Solarus  1.0.0
Surfaces

A surface is a 2D image. It is essentially a rectangle of pixels. Its main feature is that you can draw objects on it.

Functions of sol.surface

sol.surface.create([width, height])

Creates an empty surface.

  • width (number, optional): Width of the surface to create in pixels. The default value is the width of the logical screen.
  • height (number, optional): Height of the surface to create in pixels. The default value is the height of the logical screen.
  • Return value (surface): The surface created.

sol.surface.create(file_name, [language_specific])

Creates a surface from an image file.

  • file_name (string): Name of the image file to load.
  • language_specific (boolean, optional): true to load the image from the images subdirectory of the current language directory (default is false and loads the image from the sprites directory).
  • Return value (surface): The surface created.

Methods inherited from drawable

Surfaces are particular drawable objects. Therefore, they inherit all methods from the type drawable.

See Methods of all drawable types to know these methods.

Methods of the type surface

The following methods are specific to surfaces.

surface:get_size()

Returns the size of this surface.

  • Return value 1 (number): Width of the surface in pixels.
  • Return value 2 (number): Height of the surface in pixels.

surface:fill_color(color, [x, y, width, height])

Fills a region of this surface with a color.

If no region is specified, the entire surface is filled.

  • color (table): The color as an array of 3 RGB values (0 to 255).
  • x (number, optional): X coordinate of the region to fill on this surface.
  • y (number, optional): Y coordinate of the region to fill on this surface.
  • width (number, optional): Width of the region to fill on this surface.
  • height (number, optional): Height of the region to fill on this surface.

surface:set_transparency_color()

Returns the transparency color to this surface. Pixels in that color are not displayed when this surface is drawn.

  • Return value (table): The color as an array of 3 RGB values (0 to 255).

surface:set_transparency_color(color)

Sets a transparency color to this surface. Pixels in that color won't be displayed.

  • color (table): The color as an array of 3 RGB values (0 to 255).

surface:set_opacity(opacity)

Sets the opacity of this surface.

All surfaces are initially opaque.

  • opacity (integer): The opacity: 0 (transparent) to 255 (opaque).