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

Method drawGhosts

graph.js:282–324  ·  view source on GitHub ↗
( ghosts )

Source from the content-addressed store, hash-verified

280 }
281
282 drawGhosts( ghosts ){
283 this.context.strokeStyle = "#333";
284 this.context.setLineDash([5, 10]);
285
286 this.context.beginPath();
287
288 let pt, ptA, ptB, radius;
289
290 for( const [key, nodes] of Object.entries( ghosts )){
291 try{
292 nodes.forEach( node => {
293 pt = this.convertPathToScreen( node.x, node.y );
294 switch( node.tool ){
295 case 'moveTo':
296 this.context.moveTo( pt.x, pt.y );
297 break;
298 case 'lineTo':
299 this.context.lineTo( pt.x, pt.y );
300 break;
301 case 'quadraticCurveTo':
302 ptA = this.convertPathToScreen( node.options.ctrlA.x, node.options.ctrlA.y );
303 this.context.quadraticCurveTo( ptA.x, ptA.y, pt.x, pt.y );
304 break;
305 case 'bezierCurveTo':
306 ptA = this.convertPathToScreen( node.options.ctrlA.x, node.options.ctrlA.y );
307 ptB = this.convertPathToScreen( node.options.ctrlB.x, node.options.ctrlB.y );
308 this.context.bezierCurveTo( ptA.x, ptA.y, ptB.x, ptB.y, pt.x, pt.y );
309 break;
310 case 'arc':
311 radius = this.scalePathValueToScreen( node.options.radius );
312 this.context.arc( pt.x, pt.y, radius, node.options.start, node.options.end, node.options.clockwise );
313 break;
314 }
315 });
316 }catch(e){
317 console.warn( e.message );
318 }
319 }
320
321 this.context.stroke();
322
323 this.context.setLineDash([]);
324 }
325
326 isValueCtrlActive( type ){
327 if (this.activeCtrl == null ) return false;

Callers 1

renderMethod · 0.95

Calls 2

convertPathToScreenMethod · 0.95

Tested by

no test coverage detected