diff --git a/src/core/p5.Graphics.js b/src/core/p5.Graphics.js index 7744369532..751ec51fde 100644 --- a/src/core/p5.Graphics.js +++ b/src/core/p5.Graphics.js @@ -573,9 +573,6 @@ class Graphics { this._styles = []; - this._bezierDetail = 20; - this._curveDetail = 20; - // this._colorMode = RGB; // this._colorMaxes = { // rgb: [255, 255, 255, 255], diff --git a/src/core/p5.Renderer.js b/src/core/p5.Renderer.js index 05300c76cd..89132d50c9 100644 --- a/src/core/p5.Renderer.js +++ b/src/core/p5.Renderer.js @@ -212,6 +212,24 @@ class Renderer { this.currentShape.vertex(position, textureCoordinates); } + bezier(x1, y1, x2, y2, x3, y3, x4, y4) { + this._pInst.beginShape(); + this._pInst.vertex(x1, y1); + this._pInst.bezierVertex(x2, y2, x3, y3, x4, y4); + this._pInst.endShape(); + return this; + } + + spline(x1, y1, x2, y2, x3, y3, x4, y4) { + this._pInst.beginShape(); + this._pInst.splineVertex(x1, y1); + this._pInst.splineVertex(x2, y2); + this._pInst.splineVertex(x3, y3); + this._pInst.splineVertex(x4, y4); + this._pInst.endShape(); + return this; + } + beginClip(options = {}) { if (this._clipping) { throw new Error("It looks like you're trying to clip while already in the middle of clipping. Did you forget to endClip()?"); diff --git a/src/core/p5.Renderer2D.js b/src/core/p5.Renderer2D.js index 5125e4000d..23f74bec4b 100644 --- a/src/core/p5.Renderer2D.js +++ b/src/core/p5.Renderer2D.js @@ -264,7 +264,7 @@ class Renderer2D extends Renderer { shape.accept(visitor); if (this._clipping) { this.clipPath.addPath(visitor.path); - this.clipPath.closePath(); + this.clipPath.closePath(); } else { if (this.states.fillColor) { this.drawingContext.fill(visitor.path); @@ -969,27 +969,6 @@ class Renderer2D extends Renderer { } } - ////////////////////////////////////////////// - // SHAPE | Curves - ////////////////////////////////////////////// - bezier(x1, y1, x2, y2, x3, y3, x4, y4) { - this._pInst.beginShape(); - this._pInst.vertex(x1, y1); - this._pInst.bezierVertex(x2, y2, x3, y3, x4, y4); - this._pInst.endShape(); - return this; - } - - curve(x1, y1, x2, y2, x3, y3, x4, y4) { - this._pInst.beginShape(); - this._pInst.splineVertex(x1, y1); - this._pInst.splineVertex(x2, y2); - this._pInst.splineVertex(x3, y3); - this._pInst.splineVertex(x4, y4); - this._pInst.endShape(); - return this; - } - ////////////////////////////////////////////// // TRANSFORM ////////////////////////////////////////////// diff --git a/src/shape/curves.js b/src/shape/curves.js index 370011152e..c702851f0d 100644 --- a/src/shape/curves.js +++ b/src/shape/curves.js @@ -214,109 +214,6 @@ function curves(p5, fn){ return this; }; - /** - * Sets the number of segments used to draw Bézier curves in WebGL mode. - * - * In WebGL mode, smooth shapes are drawn using many flat segments. Adding - * more flat segments makes shapes appear smoother. - * - * The parameter, `detail`, is the number of segments to use while drawing a - * Bézier curve. For example, calling `bezierDetail(5)` will use 5 segments to - * draw curves with the bezier() function. By - * default,`detail` is 20. - * - * Note: `bezierDetail()` has no effect in 2D mode. - * - * @method bezierDetail - * @param {Number} detail number of segments to use. Defaults to 20. - * @chainable - * - * @example - *
- * // Draw the original curve.
- *
- * function setup() {
- * createCanvas(100, 100);
- *
- * background(200);
- *
- * // Draw the anchor points in black.
- * stroke(0);
- * strokeWeight(5);
- * point(85, 20);
- * point(15, 80);
- *
- * // Draw the control points in red.
- * stroke(255, 0, 0);
- * point(10, 10);
- * point(90, 90);
- *
- * // Draw a black bezier curve.
- * noFill();
- * stroke(0);
- * strokeWeight(1);
- * bezier(85, 20, 10, 10, 90, 90, 15, 80);
- *
- * // Draw red lines from the anchor points to the control points.
- * stroke(255, 0, 0);
- * line(85, 20, 10, 10);
- * line(15, 80, 90, 90);
- *
- * describe(
- * 'A gray square with three curves. A black s-curve has two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.'
- * );
- * }
- *
- *
- * // Draw the curve with less detail.
- *
- * function setup() {
- * createCanvas(100, 100, WEBGL);
- *
- * background(200);
- *
- * // Set the curveDetail() to 5.
- * bezierDetail(5);
- *
- * // Draw the anchor points in black.
- * stroke(0);
- * strokeWeight(5);
- * point(35, -30, 0);
- * point(-35, 30, 0);
- *
- * // Draw the control points in red.
- * stroke(255, 0, 0);
- * point(-40, -40, 0);
- * point(40, 40, 0);
- *
- * // Draw a black bezier curve.
- * noFill();
- * stroke(0);
- * strokeWeight(1);
- * bezier(35, -30, 0, -40, -40, 0, 40, 40, 0, -35, 30, 0);
- *
- * // Draw red lines from the anchor points to the control points.
- * stroke(255, 0, 0);
- * line(35, -30, -40, -40);
- * line(-35, 30, 40, 40);
- *
- * describe(
- * 'A gray square with three curves. A black s-curve is drawn with jagged segments. Two straight, red lines that extend from its ends. The endpoints of all the curves are marked with dots.'
- * );
- * }
- *
- *