Difference between revisions of "Pixel:setColor"

From GiderosMobile
(removed language stuff)
m (Text replacement - "<source" to "<syntaxhighlight")
Line 5: Line 5:
 
=== Description ===
 
=== Description ===
 
Sets the color of the Pixel.
 
Sets the color of the Pixel.
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
Pixel:setColor(color,alpha)
 
Pixel:setColor(color,alpha)
 
</source>
 
</source>
Line 21: Line 21:
 
=== Description ===
 
=== Description ===
 
Sets two-color gradient fill with optional rotation to Pixel.
 
Sets two-color gradient fill with optional rotation to Pixel.
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
Pixel:setColor(color1,alpha1,color2,alpha2,angle)
 
Pixel:setColor(color1,alpha1,color2,alpha2,angle)
 
</source>
 
</source>
Line 40: Line 40:
 
=== Description ===
 
=== Description ===
 
Sets 4-colour gradient fill to Pixel.
 
Sets 4-colour gradient fill to Pixel.
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
Pixel:setColor(color1,alpha1,color2,alpha2,color3,alpha3,color4,alpha4)
 
Pixel:setColor(color1,alpha1,color2,alpha2,color3,alpha3,color4,alpha4)
 
</source>
 
</source>
Line 56: Line 56:
 
== Example ==
 
== Example ==
 
'''A two-color pixel gradient'''
 
'''A two-color pixel gradient'''
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
local pixel = Pixel.new(0xffffff, 1, 128, 128) -- set a white color to start with
 
local pixel = Pixel.new(0xffffff, 1, 128, 128) -- set a white color to start with
 
pixel:setAnchorPoint(0.5, 0.5)
 
pixel:setAnchorPoint(0.5, 0.5)

Revision as of 15:30, 13 July 2023

Available since: Gideros 2016.06
Class: Pixel

Description

Sets the color of the Pixel. <syntaxhighlight lang="lua"> Pixel:setColor(color,alpha) </source>

Parameters

color: (number) new color optional
alpha: (number) new alpha value optional



Available since: Gideros 2016.12
Class: Pixel

Description

Sets two-color gradient fill with optional rotation to Pixel. <syntaxhighlight lang="lua"> Pixel:setColor(color1,alpha1,color2,alpha2,angle) </source>

Parameters

color1: (number) first color of the gradient
alpha1: (number) first alpha of the gradient
color2: (number) second color of the gradient
alpha2: (number) second alpha of the gradient
angle: (number) sets rotation of the gradient in degrees, default = 270 deg (top-bottom gradient) optional



Available since: Gideros 2018.6
Class: Pixel

Description

Sets 4-colour gradient fill to Pixel. <syntaxhighlight lang="lua"> Pixel:setColor(color1,alpha1,color2,alpha2,color3,alpha3,color4,alpha4) </source>

Parameters

color1: (number) color of top-left gradient corner
alpha1: (number) alpha of top-left gradient corner
color2: (number) color of top-right gradient corner
alpha2: (number) alpha of top-right gradient corner
color3: (number) color of bottom-right gradient corner
alpha3: (number) alpha of bottom-right gradient corner
color4: (number) color of bottom-left gradient corner
alpha4: (number) alpha of bottom-left gradient corner

Example

A two-color pixel gradient <syntaxhighlight lang="lua"> local pixel = Pixel.new(0xffffff, 1, 128, 128) -- set a white color to start with pixel:setAnchorPoint(0.5, 0.5) pixel:setScale(1.5) pixel:setPosition(100, 100) pixel:setColor(0xFF0000, 1, 0x0D8CFF, 1, 90) -- a gradient set horizontally stage:addChild(pixel) </source>