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
local width, height = c:size()
width = width/2
height = height/2
function c:onPaint()
self:begin()
self:clear()
c:rotate(degree)
c:fillrect(width-35, height-35, width+35, height+35, 0xA569BDFF)
degree = degree + 0.0005
sleep()
self:flip()
end
ui.run(win):wait()