Difference between revisions of "Pixel"

From GiderosMobile
(Created page with "__NOTOC__ '''Supported platforms:''' <br/> '''Available since:''' Gideros 2016.06<br/> === Description === A rectangular Sprite which can be filled with solid colors, gradient...")
 
(28 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
'''Supported platforms:''' <br/>
+
<languages />
'''Available since:''' Gideros 2016.06<br/>
+
<!-- GIDEROSOBJ:Pixel -->
=== Description ===
+
'''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/>
 +
'''<translate>Available since</translate>:''' Gideros 2016.06<br/>
 +
'''<translate>Inherits from</translate>:''' [[Special:MyLanguage/Sprite|Sprite]]<br/>
 +
 
 +
=== <translate>Description</translate> ===
 
A rectangular Sprite which can be filled with solid colors, gradients or textures.
 
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.{|-
+
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.
| style="width: 50%;"|
+
 
=== Methods ===
+
=== <translate>Examples</translate> ===
| style="width: 50%;"|
+
<source lang="lua">
=== Events ===
+
local mypixel = Pixel.new(0x0000FF, 0.75, 128, 128)
=== Constants ===
+
mypixel:setAnchorPoint(0.5, 0.5)
 +
mypixel:setPosition(application:getContentWidth() / 2, 64)
 +
 
 +
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>
 +
 
 +
{|-
 +
| style="width: 50%; vertical-align:top;"|
 +
=== <translate>Methods</translate> ===
 +
[[Special:MyLanguage/Pixel.new|Pixel.new]] ''<translate>Create new pixel</translate>''<br/><!-- GIDEROSMTD:Pixel.new(color,alpha,width,height) Create new pixel -->
 +
[[Special:MyLanguage/Pixel.new|Pixel.new]] ''<translate>Constructor to create a Pixel with texture in letterbox mode.</translate>''<br/><!-- GIDEROSMTD:Pixel.new(texture,width,height,texture_scale_x,texture_scale_y,texture_x,texture_y) Constructor to create a Pixel with texture in letterbox mode. -->
 +
[[Special:MyLanguage/Pixel:getColor|Pixel:getColor]] ''<translate>Gets the color(s) of the Pixel</translate>''<br/><!-- GIDEROSMTD:Pixel:getColor() Gets the color(s) of the Pixel -->
 +
[[Special:MyLanguage/Pixel:getDimensions|Pixel:getDimensions]] ''Returns the current size of this Pixel'' <br/><!-- GIDEROSMTD:Pixel:getDimensions() Returns the current size of this Pixel -->
 +
[[Special:MyLanguage/Pixel:getTexturePosition|Pixel:getTexturePosition]] ''Returns the texture position'' <br/><!-- GIDEROSMTD:Pixel:getTexturePosition() Returns the texture position -->
 +
[[Special:MyLanguage/Pixel:getTextureScale|Pixel:getTextureScale]] ''Returns the texture scale'' <br/><!-- GIDEROSMTD:Pixel:getTextureScale() Returns the texture scale -->
 +
[[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]] ''Sets a gradient'' <br/><!-- GIDEROSMTD:Pixel:setColor(color1,alpha1,color2,alpha2,angle) Sets a gradient -->
 +
[[Special:MyLanguage/Pixel:setColor|Pixel:setColor]] ''<translate>Sets 4-colour gradient.</translate>''<br/><!-- GIDEROSMTD:Pixel:setColor(color1,alpha1,color2,alpha2,color3,alpha3,color4,alpha4) Sets 4-colour gradient. -->
 +
[[Special:MyLanguage/Pixel:setDimensions|Pixel:setDimensions]] ''<translate>Sets both width and height of the Pixel.</translate>''<br/><!-- GIDEROSMTD:Pixel:setDimensions(w,h) Sets both width and height of the Pixel. -->
 +
[[Special:MyLanguage/Pixel:setHeight|Pixel:setHeight]] ''<translate>Sets the height of the pixel sprite.</translate>''<br/><!-- GIDEROSMTD:Pixel:setHeight(h) Sets the height of the pixel sprite. -->
 +
[[Special:MyLanguage/Pixel:setNinePatch|Pixel:setNinePatch]] ''<translate>Configure 9-patch style texture rendering.</translate>''<br/><!-- GIDEROSMTD:Pixel:setNinePatch(vl,vr,vt,vb,tl,tr,tt,tb) Configure 9-patch style texture rendering -->
 +
[[Special:MyLanguage/Pixel:setTexture|Pixel:setTexture]] ''attach a texture to this Pixel'' <br/><!-- GIDEROSMTD:Pixel:setTexture(texture,slot,matrix) attach a texture to this Pixel -->
 +
[[Special:MyLanguage/Pixel:setTextureMatrix|Pixel:setTextureMatrix]] ''specify a transform matrix for the texture'' <br/><!-- GIDEROSMTD:Pixel:setTextureMatrix(matrix) specify a transform matrix for the texture -->
 +
[[Special:MyLanguage/Pixel:setTexturePosition|Pixel:setTexturePosition]] ''set a texture position'' <br/><!-- GIDEROSMTD:Pixel:setTexturePosition(x,y) set a texture position -->
 +
[[Special:MyLanguage/Pixel:setTextureScale|Pixel:setTextureScale]] ''set a texture scale'' <br/><!-- GIDEROSMTD:Pixel:setTextureScale(sx,sy) set a texture scale -->
 +
[[Special:MyLanguage/Pixel:setWidth|Pixel:setWidth]] ''<translate>Sets the width of the pixel sprite.</translate>''<br/><!-- GIDEROSMTD:Pixel:setWidth(w) Sets the width of the pixel sprite. -->
 +
 
 +
| style="width: 50%; vertical-align:top;"|
 +
 
 +
=== <translate>Events</translate> ===
 +
=== <translate>Constants</translate> ===
 
|}
 
|}
 +
 +
{{GIDEROS IMPORTANT LINKS}}

Revision as of 08:10, 8 January 2021


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 Returns the current size of this Pixel
Pixel:getTexturePosition Returns the texture position
Pixel:getTextureScale Returns the texture scale
Pixel:setColor Sets the color of the Pixel
Pixel:setColor Sets a gradient
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 attach a texture to this Pixel
Pixel:setTextureMatrix specify a transform matrix for the texture
Pixel:setTexturePosition set a texture position
Pixel:setTextureScale set a texture scale
Pixel:setWidth Sets the width of the pixel sprite.

Events

Constants