Difference between revisions of "Shape:setFillStyle"

From GiderosMobile
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
<languages />
+
'''Available since:''' Gideros 2011.6<br/>
'''<translate>Available since</translate>:''' Gideros 2011.6<br/>
+
'''Class:''' [[Shape]]<br/>
'''<translate>Class</translate>:''' [[Special:MyLanguage/Shape|Shape]]
 
<br/>
 
  
=== <translate>Description</translate> ===
+
=== Description ===
<translate>
+
Sets the fill style that '''Shape''' object uses for subsequent drawings. The fill style remains in effect until you call ''setFillStyle()'' function with different parameters.
<br/>
+
<syntaxhighlight lang="lua">
Sets the fill style that [[Special:MyLanguage/Shape|Shape]] object uses for subsequent drawings. The fill style remains in effect until you call ''setFillStyle()'' function with different parameters.
+
Shape:setFillStyle(fillstyle,...)
<br/>
+
</syntaxhighlight>
<br/>
 
  
See the following example for more detailed usage of this function:
+
''fillstyle'' parameter can be one of the following values:
<br/>
+
* '''Shape.NONE''': clears the fill style
<source lang="lua">
+
* '''Shape.SOLID''': sets the fill style as a solid color. In this mode, the parameters are color (in hexadecimal value) and an optional alpha value
Shape:setFillStyle(type,...)
+
* '''Shape.TEXTURE''': sets the fill style as textured. In this mode, the parameters are texture and an optional transformation matrix
</source>
 
<br/>
 
  
[[Special:MyLanguage/type|type]] parameter can be one of the following values:<br/>
+
=== Parameters ===
<ul>
+
'''fillstyle''': (string) the fill style type<br/>
<li>'''Shape.NONE''': Clears the fill style.</li>
+
'''...''': (any) parameters of the fill style<br/>
<li>'''Shape.SOLID''': Sets the fill style as a solid color. In this mode, the parameters are color (in hexedecial value) and an optional alpha value.</li>
 
<li>'''Shape.TEXTURE''': Sets the fill style as a textured. In this mode, the parameters are texture and an optional transformation matrix.</li>
 
</ul>
 
</translate>
 
<br/>
 
  
=== <translate>Parameters</translate> ===
+
=== Examples ===
<br/>
+
<syntaxhighlight lang="lua">
 
 
'''type''': (string) <translate>The type of the fill. Can be one of the Shape.NONE, Shape.SOLID or Shape.TEXTURE.</translate>
 
'''...''': (any) <translate>Parameters of the fill style.</translate>
 
<br/>
 
<br/>
 
 
 
=== <translate>Examples</translate> ===
 
<br/>
 
'''Examples'''
 
<br/>
 
 
 
<source lang="lua">
 
 
setFillStyle(Shape.NONE) -- clears the fill style
 
setFillStyle(Shape.NONE) -- clears the fill style
 
 
setFillStyle(Shape.SOLID, 0xff0000) -- sets the fill style as solid red color
 
setFillStyle(Shape.SOLID, 0xff0000) -- sets the fill style as solid red color
 
 
setFillStyle(Shape.SOLID, 0xff0000, 0.5) -- sets the fill style as solid red color with 0.5 transparency
 
setFillStyle(Shape.SOLID, 0xff0000, 0.5) -- sets the fill style as solid red color with 0.5 transparency
  
Line 54: Line 30:
 
setFillStyle(Shape.TEXTURE, texture, matrix) -- sets the fill style as texture with "image.png" with a transformation matrix
 
setFillStyle(Shape.TEXTURE, texture, matrix) -- sets the fill style as texture with "image.png" with a transformation matrix
  
<!--
+
--[[
 
setFillStyle(Shape.LINEAR_GRADIENT, {}, {}, {}, (optional) matrix) -- not supported yet
 
setFillStyle(Shape.LINEAR_GRADIENT, {}, {}, {}, (optional) matrix) -- not supported yet
 
setFillStyle(Shape.RADIAL_GRADIENT, {}, {}, {}, (optional) matrix) -- not supported yet
 
setFillStyle(Shape.RADIAL_GRADIENT, {}, {}, {}, (optional) matrix) -- not supported yet
-->
+
]]
 
+
</syntaxhighlight>
</source>
 
<br/>
 
  
 
{{Shape}}
 
{{Shape}}

Latest revision as of 15:31, 13 July 2023

Available since: Gideros 2011.6
Class: Shape

Description

Sets the fill style that Shape object uses for subsequent drawings. The fill style remains in effect until you call setFillStyle() function with different parameters.

Shape:setFillStyle(fillstyle,...)

fillstyle parameter can be one of the following values:

  • Shape.NONE: clears the fill style
  • Shape.SOLID: sets the fill style as a solid color. In this mode, the parameters are color (in hexadecimal value) and an optional alpha value
  • Shape.TEXTURE: sets the fill style as textured. In this mode, the parameters are texture and an optional transformation matrix

Parameters

fillstyle: (string) the fill style type
...: (any) parameters of the fill style

Examples

setFillStyle(Shape.NONE) -- clears the fill style
setFillStyle(Shape.SOLID, 0xff0000) -- sets the fill style as solid red color
setFillStyle(Shape.SOLID, 0xff0000, 0.5) -- sets the fill style as solid red color with 0.5 transparency

local texture = Texture.new("image.png")
setFillStyle(Shape.TEXTURE, texture) -- sets the fill style as texture with "image.png"

local matrix = Matrix.new(0.5, 0, 0, 0.5, 0, 0)
setFillStyle(Shape.TEXTURE, texture, matrix) -- sets the fill style as texture with "image.png" with a transformation matrix

--[[
setFillStyle(Shape.LINEAR_GRADIENT, {}, {}, {}, (optional) matrix) -- not supported yet
setFillStyle(Shape.RADIAL_GRADIENT, {}, {}, {}, (optional) matrix) -- not supported yet
]]