FixImage Documentation
Back to summary
import "image/image";
Painter class
Painter is used to draw 2D shapes into an Image.
Initialization
static function create(img: Image): Painter
-
Creates a new painter for given image.
Properties
function get_image(): Image
-
Returns the image this painter is created for.
function get_transform(): Transform
-
Returns the current 2D transform of the painter as a direct reference.
State
function push()
-
Pushes the drawing state (current translation, rotation, antialiasing settings, etc.)
into a stack so it can be later restored by the
pop
function.
function pop()
-
Pops the drawing state from a stack to restore the state to what was set when calling a previous
push
function.
function set_subpixel_rendering(enabled: Boolean)
-
Sets subpixel rendering.
function set_subpixel_order(value: Integer)
-
Sets the order of pixels used in subpixel rendering (either
SUBPIXEL_RGB
or SUBPIXEL_BGR
).
function set_blend_gamma(value: Float)
-
Sets blending gamma adjustment, this may be required for shapes to have the same thickness
on both black and white backgrounds. Typically it is used mainly for font rendering to fine-tune
the appearance in small sizes. When the gamma is other than 1.0 (no adjustment) the performance
is affected.
Transform
function translate(tx: Float, ty: Float)
-
Translates the subsequent drawing.
function rotate(angle: Float)
-
Rotates the subsequent drawing.
function scale(s: Float)
function scale(sx: Float, sy: Float)
-
Scales the subsequent drawing.
function shear(sx: Float, sy: Float)
-
Shears the subsequent drawing.
function apply(tr: Transform)
-
Applies given transform for subsequent drawing.
Clipping
function clip(rect: Rect)
function clip(x: Integer, y: Integer, width: Integer, height: Integer)
-
Clips the rendering with given rectangle. The clipping can be made smaller only.
function clip_shape(shape: Shape)
-
Clips the rendering with given 2D shape, multiple clipping shapes are simply added into one shape,
it is essential that the clip shape is non-overlapping and is in the clockwise direction.
function get_clip_rect(): Rect
-
Returns the current clipping rectangle.
Drawing
function clear_rect(rect: Rect, color: Integer)
function clear_rect(x: Integer, y: Integer, width: Integer, height: Integer, color: Integer)
-
Clears (by setting the pixels without any blending) the rectangle with given color.
function fill_rect(rect: Rect, color: Integer)
function fill_rect(x: Integer, y: Integer, width: Integer, height: Integer, color: Integer)
-
Fills the rectangle with given color.
function fill_rect(x: Integer, y: Integer, width: Integer, height: Integer, <shader>)
-
Fills the rectangle using the colors produced by the shader.
function fill_shape(shape: Shape, color: Integer)
-
Fills a 2D shape with given color.
function fill_shape(shape: Shape, <shader>)
-
Fills a 2D shape using the colors produced by the shader.
function draw_image(x: Integer, y: Integer, img: Image)
-
Draws an image. To customize drawing (eg. to draw only part of the image or other effects) use
fill_rect
or fill_shape
with shaders.
Batched rendering
function batch_begin()
-
Starts rendering in a batch. The next drawing operations are stored and binned into small
tiles of the image. Then when you call
batch_flush
or batch_end
the tiles are actually rendered, making the rendering evenly spread across CPU cores and
thus being faster and more efficient.
Note: The used images, transforms and other referenced data in the drawing operations
are stored by reference and must not change until the batch is actually rendered.
function batch_flush()
-
Renders drawing operations currently accumulated in the batch without disabling the batch
rendering mode.
function batch_end()
-
Renders drawing operations currently accumulated in the batch and disables the batch
rendering mode for next drawing operations.