Skip to content

Commit

Permalink
Use new SHOW/HIDE names, INCLUDE/EXCLUDE
Browse files Browse the repository at this point in the history
  • Loading branch information
davepagurek committed Dec 14, 2024
1 parent 00f414a commit 6f10af2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions src/core/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/core/p5.Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Renderer {
textAlign: constants.LEFT,
textBaseline: constants.BASELINE,
bezierOrder: 3,
splineEnds: constants.SHOW,
splineEnds: constants.INCLUDE,

textWrap: constants.WORD,

Expand Down
18 changes: 9 additions & 9 deletions src/shape/custom_shapes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -296,15 +296,15 @@ 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
// the second vertex passed to splineVertex()
// 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];
Expand All @@ -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);
Expand Down Expand Up @@ -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();
Expand All @@ -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) {
Expand Down Expand Up @@ -584,7 +584,7 @@ class Shape {
_splineTightness = 0;
kind = null;
contours = [];
_splineEnds = constants.SHOW;
_splineEnds = constants.INCLUDE;
userVertexProperties = null;

constructor(
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions test/unit/visual/cases/shapes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 6f10af2

Please sign in to comment.