MCPcopy Index your code
hub / github.com/NikLever/ThreeJS-PathEditor / drawNode

Method drawNode

graph.js:188–280  ·  view source on GitHub ↗
( node, activeNode, activeCtrl )

Source from the content-addressed store, hash-verified

186 }
187
188 drawNode( node, activeNode, activeCtrl ){
189 const pt = this.convertPathToScreen( node.x, node.y );
190 let ptA, ptB;
191 let active = ( activeNode == node );
192 switch( node.tool ){
193 case 'moveTo':
194 this.drawCircle( pt.x, pt.y, 8, "#88f", active );
195 break;
196 case 'lineTo':
197 this.context.strokeStyle = (node == activeNode) ? "#000" : "#777";
198 this.context.lineWidth = 1;
199 this.context.beginPath();
200 this.context.moveTo( this.prevPt.x, this.prevPt.y );
201 this.context.lineTo( pt.x, pt.y );
202 this.context.stroke();
203 this.drawCircle( pt.x, pt.y, 8, "#88f", active );
204 break;
205 case 'quadraticCurveTo':
206 try{
207 this.context.fillStyle = "#88f";
208 this.context.strokeStyle = (node == this.activeNode || node.options.ctrlA == this.activeCtrl ) ? "#000" : "#777";
209 this.context.lineWidth = 1;
210 ptA = this.convertPathToScreen( node.options.ctrlA.x, node.options.ctrlA.y );
211 this.context.beginPath();
212 this.context.moveTo( this.prevPt.x, this.prevPt.y );
213 this.context.quadraticCurveTo( ptA.x, ptA.y, pt.x, pt.y );
214 this.context.stroke();
215 this.context.setLineDash([5, 5]);
216 this.context.beginPath();
217 this.context.moveTo( this.prevPt.x, this.prevPt.y );
218 this.context.lineTo( ptA.x, ptA.y );
219 this.context.lineTo( pt.x, pt.y );
220 this.context.stroke();
221 this.context.setLineDash([]);
222 this.drawCircle( ptA.x, ptA.y, 8, "#8f8", activeCtrl == node.options.ctrlA );
223 }catch( e ){
224
225 }
226 this.drawCircle( pt.x, pt.y, 8, "#88f", active );
227 break;
228 case 'bezierCurveTo':
229 try{
230 this.context.fillStyle = "#88f";
231 this.context.strokeStyle = (node == activeNode || node.options.ctrlA == activeCtrl || node.options.ctrlB == activeCtrl ) ? "#000" : "#777";
232 this.context.lineWidth = 1;
233 ptA = this.convertPathToScreen( node.options.ctrlA.x, node.options.ctrlA.y );
234 ptB = this.convertPathToScreen( node.options.ctrlB.x, node.options.ctrlB.y );
235 this.context.beginPath();
236 this.context.moveTo( this.prevPt.x, this.prevPt.y );
237 this.context.bezierCurveTo( ptA.x, ptA.y, ptB.x, ptB.y, pt.x, pt.y );
238 this.context.stroke();
239 this.context.setLineDash([5, 5]);
240 this.context.beginPath();
241 this.context.moveTo( this.prevPt.x, this.prevPt.y );
242 this.context.lineTo( ptB.x, ptB.y );
243 this.context.lineTo( ptA.x, ptA.y );
244 this.context.lineTo( pt.x, pt.y );
245 this.context.stroke();

Callers 1

renderMethod · 0.95

Calls 6

convertPathToScreenMethod · 0.95
drawCircleMethod · 0.95
isValueCtrlActiveMethod · 0.95
drawArrowMethod · 0.95
calcPointOnCircleMethod · 0.80

Tested by

no test coverage detected