1.09.01 - 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.

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

Creates a surface from an image file.

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.

surface:clear()

Erases all pixels of this surface.

All pixels become transparent. The opacity property and the size of the surface are preserved.

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. If the color has an alpha component different from 255 (opaque), then the color is blended onto the existing pixels.

surface:get_opacity()

Returns the opacity of this surface.

surface:set_opacity(opacity)

Sets the opacity of this surface.

All surfaces are initially opaque.

surface:get_pixels()

Returns all pixel values of this surface.

surface:set_pixels(pixels)

Sets all pixel values of this surface.

The number of pixels should match the size of the surface (the size does not change).