Canvas:scale(x, y, [centerx], [centery])method


Applyies a scale transformation on the Canvas

Parameters

x

A number representing the x-axis scale factor.

y

A number representing the y-axis scale factor.

[centerx]

The horizonal coordinate for the scale center point, defaulting to the center of the Canvas.

[centery]

The vertical coordinate for the scale center point, defaulting to the center of the Canvas.

Return value

This function returns no value.

Example

--! luart-extensions import 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 await win:showasync()