Difference between revisions of "Path2D"
From GiderosMobile
m (Text replacement - "</source>" to "</syntaxhighlight>") |
|||
(12 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
− | '''Supported platforms:''' <br/> | + | <!-- GIDEROSOBJ:Path2D --> |
+ | '''Supported platforms:''' [[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/> | ||
'''Available since:''' Gideros 2016.04<br/> | '''Available since:''' Gideros 2016.04<br/> | ||
− | === | + | '''Inherits from:''' [[Sprite]]<br/> |
− | + | ||
− | === | + | === Description === |
− | '''Drawing Moon''' | + | Draws quick 2D vector paths. This class aims at being a faster alternative to Shape for complex/curvy shapes. |
− | < | + | |
+ | === Examples === | ||
+ | '''Drawing a Moon''' | ||
+ | <syntaxhighlight 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 20: | ||
p:setLineColor(0xC0C0C0) --Line color | p:setLineColor(0xC0C0C0) --Line color | ||
p:setAnchorPosition(100,100) | p:setAnchorPosition(100,100) | ||
− | stage:addChild(p)</ | + | p:setPosition(160,240) |
− | '''Drawing banana''' | + | stage:addChild(p) |
− | < | + | </syntaxhighlight> |
+ | |||
+ | '''Drawing a banana''' | ||
+ | <syntaxhighlight 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 34: | ||
p:setLineColor(0x404000) --Line color | p:setLineColor(0x404000) --Line color | ||
p:setAnchorPosition(100,100) | p:setAnchorPosition(100,100) | ||
− | stage:addChild(p)</ | + | p:setPosition(160,240) |
+ | stage:addChild(p) | ||
+ | </syntaxhighlight> | ||
+ | |||
{|- | {|- | ||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
− | === | + | === Methods === |
− | [[ | + | [[Path2D.new]] ''creates Path2D object''<br/><!--GIDEROSMTD:Path2D.new() creates Path2D object--> |
− | [[ | + | [[Path2D:getPathPoints]] ''computes location of points along the path''<br/><!--GIDEROSMTD:Path2D:getPathPoints(interval,offset,maxpts,flatness,subdiv_limit) computes location of points along the path--> |
− | [[ | + | [[Path2D:setConvex]] ''flags the shape as convex''<br/><!--GIDEROSMTD:Path2D:setConvex(convex) flags the shape as convex--> |
− | [[ | + | [[Path2D:setFillColor]] ''sets fill color''<br/><!--GIDEROSMTD:Path2D:setFillColor(color,alpha) sets fill color--> |
− | [[ | + | [[Path2D:setFontPath]] ''sets the path from the outline of a TTFont character''<br/><!--GIDEROSMTD:Path2D:setFontPath(font,character) sets the path from the outline of a TTFont character--> |
− | [[ | + | [[Path2D:setLineColor]] ''sets line color''<br/><!--GIDEROSMTD:Path2D:setLineColor(color,alpha) sets line color--> |
− | [[ | + | [[Path2D:setLineThickness]] ''sets the thickness of the outline''<br/><!--GIDEROSMTD:Path2D:setLineThickness(thickness,feather) sets the thickness of the outline--> |
− | [[ | + | [[Path2D:setPath]] ''sets path to draw''<br/><!--GIDEROSMTD:Path2D:setPath(commands,coordinates,more coordinates) sets path to draw--> |
− | [[ | + | [[Path2D:setSvgPath]] ''sets path with svg properties''<br/><!--GIDEROSMTD:Path2D:setSvgPath(svg_params) sets path with svg properties--> |
+ | [[Path2D:setTexture]] ''sets texture for fill''<br/><!--GIDEROSMTD:Path2D:setTexture(texture,matrix) sets texture for fill--> | ||
+ | |||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
− | === | + | === Events === |
− | === | + | === Constants === |
|} | |} | ||
+ | |||
+ | {{GIDEROS IMPORTANT LINKS}} |
Latest revision as of 14:32, 13 July 2023
Supported platforms:
Available since: Gideros 2016.04
Inherits from: Sprite
Description
Draws 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)
MethodsPath2D.new creates Path2D object |
EventsConstants |