Layer¶
The Layer class provides functionalities for managing drawing layers, which includes adding objects to layers and drawing all layers in order of their z-index.
- class Layer¶
This class represents a drawing layer with a z-index and objects.
- new(z_index)¶
Creates a new
Layerinstance.- Parameters:
z_index (
number) – The z-index of the layer, determining its drawing order. Defaults to0.- Returns:
A new instance of
Layer.
- draw_all()¶
Draws all layers in order of their z-index.
- add(object, draw_function_name)¶
Adds an object to the layer.
- Parameters:
object (
table) – The object to be added to the layer.draw_function_name (
string) – The name of the draw function to be used for the object. Defaults to"draw".
- draw()¶
Draws all objects in the layer using their specified draw function.