From fd745dc6995b98c45b99f13db127f9227104e885 Mon Sep 17 00:00:00 2001 From: arihant parsoya Date: Tue, 29 Dec 2015 21:27:02 +0530 Subject: [PATCH 1/3] #906 --- src/core/p5.Renderer2D.js | 72 ++++++++++++++++++++++++++++++++++++--- src/core/vertex.js | 19 ++++++++++- 2 files changed, 85 insertions(+), 6 deletions(-) diff --git a/src/core/p5.Renderer2D.js b/src/core/p5.Renderer2D.js index 9b9d4633e6..4b6f4b5b88 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) { 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 @@ -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]; From e7b59c4d76b12e9e14bafc2465ce82de0c4df496 Mon Sep 17 00:00:00 2001 From: arihant parsoya Date: Tue, 29 Dec 2015 21:33:31 +0530 Subject: [PATCH 2/3] # 906 --- src/core/vertex.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/vertex.js b/src/core/vertex.js index 4e59dbc764..e522e414f5 100644 --- a/src/core/vertex.js +++ b/src/core/vertex.js @@ -344,7 +344,7 @@ p5.prototype.bezierVertex = function(x2, y2, x3, y3, x4, y4) { */ /* -p5.prototype.curveVertex = function(x,y) { +p5.prototype.curveVertex = function(x,y) {// issue 906 isCurve = true; this.vertex(x, y); return this; From baea77220c0c2e91ff35a8f2b91ea54d39a688ef Mon Sep 17 00:00:00 2001 From: arihant parsoya Date: Tue, 29 Dec 2015 21:46:51 +0530 Subject: [PATCH 3/3] #906 --- src/core/p5.Renderer2D.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/p5.Renderer2D.js b/src/core/p5.Renderer2D.js index 4b6f4b5b88..090b42613d 100644 --- a/src/core/p5.Renderer2D.js +++ b/src/core/p5.Renderer2D.js @@ -714,7 +714,7 @@ function (mode, vertices, isCurve, isBezier, b[2] = [ vertices[i + 1][0] + (s * vertices[i][0]-s * vertices[i + 2][0]) / 6, - vertices[i + 1][1]+(s * vertices[i][1] - s*vertices[i + 2][1]) / 6 + vertices[i + 1][1]+(s * vertices[i][1] - s*vertices[i + 2][1]) / 6 ]; b[3] = [ vertices[i + 1][0],