User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
design_guide_path [2018/05/12 08:15]
z3dev
design_guide_path [2018/06/12 14:13] (current)
z3dev
Line 1: Line 1:
 ==== Path ==== ==== Path ====
  
-A path is a series of points, connected by very thin (invisible) ​lines. Paths can be created by giving an array of points, or by calling various functions to create or extend another path.+A path is a series of points, connected by very thin (invisible) ​line segments. Paths can be created by giving an array of points, or by calling various functions to create or extend another path.
  
-In addition, a path can be open or closed. ​open path is typically used to create another, by appending additional points. A closed path is final, and has a line between first and last points.+<code javascript>​ 
 +let path = new CSG.Path2D([[10,​ 10], [-10, 10]], false); 
 +let anotherpath = new CSG.Path2D([[-10,​ -10]]) 
 +path = path.concat(anotherpath) 
 +path = path.appendPoint([10,​-10]) 
 +path = path.close() 
 +</​code>​ 
 + 
 +In addition, a path can be open or closed. ​An open path is typically used to create another, by appending additional points. A closed path is final, and has a line between first and last points. 
 + 
 +Curved paths can also be created. Paths can be created as an arc, or arcs can be appended to an existing path. 
 + 
 +<code javascript>​ 
 +let p1 = new CSG.Path2D([[27,​-22],​[27,​-3]],​false);​ 
 +p1 = p1.appendArc([12,​-22],​{xradius:​ 15,yradius: -20,​xaxisrotation:​ 0,​clockwise:​ false,​large:​ false}); 
 +p1 = p1.close();​ 
 +</​code>​
  
 Which include: Which include:
Line 22: Line 38:
 === Conversion to 2D Shape === === Conversion to 2D Shape ===
  
-Paths can be converted to two dimensional shapes. First, a Path can be converted directly to a two dimensional shape but the Path must be **closed**.+Paths can be converted to two dimensional shapes ​in various forms. 
 + 
 +First, a Path can be converted directly to a two dimensional shape but the Path must be **closed**.
  
 <code javascript>​ <code javascript>​
-let path = new CSG.Path2D([[10,​10],​ [-10,10], [-10,-10]], true) // create a closed path+// create a closed path in shape of triangle 
 +let path = new CSG.Path2D([[10,​10],​ [-10,10], [-10,-10]], true)
 let shape = path.innerToCAG() let shape = path.innerToCAG()
 </​code>​ </​code>​
Line 32: Line 51:
  
 <code javascript>​ <code javascript>​
-let path = new CSG.Path2D([[10,​10],​ [-10,10], [-10,​-10]], ​true// create a closed path+// create an open path in shape of L 
 +let path = new CSG.Path2D([[10,​10],​ [-10,10], [-10,​-10]], ​false)
 let shape = path.expandToCAG(3) let shape = path.expandToCAG(3)
 </​code>​ </​code>​