Article Tutorials/Drawing Shapes (filled polygons): Difference between revisions

From GiderosMobile
m Text replacement - "</source" to "</syntaxhighlight"
No edit summary
 
(One intermediate revision by the same user not shown)
Line 31: Line 31:


== Style ==
== Style ==
There are a few options for setFillStyle:<br/>
There are a few options for setFillStyle:
''Shape.NONE = No fill''<br/>
*''Shape.NONE = No fill''
''Shape.SOLID = Solid color fill''<br/>
*''Shape.SOLID = Solid color fill''
''Shape.TEXTURE = Fill your shape with the content of a PNG''<br>
*''Shape.TEXTURE = Fill your shape with the content of a PNG''


This will set the shape as solid with a blue color filling and a transparency of 0.25:
This will set the shape as solid with a blue color filling and a transparency of 0.25:
Line 41: Line 41:
</syntaxhighlight>
</syntaxhighlight>


There are also a few options for setLineStyle:<br/>
There are also a few options for setLineStyle:
''width''<br>
*''width''
''color''<br>
*''color''
''alpha''<br>
*''alpha''




'''Note:''' This tutorial was written by [http://bluebilby.com/author/waulokadmin/ Jason Oakley] and was originally available here: http://bluebilby.com/2013/04/10/gideros-mobile-tutorial-displaying-graphics/.
'''Note: This tutorial was written by [http://bluebilby.com/author/waulokadmin/ Jason Oakley] and was originally available here: http://bluebilby.com/2013/04/10/gideros-mobile-tutorial-displaying-graphics/'''
 
 
'''[[Written Tutorials]]'''
{{GIDEROS IMPORTANT LINKS}}

Latest revision as of 09:29, 26 August 2024

Displaying Images

Gideros Studio has a simple way of creating graphics in the way of Shapes.

To create a shape, you draw it using line commands. Once created, the shape can be rotated, scaled, ...

local myShape = Shape.new()
myShape:setLineStyle(2)
myShape:setFillStyle(Shape.SOLID, 0x9900ff)
myShape:beginPath()
myShape:moveTo(1,1)
myShape:lineTo(100,1)
myShape:lineTo(100,100)
myShape:lineTo(1,100)
myShape:lineTo(1,1)
myShape:endPath()
stage:addChild(myShape)

This will draw a purple rectangle:


Manipulating your shape

myShape:setPosition(75,0)
myShape:setRotation(45)
myShape:setAlpha(0.5)

Style

There are a few options for setFillStyle:

  • Shape.NONE = No fill
  • Shape.SOLID = Solid color fill
  • Shape.TEXTURE = Fill your shape with the content of a PNG

This will set the shape as solid with a blue color filling and a transparency of 0.25:

setFillStyle(Shape.SOLID, 0x0000ff, 0.25)

There are also a few options for setLineStyle:

  • width
  • color
  • alpha


Note: This tutorial was written by Jason Oakley and was originally available here: http://bluebilby.com/2013/04/10/gideros-mobile-tutorial-displaying-graphics/


Written Tutorials