phetsims / kite

A library for creating, manipulating and displaying 2D shapes in JavaScript.
http://scenerystack.org/
MIT License
15 stars 6 forks source link

problem with smoothQuadraticCurveTo() #38

Closed veillette closed 10 years ago

veillette commented 10 years ago

smoothQuadraticCurveTo() is currently equivalent to lineTo().

    var shape = new Shape().moveTo(100,100).smoothQuadraticCurveTo( 100,200).smoothQuadraticCurveTo( 200,200 ).smoothQuadraticCurveTo( 200,400 );
    this.addChild( new Path(shape,{stroke: 'black'}));

bug_report

The problems lies in the control point that is invoked in getSmoothQuadraticControlPoint().

When you used lineTo, you get a line from an initial point to a destination point. For an array of points, an automatic control point can be picked from the point just before the initial point or point that comes after the destination point. In the current implementation the control point is the same as the initial point. As a result these three points (initial, destination and control) are collinear and smoothQuadraticCurveTo results in a straight line.

samreid commented 10 years ago

@bereaphysics thanks for this issue report. @jonathanolson I also saw a problem like this when trying to use smoothQuadraticCurveTo a while ago, can you take a look?

jonathanolson commented 10 years ago

Thanks for finding this!

Looks like since the first quadratic is linear, it gets simplified internally to a line, and the getSmoothQuadraticControlPoint() will just return the last point (instead of the reflection).

Should have it fixed shortly.

jonathanolson commented 10 years ago

For reference, here is the desired behavior:

screen shot 2014-09-23 at 11 42 42 pm