diff --git a/src/core/p5.Renderer2D.js b/src/core/p5.Renderer2D.js index 9b9d4633e6..090b42613d 100644 --- a/src/core/p5.Renderer2D.js +++ b/src/core/p5.Renderer2D.js @@ -645,7 +645,7 @@ p5.Renderer2D.prototype.triangle = function(x1, y1, x2, y2, x3, y3) { p5.Renderer2D.prototype.endShape = function (mode, vertices, isCurve, isBezier, - isQuadratic, isContour, shapeKind) { + isQuadratic, isContour, shapeKind, ar) { if (vertices.length === 0) { return this; } @@ -657,13 +657,13 @@ function (mode, vertices, isCurve, isBezier, if (closeShape && !isContour) { vertices.push(vertices[0]); } - var i, j; + var i, j, k; var numVerts = vertices.length; + var numar=ar.length; if (isCurve && (shapeKind === constants.POLYGON || shapeKind === null)) { - if (numVerts > 3) { - var b = [], s = 1 - this._curveTightness; + var b = [], s = 1 - this._curveTightness; + if (numVerts > 3 && (numVerts===numar)) { this.drawingContext.beginPath(); - this.drawingContext.moveTo(vertices[1][0], vertices[1][1]); for (i = 1; i + 2 < numVerts; i++) { v = vertices[i]; b[0] = [ @@ -691,6 +691,68 @@ function (mode, vertices, isCurve, isBezier, } this._doFillStrokeClose(); } + else if(numVerts > 3 && (numVerts!==numar)){// issue #906 + //var b = [], s = 1 - this._curveTightness; + j=0; + for(k=0;k+1 * */ + +/* +p5.prototype.curveVertex = function(x,y) {// issue 906 + isCurve = true; + this.vertex(x, y); + return this; +}; +*/ + + p5.prototype.curveVertex = function(x,y) { isCurve = true; + curveVertices[curveVerticesIndex]=VerticesIndex; + curveVerticesIndex=curveVerticesIndex+1; this.vertex(x, y); return this; }; + /** * Use the beginContour() and endContour() functions to create negative * shapes within shapes such as the center of the letter 'O'. beginContour() @@ -440,7 +456,7 @@ p5.prototype.endShape = function(mode) { } this._renderer.endShape(mode, vertices, isCurve, isBezier, - isQuadratic, isContour, shapeKind); + isQuadratic, isContour, shapeKind, curveVertices); // Reset some settings isCurve = false; @@ -553,6 +569,7 @@ p5.prototype.quadraticVertex = function(cx, cy, x3, y3) { * */ p5.prototype.vertex = function(x, y, moveTo) { + VerticesIndex=VerticesIndex+1; var args = new Array(arguments.length); for (var i = 0; i < args.length; ++i) { args[i] = arguments[i];