The boxlayer functions provide way to make it easier to use cached offscreen images (layers) in your drawing. More...
Functions | |
t_max_err | jbox_invalidate_layer (t_object *b, t_object *view, t_symbol *name) |
Invalidate a layer, indicating that it needs to be re-drawn. More... | |
t_jgraphics * | jbox_start_layer (t_object *b, t_object *view, t_symbol *name, double width, double height) |
Create a layer, and ready it for drawing commands. More... | |
t_max_err | jbox_end_layer (t_object *b, t_object *view, t_symbol *name) |
Conclude a layer, indicating that it is complete and ready for painting. More... | |
t_max_err | jbox_paint_layer (t_object *b, t_object *view, t_symbol *name, double x, double y) |
Paint a layer at a given position. More... | |
The boxlayer functions provide way to make it easier to use cached offscreen images (layers) in your drawing.
The general idea is to do something like this:
Then, if something changes where you would need to redraw the layer you invalidate it:
or
Each view has its own layer stored since if a patcher has multiple views each could be at a different zoom level.
Conclude a layer, indicating that it is complete and ready for painting.
b | The object/box for the layer opened by jbox_start_layer(). |
view | The patcherview for the object opened by jbox_start_layer(). |
name | The name of the layer. |
Invalidate a layer, indicating that it needs to be re-drawn.
b | The object/box to invalidate. |
view | The patcherview for the object which should be invalidated, or NULL for all patcherviews. |
name | The name of the layer to invalidate. |
Paint a layer at a given position.
Note that the current color alpha value is used when painting layers to allow you to blend layers. The same is also true for jgraphics_image_surface_draw() and jgraphics_image_surface_draw_fast().
b | The object/box to be painted. |
view | The patcherview for the object which should be painted, or NULL for all patcherviews. |
name | The name of the layer to paint. |
x | The x-coordinate for the position at which to paint the layer. |
y | The y-coordinate for the position at which to paint the layer. |
t_jgraphics* jbox_start_layer | ( | t_object * | b, |
t_object * | view, | ||
t_symbol * | name, | ||
double | width, | ||
double | height | ||
) |
Create a layer, and ready it for drawing commands.
The layer drawing commands must be wrapped with a matching call to jbox_end_layer() prior to calling jbox_paint_layer().
b | The object/box to which the layer is attached. |
view | The patcherview for the object to which the layer is attached. |
name | A name for this layer. |
width | The width of the layer. |
height | The height of the layer. |