Canvas translate

From Sim Innovations Wiki
Jump to navigation Jump to search


_translate(x, y)

_translate is used to move all shapes drawn after this call in x and/or y position.

Info This function may only be called within a canvas draw callback

Return value

This function won't return any value.


# Argument Type Description
1 x Number X position
2 y Number Y position


canvas_add(0, 0, 200, 200, function()
  -- Draw a red rectangle with rotation
  _rect(0, 0, 100, 100)

  -- From this point everything is drawn with a x offset of 100
  _translate(100, 0)

  -- Draw a second blue rectangle
  -- Because of the tranlate above, this will be drawn at the 100, 0 position
  _rect(0, 0, 100, 100)