Difference between revisions of "Pixel:setColor"

From GiderosMobile
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
'''<translate>Available since</translate>:''' Gideros 2016.06<br/>
+
'''Available since:''' Gideros 2016.06<br/>
'''<translate>Class</translate>:''' [[Special:MyLanguage/Pixel|Pixel]]<br/>
+
'''Class:''' [[Pixel]]<br/>
=== <translate>Description</translate> ===
+
 
<translate>Sets the color of the Pixel</translate>
+
=== Description ===
<source lang="lua">
+
Sets the color of the Pixel.
Pixel:setColor(color,alpha)
+
<syntaxhighlight lang="lua">
</source>
+
Pixel:setColor(color,alpha)
=== <translate>Parameters</translate> ===
+
</syntaxhighlight>
'''color''': (number) <translate>new color</translate> '''optional'''<br/>
+
 
'''alpha''': (number) <translate>New alpha value</translate> '''optional'''<br/>
+
=== Parameters ===
 +
'''color''': (number) new color '''optional'''<br/>
 +
'''alpha''': (number) new alpha value '''optional'''<br/>
 +
 
 +
 
 +
----
 
__NOTOC__
 
__NOTOC__
'''<translate>Available since</translate>:''' Gideros 2011.6<br/>
+
'''Available since:''' Gideros 2016.12<br/>
'''<translate>Class</translate>:''' [[Special:MyLanguage/Pixel|Pixel]]<br/>
+
'''Class:''' [[Pixel]]<br/>
=== <translate>Description</translate> ===
+
 
<translate>Sets two-colour gradient fill with optional rotation to Pixel.</translate>
+
=== Description ===
<source lang="lua">
+
Sets two-color gradient fill with optional rotation to Pixel.
Pixel:setColor(color1,alpha1,color2,alpha2,angle)
+
<syntaxhighlight lang="lua">
</source>
+
Pixel:setColor(color1,alpha1,color2,alpha2,angle)
=== <translate>Parameters</translate> ===
+
</syntaxhighlight>
'''color1''': (number) <translate>First color of the gradient.</translate> <br/>
+
 
'''alpha1''': (number) <translate>First alpha of the gradient.</translate> <br/>
+
=== Parameters ===
'''color2''': (number) <translate>Second color of the gradient.</translate> <br/>
+
'''color1''': (number) first color of the gradient<br/>
'''alpha2''': (number) <translate>Second alpha of the gradient.</translate> <br/>
+
'''alpha1''': (number) first alpha of the gradient<br/>
'''angle''': (number) <translate>Sets rotation of the gradient in degrees. Default value is 270: top-bottom gradient.</translate> '''optional'''<br/>
+
'''color2''': (number) second color of the gradient<br/>
 +
'''alpha2''': (number) second alpha of the gradient<br/>
 +
'''angle''': (number) sets rotation of the gradient in degrees, default = 270 deg (top-bottom gradient) '''optional'''<br/>
 +
 
 +
 
 +
----
 
__NOTOC__
 
__NOTOC__
'''<translate>Available since</translate>:''' Gideros 2011.6<br/>
+
'''Available since:''' Gideros 2018.6<br/>
'''<translate>Class</translate>:''' [[Special:MyLanguage/Pixel|Pixel]]<br/>
+
'''Class:''' [[Pixel]]<br/>
=== <translate>Description</translate> ===
+
 
<translate>Sets 4-colour gradient fill to Pixel.</translate>
+
=== Description ===
<source lang="lua">
+
Sets 4-colour gradient fill to Pixel.
Pixel:setColor(color1,alpha1,color2,alpha2,color3,alpha3,color4,alpha4)
+
<syntaxhighlight lang="lua">
</source>
+
Pixel:setColor(color1,alpha1,color2,alpha2,color3,alpha3,color4,alpha4)
=== <translate>Parameters</translate> ===
+
</syntaxhighlight>
'''color1''': (number) <translate>Color of top-left gradient corner.</translate> <br/>
+
 
'''alpha1''': (number) <translate>Alpha of top-left gradient corner.</translate> <br/>
+
=== Parameters ===
'''color2''': (number) <translate>Color of top-right gradient corner.</translate> <br/>
+
'''color1''': (number) color of top-left gradient corner<br/>
'''alpha2''': (number) <translate>Alpha of top-right gradient corner.</translate> <br/>
+
'''alpha1''': (number) alpha of top-left gradient corner<br/>
'''color3''': (number) <translate>Color of bottom-right gradient corner.</translate> <br/>
+
'''color2''': (number) color of top-right gradient corner<br/>
'''alpha3''': (number) <translate>Alpha of bottom-right gradient corner.</translate> <br/>
+
'''alpha2''': (number) alpha of top-right gradient corner<br/>
'''color4''': (number) <translate>Color of bottom-left gradient corner.</translate> <br/>
+
'''color3''': (number) color of bottom-right gradient corner<br/>
'''alpha4''': (number) <translate>Alpha of bottom-left gradient corner.</translate> <br/>
+
'''alpha3''': (number) alpha of bottom-right gradient corner<br/>
 +
'''color4''': (number) color of bottom-left gradient corner<br/>
 +
'''alpha4''': (number) alpha of bottom-left gradient corner<br/>
 +
 
 +
== 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)
 +
</syntaxhighlight>
 +
 
 +
{{Pixel}}

Latest revision as of 14:32, 13 July 2023

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 = 270 deg (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)