Canvas:rotate(angle, [ x, y] ) method


Applyies a rotation transformation on the Canvas

Canvas transformations are cumulative. Remember that the order of method calls (rotate(), translate()...) must be the opposite of the order of the desired transformation.

Parameters

angle

A number representing the rotation angle in degrees. A positive angle creates a clockwise rotation, and a negative angle creates a counterclockwise rotation.

[x, y]

Two numbers representing the coordinates for the rotation center point, defaulting to the center of the Canvas.

Return value

This function returns no value.

Example

local ui = require "ui" require "canvas" local win = ui.Window("Canvas - Rotation example", "fixed", 320, 240) local c = ui.Canvas(win) c.align = "all" local degree = 0 -- Uses internal timer for 30fps drawing function c:onPaint() self:clear(0xffffffff) c:rotate(degree) c:rect(50,50,100,100) degree = degree + 2 end ui.run(win)