Difference between revisions of "Pixel:setColor"

(added example)
 
Line 6: Line 6:
 
<translate>Sets the color of the Pixel</translate>
 
<translate>Sets the color of the Pixel</translate>
 
<source lang="lua">
 
<source lang="lua">
Pixel:setColor(color,alpha)
+
Pixel:setColor(color,alpha)
 
</source>
 
</source>
 
=== <translate>Parameters</translate> ===
 
=== <translate>Parameters</translate> ===
Line 16: Line 16:
 
'''<translate>Class</translate>:''' [[Special:MyLanguage/Pixel|Pixel]]<br/>
 
'''<translate>Class</translate>:''' [[Special:MyLanguage/Pixel|Pixel]]<br/>
 
=== <translate>Description</translate> ===
 
=== <translate>Description</translate> ===
<translate>Sets two-colour gradient fill with optional rotation to Pixel.</translate>
+
<translate>Sets two-color gradient fill with optional rotation to Pixel.</translate>
 
<source lang="lua">
 
<source lang="lua">
Pixel:setColor(color1,alpha1,color2,alpha2,angle)
+
Pixel:setColor(color1,alpha1,color2,alpha2,angle)
 
</source>
 
</source>
 
=== <translate>Parameters</translate> ===
 
=== <translate>Parameters</translate> ===
Line 33: Line 33:
 
<translate>Sets 4-colour gradient fill to Pixel.</translate>
 
<translate>Sets 4-colour gradient fill to Pixel.</translate>
 
<source lang="lua">
 
<source lang="lua">
Pixel:setColor(color1,alpha1,color2,alpha2,color3,alpha3,color4,alpha4)
+
Pixel:setColor(color1,alpha1,color2,alpha2,color3,alpha3,color4,alpha4)
 
</source>
 
</source>
 
=== <translate>Parameters</translate> ===
 
=== <translate>Parameters</translate> ===
Line 44: Line 44:
 
'''color4''': (number) <translate>Color of bottom-left gradient corner.</translate> <br/>
 
'''color4''': (number) <translate>Color of bottom-left gradient corner.</translate> <br/>
 
'''alpha4''': (number) <translate>Alpha of bottom-left gradient corner.</translate> <br/>
 
'''alpha4''': (number) <translate>Alpha of bottom-left gradient corner.</translate> <br/>
 +
 +
== <translate>Example</translate> ==
 +
A two-color pixel gradient:
 +
<source 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>
  
 
{{Pixel}}
 
{{Pixel}}

Latest revision as of 02:11, 24 May 2020


Available since: Gideros 2016.06
Class: Pixel

Description

Sets the color of the Pixel

Pixel:setColor(color,alpha)

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.

Pixel:setColor(color1,alpha1,color2,alpha2,angle)

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 value is 270: top-bottom gradient. optional


Available since: Gideros 2018.6
Class: Pixel

Description

Sets 4-colour gradient fill to Pixel.

Pixel:setColor(color1,alpha1,color2,alpha2,color3,alpha3,color4,alpha4)

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:

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)