graphics.curveTo draw extra line

base on 8.9.6 ,use the graphics.curveTo
eg:

var spr:Sprite = new Sprite();
spr.x=100;
spr.y=100;
spr.graphics.lineStyle(1,0,1);
spr.graphics.moveTo(0,0);
spr.graphics.curveTo(100, -100, 200, 0);
spr.graphics.moveTo(0,0);
spr.graphics.curveTo(100, 100, 200, 0);
this.addChild(spr);
image

I’m not sure what your issue is - I’d say it’s the expected behaviour since you’re just drawing two curves.
To have that particular third line you would need to draw an additional line to the origin after the two curves have been drawn e.g.

spr.graphics.lineStyle(1, 0, 1);
spr.graphics.moveTo(0, 0);
spr.graphics.curveTo(100, -100, 200, 0);
spr.graphics.moveTo(0, 0);
spr.graphics.curveTo(100, 100, 200, 0);
spr.graphics.lineTo(0, 0);

When I want to draw a coil, Like this use the AS3 .
image
But I always have a horizontal line in the middle.Use openfl 8.9.6
image
Typescript code eg:
var spr:Sprite = new Sprite();
spr.x=100;
spr.y=100;
spr.graphics.lineStyle(1,0,1);
spr.graphics.moveTo(0,0);
spr.graphics.curveTo(100, -100, 200, 0);
spr.graphics.moveTo(0,0);
spr.graphics.curveTo(100, 100, 200, 0);
this.addChild(spr);

I had a similar issue, where the “moveTo” command behaved differently between Flash & OpenFL.
Here is a workaround for your case :

var spr:Sprite = new Sprite();
spr.x=100;
spr.y=100;
spr.graphics.lineStyle(1,0,1);
spr.graphics.moveTo(0,0);
spr.graphics.curveTo(100, -100, 200, 0);
spr.graphics.curveTo(100, 100, 0, 0);
this.addChild(spr);

Does this help?

Yes,It’s work!,thank you!

1 Like