Surface - JakeTurner616/pygame-lua-bindings GitHub Wiki

Pygame surface functions

create_surface(width, height, flags=0, depth=0)

Create a new Pygame surface with the specified width, height, flags, and depth.

Parameters:

  • width: The width of the surface.
  • height: The height of the surface.
  • flags: Optional surface flags (default is 0).
  • depth: Optional depth (default is 0).

Returns: A new Pygame surface.

surface_blit(surface, source, x, y)

Blit a source surface onto a destination surface at the specified coordinates.

Parameters:

  • surface: The destination surface.
  • source: The source surface.
  • x: The x-coordinate on the destination surface.
  • y: The y-coordinate on the destination surface.

Returns: A rectangle representing the area of the destination surface that was changed.

surface_blits(surface, blit_sequence)

Blit multiple source surfaces onto a destination surface using a sequence of blits.

Parameters:

  • surface: The destination surface.
  • blit_sequence: A sequence of blits.

Returns: A list of rectangles representing the areas of the destination surface that were changed.

surface_convert(surface, display_surface=None)

Convert a surface to the same pixel format as another surface (display surface).

Parameters:

  • surface: The surface to convert.
  • display_surface: The display surface to match the format of (optional).

Returns: A new surface with the same format as the display surface.

surface_convert_alpha(surface)

Convert a surface to include per-pixel alpha.

Parameters:

  • surface: The surface to convert.

Returns: A new surface with per-pixel alpha.

surface_copy(surface)

Create a copy of the surface.

Parameters:

  • surface: The surface to copy.

Returns: A new surface that is a copy of the original.

surface_fill(surface, color, rect=None, special_flags=0)

Fill a surface with a color, optionally within a specific rectangle and with special flags.

Parameters:

  • surface: The surface to fill.
  • color: The color to fill with.
  • rect: The rectangle to fill (optional).
  • special_flags: Special fill flags (optional, default is 0).

Returns: A rectangle representing the filled area.

surface_scroll(surface, dx=0, dy=0)

Scroll the surface by the specified amount.

Parameters:

  • surface: The surface to scroll.
  • dx: The amount to scroll horizontally (default is 0).
  • dy: The amount to scroll vertically (default is 0).

Returns: None

surface_set_colorkey(surface, color, flags=0)

Set the transparent color key for the surface.

Parameters:

  • surface: The surface to set the color key for.
  • color: The color key.
  • flags: Optional flags (default is 0).

Returns: None

surface_get_colorkey(surface)

Get the transparent color key for the surface.

Parameters:

  • surface: The surface to get the color key from.

Returns: The color key.

surface_set_alpha(surface, value, flags=0)

Set the alpha value for the entire surface.

Parameters:

  • surface: The surface to set the alpha value for.
  • value: The alpha value.
  • flags: Optional flags (default is 0).

Returns: None

surface_get_alpha(surface)

Get the alpha value for the entire surface.

Parameters:

  • surface: The surface to get the alpha value from.

Returns: The alpha value.

surface_lock(surface)

Lock the surface for pixel access.

Parameters:

  • surface: The surface to lock.

Returns: None

surface_unlock(surface)

Unlock the surface after pixel access.

Parameters:

  • surface: The surface to unlock.

Returns: None

surface_get_at(surface, x, y)

Get the color of the pixel at the specified position.

Parameters:

  • surface: The surface to get the pixel color from.
  • x: The x-coordinate of the pixel.
  • y: The y-coordinate of the pixel.

Returns: A color tuple representing the pixel color.

surface_set_at(surface, x, y, color)

Set the color of the pixel at the specified position.

Parameters:

  • surface: The surface to set the pixel color on.
  • x: The x-coordinate of the pixel.
  • y: The y-coordinate of the pixel.
  • color: The color to set.

Returns: None

surface_subsurface(surface, x, y, width, height)

Create a subsurface from a surface.

Parameters:

  • surface: The original surface.
  • x: The x-coordinate of the subsurface.
  • y: The y-coordinate of the subsurface.
  • width: The width of the subsurface.
  • height: The height of the subsurface.

Returns: A new subsurface.

surface_get_size(surface)

Get the size of the surface.

Parameters:

  • surface: The surface to get the size of.

Returns: A tuple representing the width and height of the surface.

surface_get_width(surface)

Get the width of the surface.

Parameters:

  • surface: The surface to get the width of.

Returns: The width of the surface.

surface_get_height(surface)

Get the height of the surface.

Parameters:

  • surface: The surface to get the height of.

Returns: The height of the surface.

surface_get_rect(surface)

Get the rectangle covering the entire surface.

Parameters:

  • surface: The surface to get the rectangle from.

Returns: A pygame.Rect object representing the rectangle covering the surface.