Canvas:scale(x, y, [ centerx, centery] ) method
Applyies a scale transformation on the Canvas
Canvas transformations are cumulative. Remember that the order of method calls (scale()
, translate()
...) must be the opposite of the order of the desired transformation.
Parameters
x
A number representing the x-axis scale factor.
y
A number representing the y-axis scale factor.
[centerx, centery]
Two numbers representing the coordinates for the scaling 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 - Scaling example", "fixed", 150, 150)
local c = ui.Canvas(win)
c.align = "all"
local scale = 0
-- Uses internal timer for 30fps drawing
function c:onPaint()
self:clear(0xffffffff)
c:scale(scale, scale)
c:rect(50,50,100,100)
scale = scale + 0.02
end
ui.run(win)