Difference between revisions of "Pixel"

From GiderosMobile
(removed language stuff)
(23 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
'''Supported platforms:''' <br/>
+
<!-- GIDEROSOBJ:Pixel -->
 +
'''Supported platforms:''' [[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/>
 
'''Available since:''' Gideros 2016.06<br/>
 
'''Available since:''' Gideros 2016.06<br/>
 +
'''Inherits from:''' [[Sprite]]<br/>
 +
 
=== Description ===
 
=== 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.</translate>
+
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 ===
 +
<source lang="lua">
 +
local mypixel = Pixel.new(0x0000FF, 0.75, 128, 128)
 +
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;"|
 
| style="width: 50%; vertical-align:top;"|
 
=== Methods ===
 
=== Methods ===
[[Pixel.new]] ''<translate>Create new pixel</translate>''<br/>
+
[[Pixel.new]] ''creates a new Pixel''<br/><!--GIDEROSMTD:Pixel.new(color,alpha,width,height) creates a new Pixel-->
[[Pixel.new]] ''<translate>Constructor to create a Pixel with texture in letterbox mode.</translate>''<br/>
+
[[Pixel.new]] ''constructor to create a Pixel with texture in letterbox mode''<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-->
[[Pixel:getColor]] ''<translate>Gets the color(s) of the Pixel</translate>''<br/>
+
[[Pixel:getColor]] ''returns the color(s) of the Pixel''<br/><!--GIDEROSMTD:Pixel:getColor() gets the color(s) of the Pixel-->
[[Pixel:getDimensions]] ''<translate></translate>''<br/>
+
[[Pixel:getDimensions]] ''returns the current size of the Pixel''<br/><!--GIDEROSMTD:Pixel:getDimensions() returns the current size of the Pixel-->
[[Pixel:getTexturePosition]] ''<translate></translate>''<br/>
+
[[Pixel:getTexturePosition]] ''returns the texture position''<br/><!--GIDEROSMTD:Pixel:getTexturePosition() returns the texture position-->
[[Pixel:getTextureScale]] ''<translate></translate>''<br/>
+
[[Pixel:getTextureScale]] ''returns the texture scale''<br/><!--GIDEROSMTD:Pixel:getTextureScale() returns the texture scale-->
[[Pixel:setColor]] ''<translate>Sets the color of the Pixel</translate>''<br/>
+
[[Pixel:setColor]] ''sets the color of the Pixel''<br/><!--GIDEROSMTD:Pixel:setColor(color,alpha) sets the color of the Pixel-->
[[Pixel:setColor]] ''<translate></translate>''<br/>
+
[[Pixel:setColor]] ''sets a gradient''<br/><!--GIDEROSMTD:Pixel:setColor(color1,alpha1,color2,alpha2,angle) sets a gradient-->
[[Pixel:setColor]] ''<translate>Sets 4-colour gradient.</translate>''<br/>
+
[[Pixel:setColor]] ''sets a 4-colour gradient''<br/><!--GIDEROSMTD:Pixel:setColor(color1,alpha1,color2,alpha2,color3,alpha3,color4,alpha4) sets a 4-colour gradient-->
[[Pixel:setDimensions]] ''<translate>Sets both width and height of the Pixel.</translate>''<br/>
+
[[Pixel:setDimensions]] ''sets both width and height of the Pixel''<br/><!--GIDEROSMTD:Pixel:setDimensions(w,h) sets both width and height of the Pixel-->
[[Pixel:setHeight]] ''<translate>Sets the height of the pixel sprite.</translate>''<br/>
+
[[Pixel:setHeight]] ''sets the height of the Pixel sprite''<br/><!--GIDEROSMTD:Pixel:setHeight(h) sets the height of the Pixel sprite-->
[[Pixel:setTexture]] ''<translate></translate>''<br/>
+
[[Pixel:setNinePatch]] ''sets a 9-patch style texture rendering''<br/><!--GIDEROSMTD:Pixel:setNinePatch(vl,vr,vt,vb,tl,tr,tt,tb) sets a 9-patch style texture rendering-->
[[Pixel:setTextureMatrix]] ''<translate></translate>''<br/>
+
[[Pixel:setTexture]] ''attaches a texture to the Pixel''<br/><!--GIDEROSMTD:Pixel:setTexture(texture,slot,matrix) attaches a texture to the Pixel-->
[[Pixel:setTexturePosition]] ''<translate></translate>''<br/>
+
[[Pixel:setTextureMatrix]] ''specifies a transform matrix for the texture''<br/><!--GIDEROSMTD:Pixel:setTextureMatrix(matrix) specifies a transform matrix for the texture-->
[[Pixel:setTextureScale]] ''<translate></translate>''<br/>
+
[[Pixel:setTexturePosition]] ''sets a texture position''<br/><!--GIDEROSMTD:Pixel:setTexturePosition(x,y) sets a texture position-->
[[Pixel:setWidth]] ''<translate>Sets the width of the pixel sprite.</translate>''<br/>
+
[[Pixel:setTextureScale]] ''sets a texture scale''<br/><!--GIDEROSMTD:Pixel:setTextureScale(sx,sy) sets a texture scale-->
 +
[[Pixel:setWidth]] ''sets the width of the Pixel sprite''<br/><!--GIDEROSMTD:Pixel:setWidth(w) sets the width of the Pixel sprite-->
 +
 
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
 +
 
=== Events ===
 
=== Events ===
 
=== Constants ===
 
=== Constants ===
 
|}
 
|}
 +
 +
{{GIDEROS IMPORTANT LINKS}}

Revision as of 01:49, 13 April 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 creates a new Pixel
Pixel.new constructor to create a Pixel with texture in letterbox mode
Pixel:getColor returns the color(s) of the Pixel
Pixel:getDimensions returns the current size of the 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 a 4-colour gradient
Pixel:setDimensions sets both width and height of the Pixel
Pixel:setHeight sets the height of the Pixel sprite
Pixel:setNinePatch sets a 9-patch style texture rendering
Pixel:setTexture attaches a texture to the Pixel
Pixel:setTextureMatrix specifies a transform matrix for the texture
Pixel:setTexturePosition sets a texture position
Pixel:setTextureScale sets a texture scale
Pixel:setWidth sets the width of the Pixel sprite

Events

Constants