What is 'skew' (aka 'shear mapping')? I will quote Wikipedia (
https://en.wikipedia.org/wiki/Shear_mapping):
In plane geometry, a shear mapping is a linear map that displaces each point in fixed direction, by an amount proportional to its signed distance from a line that is parallel to that direction
A picture here is worth a thousand words:
In Gideros you can apply skew effect to any Sprite class with `Sprite:setSkew(kx, ky)` where `kx` and `ky` are horizontal and vertical skew factors in range from -90 to 90 degrees. There are short versions too: `setSkewX(kx)` and `setSkewY(ky)`.
Skew effects are very useful, for example
@SinisterSoft uses them for shadows:
http://giderosmobile.com/forum/discussion/6729/using-a-mask-and-the-new-sprite-skew-commands-to-make-a-shadow#Item_7And this YouTube video demonstrates skew-based animation in Cocos2D:
You may use `Sprite:setSkewX` in ENTER_FRAME event to achieve same animation effect in Gideros.
And of course you can easily create italics text with skewX:
Note: to left align skewed text use following snippet:
local offsetX = -math.tan(math.rad(math.min(text:getSkewX(), 0))) * text:getHeight()
text:setX(offsetX) |