Difference between revisions of "Pixel"

From GiderosMobile
(added example)
(added setAlpha)
Line 49: Line 49:
 
[[Special:MyLanguage/Pixel:getTexturePosition|Pixel:getTexturePosition]] <br/><!-- GIDEROSMTD:Pixel:getTexturePosition()  -->
 
[[Special:MyLanguage/Pixel:getTexturePosition|Pixel:getTexturePosition]] <br/><!-- GIDEROSMTD:Pixel:getTexturePosition()  -->
 
[[Special:MyLanguage/Pixel:getTextureScale|Pixel:getTextureScale]] <br/><!-- GIDEROSMTD:Pixel:getTextureScale()  -->
 
[[Special:MyLanguage/Pixel:getTextureScale|Pixel:getTextureScale]] <br/><!-- GIDEROSMTD:Pixel:getTextureScale()  -->
 +
[[Special:MyLanguage/Pixel:setAlpha|Pixel:setAlpha]] ''<translate>Sets the alpha color of the Pixel</translate>''<br/><!-- GIDEROSMTD:Pixel:setAlpha(alpha) Sets the alpha color of the Pixel -->
 
[[Special:MyLanguage/Pixel:setColor|Pixel:setColor]] ''<translate>Sets the color of the Pixel</translate>''<br/><!-- GIDEROSMTD:Pixel:setColor(color,alpha) Sets the color of the Pixel -->
 
[[Special:MyLanguage/Pixel:setColor|Pixel:setColor]] ''<translate>Sets the color of the Pixel</translate>''<br/><!-- GIDEROSMTD:Pixel:setColor(color,alpha) Sets the color of the Pixel -->
 
[[Special:MyLanguage/Pixel:setColor|Pixel:setColor]] <br/><!-- GIDEROSMTD:Pixel:setColor(color1,alpha1,color2,alpha2,angle)  -->
 
[[Special:MyLanguage/Pixel:setColor|Pixel:setColor]] <br/><!-- GIDEROSMTD:Pixel:setColor(color1,alpha1,color2,alpha2,angle)  -->

Revision as of 21:47, 29 March 2020


Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.pngPlatform html5.pngPlatform winrt.pngPlatform win32.png
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)

Methods

Pixel.new Create new pixel
Pixel.new Constructor to create a Pixel with texture in letterbox mode.
Pixel:getColor Gets the color(s) of the Pixel
Pixel:getDimensions
Pixel:getTexturePosition
Pixel:getTextureScale
Pixel:setAlpha Sets the alpha color of the Pixel
Pixel:setColor Sets the color of the Pixel
Pixel:setColor
Pixel:setColor Sets 4-colour gradient.
Pixel:setDimensions Sets both width and height of the Pixel.
Pixel:setHeight Sets the height of the pixel sprite.
Pixel:setNinePatch Configure 9-patch style texture rendering.
Pixel:setTexture
Pixel:setTextureMatrix
Pixel:setTexturePosition
Pixel:setTextureScale
Pixel:setWidth Sets the width of the pixel sprite.

Events

Constants