Graphics 2D Management
Understanding the allocation system
When you create graphics, you need to allocate them. This means that you need to create a new graphics object, and then you need to draw on it.
When you're done drawing, you need to dispose of it. This must be done by yourself in order to avoid memory leaks.
Creating a graphics
You can easily create & store 2D graphics with the following expression:
Danger
As explained above, you need to dispose of the graphics when you're done drawing on it. You can do so with the following effect:
You won't be able to draw on the graphics after disposing it.
Drawing on a graphics
Shapes
You can draw several shapes on a graphics. You first need to create and configure the shape itself, then draw it at the specified location.
When you have a shape, you can draw it using the following effect:
Info
The colors are Skript color. You can however use color from rgb
to create a color from RGB values.
For these example, we'll have a blank (transparent) image of 100x100 pixels. Also, anti-aliasing is enabled and the stroke is set to a width of 5.
Images
You can also draw images on the graphics:
Note
For drawing with semi-transparent colors, you need:
- An image with RGBA format (see image types for more information)
- The proper composite effect set (see composite effects for details)