MCPcopy Create free account
hub / github.com/NikLever/ThreeJS-PathEditor / nodesToShape

Method nodesToShape

preview.js:114–140  ·  view source on GitHub ↗
( nodes )

Source from the content-addressed store, hash-verified

112 }
113
114 nodesToShape( nodes ){
115 const shape = new Shape();
116
117 nodes.forEach( node => {
118 switch( node.tool ){
119 case 'moveTo':
120 shape.moveTo( node.x, -node.y );
121 break;
122 case 'lineTo':
123 shape.lineTo( node.x, -node.y );
124 break;
125 case 'quadraticCurveTo':
126 shape.quadraticCurveTo( node.options.ctrlA.x, -node.options.ctrlA.y, node.x, -node.y );
127 break;
128 case 'bezierCurveTo':
129 shape.bezierCurveTo( node.options.ctrlA.x, -node.options.ctrlA.y, node.options.ctrlB.x, -node.options.ctrlB.y, node.x, -node.y );
130 break;
131 case 'arc':
132 shape.absarc( node.x, -node.y, node.options.radius, -node.options.start, -node.options.end, !node.options.clockwise );
133 const pt = Geometry.calcPointOnCircle( node.x, node.y, node.options.radius, node.options.end );
134 shape.moveTo( pt.x, -pt.y );
135 break;
136 }
137 });
138
139 return shape;
140 }
141
142 nodesToPath( nodes ){
143 const path = new Path();

Callers 1

showMethod · 0.95

Calls 1

calcPointOnCircleMethod · 0.80

Tested by

no test coverage detected