Difference between revisions of "Shape:setFillStyle"
From GiderosMobile
m (some typos plus formatting) |
|||
Line 2: | Line 2: | ||
<languages /> | <languages /> | ||
'''<translate>Available since</translate>:''' Gideros 2011.6<br/> | '''<translate>Available since</translate>:''' Gideros 2011.6<br/> | ||
− | '''<translate>Class</translate>:''' [[Special:MyLanguage/Shape|Shape]] | + | '''<translate>Class</translate>:''' [[Special:MyLanguage/Shape|Shape]]<br/> |
− | <br/> | ||
=== <translate>Description</translate> === | === <translate>Description</translate> === | ||
− | |||
− | |||
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. | 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. | ||
− | |||
− | |||
− | See | + | See examples below for more detailed usage of this function. |
− | |||
<source lang="lua"> | <source lang="lua"> | ||
Shape:setFillStyle(type,...) | Shape:setFillStyle(type,...) | ||
</source> | </source> | ||
− | + | [[Special:MyLanguage/type|type]] parameter can be one of the following values: | |
− | + | * '''Shape.NONE''': clears the fill style | |
− | [[Special:MyLanguage/type|type]] parameter can be one of the following values: | + | * '''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 | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=== <translate>Parameters</translate> === | === <translate>Parameters</translate> === | ||
− | + | '''type''': (string) <translate>the type of the fill. Can be one of the Shape.NONE, Shape.SOLID or Shape.TEXTURE</translate><br/> | |
− | + | '''...''': (any) <translate>parameters of the fill style</translate><br/> | |
− | '''type''': (string) <translate> | ||
− | '''...''': (any) <translate> | ||
− | |||
− | <br/> | ||
=== <translate>Examples</translate> === | === <translate>Examples</translate> === | ||
− | |||
− | |||
− | |||
− | |||
<source lang="lua"> | <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 58: | Line 36: | ||
setFillStyle(Shape.RADIAL_GRADIENT, {}, {}, {}, (optional) matrix) -- not supported yet | setFillStyle(Shape.RADIAL_GRADIENT, {}, {}, {}, (optional) matrix) -- not supported yet | ||
--> | --> | ||
− | |||
</source> | </source> | ||
− | |||
{{Shape}} | {{Shape}} |
Revision as of 22:45, 10 April 2020
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.
See examples below for more detailed usage of this function.
Shape:setFillStyle(type,...)
type 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
type: (string) the type of the fill. Can be one of the Shape.NONE, Shape.SOLID or Shape.TEXTURE
...: (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
-->