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 local delta = 0.02 -- Uses internal timer for 30fps drawing function c:onPaint() self:begin() self:clear(0xffffffff) -- Resets the canvas transformations c:identity() -- Sets the new scale transformation c:scale(scale, scale) c:fillrect(50,50,100,100, 0xF0A0D7FF) self:flip() sleep() scale = scale + delta if scale > 2 then delta = -0.02 elseif scale < 0.02 then delta = 0.02 end end ui.run(win):wait()