From 6f10af22383c3635d9280c61fa9891c13ee0a1f9 Mon Sep 17 00:00:00 2001 From: Dave Pagurek Date: Sat, 14 Dec 2024 15:19:39 -0500 Subject: [PATCH] Use new SHOW/HIDE names, INCLUDE/EXCLUDE --- src/core/constants.js | 12 ++++++------ src/core/p5.Renderer.js | 2 +- src/shape/custom_shapes.js | 18 +++++++++--------- test/unit/visual/cases/shapes.js | 4 ++-- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/core/constants.js b/src/core/constants.js index b452e10997..8142772026 100644 --- a/src/core/constants.js +++ b/src/core/constants.js @@ -1347,20 +1347,20 @@ export const RGBA = 'rgba'; /** * The `splineEnds` mode where splines curve through * their first and last points. - * @typedef {unique symbol} SHOW - * @property {SHOW} SHOW + * @typedef {unique symbol} INCLUDE + * @property {INCLUDE} INCLUDE * @final */ -export const SHOW = Symbol('show'); +export const INCLUDE = Symbol('include'); /** * The `splineEnds` mode where the first and last points in a spline * affect the direction of the curve, but are not rendered. - * @typedef {unique symbol} HIDE - * @property {HIDE} HIDE + * @typedef {unique symbol} EXCLUDE + * @property {EXCLUDE} EXCLUDE * @final */ -export const HIDE = Symbol('hide'); +export const EXCLUDE = Symbol('exclude'); /** * The `splineEnds` mode where the spline loops back to its first point. diff --git a/src/core/p5.Renderer.js b/src/core/p5.Renderer.js index 04cda0e527..61d6ea0c2f 100644 --- a/src/core/p5.Renderer.js +++ b/src/core/p5.Renderer.js @@ -45,7 +45,7 @@ class Renderer { textAlign: constants.LEFT, textBaseline: constants.BASELINE, bezierOrder: 3, - splineEnds: constants.SHOW, + splineEnds: constants.INCLUDE, textWrap: constants.WORD, diff --git a/src/shape/custom_shapes.js b/src/shape/custom_shapes.js index aadfead8d9..ce718f9f3c 100644 --- a/src/shape/custom_shapes.js +++ b/src/shape/custom_shapes.js @@ -280,7 +280,7 @@ to interpolated endpoints (a breaking change) */ class SplineSegment extends Segment { #vertexCapacity = Infinity; - _splineEnds = constants.SHOW; + _splineEnds = constants.INCLUDE; _splineTightness = 0; get vertexCapacity() { @@ -296,7 +296,7 @@ class SplineSegment extends Segment { } get canOverrideAnchor() { - return this._splineEnds === constants.HIDE; + return this._splineEnds === constants.EXCLUDE; } // assuming for now that the first interpolated vertex is always @@ -304,7 +304,7 @@ class SplineSegment extends Segment { // if this spline segment doesn't follow another segment, // the first vertex is in an anchor get _firstInterpolatedVertex() { - if (this._splineEnds === constants.HIDE) { + if (this._splineEnds === constants.EXCLUDE) { return this._comesAfterSegment ? this.vertices[1] : this.vertices[0]; @@ -331,7 +331,7 @@ class SplineSegment extends Segment { this._splineEnds = shape._splineEnds; this._splineTightness = shape._splineTightness; - if (this._splineEnds !== constants.HIDE) return added; + if (this._splineEnds !== constants.EXCLUDE) return added; let verticesPushed = !this._belongsToShape; let lastPrimitive = shape.at(-1, -1); @@ -367,9 +367,9 @@ class SplineSegment extends Segment { // override method on base class getEndVertex() { - if (this._splineEnds === constants.SHOW) { + if (this._splineEnds === constants.INCLUDE) { return super.getEndVertex(); - } else if (this._splineEnds === constants.HIDE) { + } else if (this._splineEnds === constants.EXCLUDE) { return this.vertices.at(-2); } else { return this.getStartVertex(); @@ -389,7 +389,7 @@ class SplineSegment extends Segment { } const prevVertex = this.getStartVertex(); - if (this._splineEnds === constants.SHOW) { + if (this._splineEnds === constants.INCLUDE) { points.unshift(prevVertex); points.push(this.vertices.at(-1)); } else if (this._splineEnds === constants.JOIN) { @@ -584,7 +584,7 @@ class Shape { _splineTightness = 0; kind = null; contours = []; - _splineEnds = constants.SHOW; + _splineEnds = constants.INCLUDE; userVertexProperties = null; constructor( @@ -1078,7 +1078,7 @@ class PrimitiveToPath2DConverter extends PrimitiveVisitor { const shape = splineSegment._shape; if ( - splineSegment._splineEnds === constants.HIDE && + splineSegment._splineEnds === constants.EXCLUDE && !splineSegment._comesAfterSegment ) { let startVertex = splineSegment._firstInterpolatedVertex; diff --git a/test/unit/visual/cases/shapes.js b/test/unit/visual/cases/shapes.js index 04305c04e5..61f8c0d3d9 100644 --- a/test/unit/visual/cases/shapes.js +++ b/test/unit/visual/cases/shapes.js @@ -128,7 +128,7 @@ visualSuite('Shape drawing', function() { visualTest('Drawing with curves with hidden ends', function(p5, screenshot) { setup(p5); p5.beginShape(); - p5.splineEnds(p5.HIDE); + p5.splineEnds(p5.EXCLUDE); p5.splineVertex(10, 10); p5.splineVertex(15, 40); p5.splineVertex(40, 35); @@ -166,7 +166,7 @@ visualSuite('Shape drawing', function() { visualTest('Drawing closed curve loops', function(p5, screenshot) { setup(p5); p5.beginShape(); - p5.splineEnds(p5.HIDE); + p5.splineEnds(p5.EXCLUDE); p5.splineVertex(10, 10); p5.splineVertex(15, 40); p5.splineVertex(40, 35);