Difference between revisions of "Path2D"

 
(15 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
'''Supported platforms:''' <br/>
+
<languages />
'''Available since:''' Gideros 2016.04<br/>
+
<!-- GIDEROSOBJ:Path2D -->
=== Description ===
+
'''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/>
<translate>Draw quick 2D vector paths. This class aims at being a faster alternative to Shape for complex/curvy shapes.</translate>
+
'''<translate>Available since</translate>:''' Gideros 2016.04<br/>
=== Examples ===
+
'''<translate>Inherits from</translate>:''' [[Special:MyLanguage/Sprite|Sprite]]<br/>
'''Drawing Moon'''<br/>
+
 
<source lang="lua">--Moon
+
=== <translate>Description</translate> ===
 +
Draw quick 2D vector paths. This class aims at being a faster alternative to Shape for complex/curvy shapes.
 +
 
 +
=== <translate>Examples</translate> ===
 +
'''Drawing a Moon'''
 +
<source lang="lua">
 +
--Moon
 
local p=Path2D.new()
 
local p=Path2D.new()
 
local ms="MQQZ" --MoveTo, QuadTo, QuadTo, Close
 
local ms="MQQZ" --MoveTo, QuadTo, QuadTo, Close
Line 15: Line 21:
 
p:setLineColor(0xC0C0C0) --Line color
 
p:setLineColor(0xC0C0C0) --Line color
 
p:setAnchorPosition(100,100)
 
p:setAnchorPosition(100,100)
stage:addChild(p)</source>
+
p:setPosition(160,240)
'''Drawing banana'''<br/>
+
stage:addChild(p)
<source lang="lua">--Banana shape, SVG path format
+
</source>
 +
 
 +
'''Drawing a banana'''
 +
<source lang="lua">
 +
--Banana shape, SVG path format
 
local banana="M8.64,223.948c0,0,143.468,3.431,185.777-181.808c2.673-11.702-1.23-20.154,1.316-33.146h16.287c0,0-3.14,17.248,1.095,30.848c21.392,68.692-4.179,242.343-204.227,196.59L8.64,223.948z"
 
local banana="M8.64,223.948c0,0,143.468,3.431,185.777-181.808c2.673-11.702-1.23-20.154,1.316-33.146h16.287c0,0-3.14,17.248,1.095,30.848c21.392,68.692-4.179,242.343-204.227,196.59L8.64,223.948z"
 
p=Path2D.new()
 
p=Path2D.new()
Line 25: Line 35:
 
p:setLineColor(0x404000) --Line color
 
p:setLineColor(0x404000) --Line color
 
p:setAnchorPosition(100,100)
 
p:setAnchorPosition(100,100)
stage:addChild(p)</source>
+
p:setPosition(160,240)
 +
stage:addChild(p)
 +
</source>
 +
 
 
{|-
 
{|-
| style="width: 50%;"|
+
| style="width: 50%; vertical-align:top;"|
=== Methods ===
+
=== <translate>Methods</translate> ===
[[Path2D.new]] - Creates Path2D object<br/>
+
[[Special:MyLanguage/Path2D.new|Path2D.new]] ''<translate>Creates Path2D object</translate>''<br/><!-- GIDEROSMTD:Path2D.new() Creates Path2D object -->
[[Path2D:setConvex]] - Flag the shape as convex.<br/>
+
[[Special:MyLanguage/Path2D:getPathPoints|Path2D:getPathPoints]] ''<translate>Compute location of points along the path.</translate>''<br/><!-- GIDEROSMTD:Path2D:getPathPoints(interval,offset,maxpts,flatness,subdiv_limit) Compute location of points along the path. -->
[[Path2D:setFillColor]] - Sets fill color<br/>
+
[[Special:MyLanguage/Path2D:setConvex|Path2D:setConvex]] ''<translate>Flag the shape as convex.</translate>''<br/><!-- GIDEROSMTD:Path2D:setConvex(convex) Flag the shape as convex. -->
[[Path2D:setFontPath]] - Sets the path from the outline of a TTFont character<br/>
+
[[Special:MyLanguage/Path2D:setFillColor|Path2D:setFillColor]] ''<translate>Sets fill color</translate>''<br/><!-- GIDEROSMTD:Path2D:setFillColor(color,alpha) Sets fill color -->
[[Path2D:setLineColor]] - Sets line color<br/>
+
[[Special:MyLanguage/Path2D:setFontPath|Path2D:setFontPath]] ''<translate>Sets the path from the outline of a TTFont character</translate>''<br/><!-- GIDEROSMTD:Path2D:setFontPath(font,character) Sets the path from the outline of a TTFont character -->
[[Path2D:setLineThickness]] - Set the thickness of the outline<br/>
+
[[Special:MyLanguage/Path2D:setLineColor|Path2D:setLineColor]] ''<translate>Sets line color</translate>''<br/><!-- GIDEROSMTD:Path2D:setLineColor(color,alpha) Sets line color -->
[[Path2D:setPath]] - set path to draw<br/>
+
[[Special:MyLanguage/Path2D:setLineThickness|Path2D:setLineThickness]] ''<translate>Set the thickness of the outline</translate>''<br/><!-- GIDEROSMTD:Path2D:setLineThickness(thickness,feather) Set the thickness of the outline -->
[[Path2D:setSvgPath]] - set path with svg properties<br/>
+
[[Special:MyLanguage/Path2D:setPath|Path2D:setPath]] ''<translate>set path to draw</translate>''<br/><!-- GIDEROSMTD:Path2D:setPath(commands,coordinates,more coordinates) set path to draw -->
[[Path2D:setTexture]] - sets texture for fill<br/>
+
[[Special:MyLanguage/Path2D:setSvgPath|Path2D:setSvgPath]] ''<translate>set path with svg properties</translate>''<br/><!-- GIDEROSMTD:Path2D:setSvgPath(svg_params) set path with svg properties -->
| style="width: 50%;"|
+
[[Special:MyLanguage/Path2D:setTexture|Path2D:setTexture]] ''<translate>sets texture for fill</translate>''<br/><!-- GIDEROSMTD:Path2D:setTexture(texture,matrix) sets texture for fill -->
=== Events ===
+
 
=== Constants ===
+
| style="width: 50%; vertical-align:top;"|
 +
=== <translate>Events</translate> ===
 +
=== <translate>Constants</translate> ===
 
|}
 
|}
 +
 +
{{GIDEROS IMPORTANT LINKS}}

Latest revision as of 14:59, 30 January 2020


Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.pngPlatform html5.pngPlatform winrt.pngPlatform win32.png
Available since: Gideros 2016.04
Inherits from: Sprite

Description

Draw quick 2D vector paths. This class aims at being a faster alternative to Shape for complex/curvy shapes.

Examples

Drawing a Moon

--Moon
local p=Path2D.new()
local ms="MQQZ" --MoveTo, QuadTo, QuadTo, Close
local mp={100,0, -50,100, 100,200, 20,100, 100,0 }
p:setPath(ms,mp) --Set the path from a set of commands and coordinates
p:setLineThickness(3) -- Outline width
p:setFillColor(0xE0E0E0,0.7) --Fill color
p:setLineColor(0xC0C0C0) --Line color
p:setAnchorPosition(100,100)
p:setPosition(160,240)
stage:addChild(p)

Drawing a banana

--Banana shape, SVG path format
local banana="M8.64,223.948c0,0,143.468,3.431,185.777-181.808c2.673-11.702-1.23-20.154,1.316-33.146h16.287c0,0-3.14,17.248,1.095,30.848c21.392,68.692-4.179,242.343-204.227,196.59L8.64,223.948z"
p=Path2D.new()
p:setSvgPath(banana) --Set the path from a SVG path description
p:setLineThickness(5) -- Outline width
p:setFillColor(0xFFFF80,0.7) --Fill color
p:setLineColor(0x404000) --Line color
p:setAnchorPosition(100,100)
p:setPosition(160,240)
stage:addChild(p)

Methods

Path2D.new Creates Path2D object
Path2D:getPathPoints Compute location of points along the path.
Path2D:setConvex Flag the shape as convex.
Path2D:setFillColor Sets fill color
Path2D:setFontPath Sets the path from the outline of a TTFont character
Path2D:setLineColor Sets line color
Path2D:setLineThickness Set the thickness of the outline
Path2D:setPath set path to draw
Path2D:setSvgPath set path with svg properties
Path2D:setTexture sets texture for fill

Events

Constants