Difference between revisions of "Pixel"
(added example) |
|||
Line 10: | Line 10: | ||
Pixel aims at being a simpler and faster alternative to Shape when needing to display a coloured box or box with a gradient. It is also useful as Bitmap replacement since every texture will be fitted into Pixel dimensions automatically. | Pixel aims at being a simpler and faster alternative to Shape when needing to display a coloured box or box with a gradient. It is also useful as Bitmap replacement since every texture will be fitted into Pixel dimensions automatically. | ||
− | === <translate> | + | === <translate>Examples</translate> === |
<source lang="lua"> | <source lang="lua"> | ||
local mypixel = Pixel.new(0x0000FF, 0.75, 128, 128) | local mypixel = Pixel.new(0x0000FF, 0.75, 128, 128) | ||
Line 17: | Line 17: | ||
stage:addChild(mypixel) | stage:addChild(mypixel) | ||
+ | </source> | ||
+ | |||
+ | <source lang="lua"> | ||
+ | application:setBackgroundColor(0x323232) | ||
+ | local p = Pixel.new(0xffffff, 1, 32, 32) | ||
+ | |||
+ | p:set("redMultiplier",1) -- OK | ||
+ | p:set("greenMultiplier",0) -- OK | ||
+ | p:set("blueMultiplier",0) -- OK | ||
+ | p:set("alphaMultiplier",1) -- OK | ||
+ | --p:set("anchorX", .5) -- NOT OK | ||
+ | --p:set("anchorY", .5) -- NOT OK | ||
+ | p:set("anchorX", 16) -- OK | ||
+ | p:set("anchorY", 16) -- OK | ||
+ | p:set("alpha", .5) -- OK | ||
+ | p:set("scaleX", 1.5) -- OK | ||
+ | p:set("rotation", 10) -- OK | ||
+ | p:set("x", 32) -- OK | ||
+ | p:set("y", 32) -- OK | ||
+ | |||
+ | stage:addChild(p) | ||
</source> | </source> | ||
Revision as of 16:53, 25 March 2020
Supported platforms:
Available since: Gideros 2016.06
Inherits from: Sprite
Description
A rectangular Sprite which can be filled with solid colors, gradients or textures. Pixel aims at being a simpler and faster alternative to Shape when needing to display a coloured box or box with a gradient. It is also useful as Bitmap replacement since every texture will be fitted into Pixel dimensions automatically.
Examples
local mypixel = Pixel.new(0x0000FF, 0.75, 128, 128)
mypixel:setAnchorPoint(0.5, 0.5)
mypixel:setPosition(application:getContentWidth() / 2, 64)
stage:addChild(mypixel)
application:setBackgroundColor(0x323232)
local p = Pixel.new(0xffffff, 1, 32, 32)
p:set("redMultiplier",1) -- OK
p:set("greenMultiplier",0) -- OK
p:set("blueMultiplier",0) -- OK
p:set("alphaMultiplier",1) -- OK
--p:set("anchorX", .5) -- NOT OK
--p:set("anchorY", .5) -- NOT OK
p:set("anchorX", 16) -- OK
p:set("anchorY", 16) -- OK
p:set("alpha", .5) -- OK
p:set("scaleX", 1.5) -- OK
p:set("rotation", 10) -- OK
p:set("x", 32) -- OK
p:set("y", 32) -- OK
stage:addChild(p)
MethodsPixel.new Create new pixel |
EventsConstants |