# 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 state into a stack so it can be later restored by the `pop` function.
`function pop()`
  Pops the state from a stack to restore it from 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 having 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.

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