Skip to content

Commit

Permalink
curve drawing algorithm for quadratic curves is replaced by Bezier se…
Browse files Browse the repository at this point in the history
…gment. It should improve performance on iPad (see #103)
  • Loading branch information
veillette committed Mar 18, 2017
1 parent d2a33cc commit 5278d7e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions js/curve-fitting/view/GraphAreaNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ define( function( require ) {
if ( order === 1 ) {
curveShape.lineTo( xMax, curve.getYValueAt( xMax ) );
}
else if ( order === 2 ) {
// use bezier curve : must determine the control points
// note that the curve will not go through the control point.
var cpx = (xMin + xMax) / 2;
var cpy = (b * xMin + c / 2) * (xMax - xMin) + curve.getYValueAt( xMin );
curveShape.quadraticCurveTo( cpx, cpy, xMax, curve.getYValueAt( xMax ) );
}
else {
for ( x = xMin; x < xMax; x += PLOT_STEP ) {
curveShape.lineTo( x, curve.getYValueAt( x ) );
Expand Down

0 comments on commit 5278d7e

Please sign in to comment.