@@ -280,8 +280,10 @@ to interpolated endpoints (a breaking change)
280
280
*/
281
281
class SplineSegment extends Segment {
282
282
#vertexCapacity = Infinity ;
283
- _splineEnds = constants . INCLUDE ;
284
- _splineTightness = 0 ;
283
+ _splineProperties = {
284
+ ends : constants . INCLUDE ,
285
+ tightness : 0
286
+ } ;
285
287
286
288
get vertexCapacity ( ) {
287
289
return this . #vertexCapacity;
@@ -296,15 +298,15 @@ class SplineSegment extends Segment {
296
298
}
297
299
298
300
get canOverrideAnchor ( ) {
299
- return this . _splineEnds === constants . EXCLUDE ;
301
+ return this . _splineProperties . ends === constants . EXCLUDE ;
300
302
}
301
303
302
304
// assuming for now that the first interpolated vertex is always
303
305
// the second vertex passed to splineVertex()
304
306
// if this spline segment doesn't follow another segment,
305
307
// the first vertex is in an anchor
306
308
get _firstInterpolatedVertex ( ) {
307
- if ( this . _splineEnds === constants . EXCLUDE ) {
309
+ if ( this . _splineProperties . ends === constants . EXCLUDE ) {
308
310
return this . _comesAfterSegment ?
309
311
this . vertices [ 1 ] :
310
312
this . vertices [ 0 ] ;
@@ -328,10 +330,10 @@ class SplineSegment extends Segment {
328
330
// doesn't line up with end of last segment
329
331
addToShape ( shape ) {
330
332
const added = super . addToShape ( shape ) ;
331
- this . _splineEnds = shape . _splineEnds ;
332
- this . _splineTightness = shape . _splineTightness ;
333
+ this . _splineProperties . ends = shape . _splineProperties . ends ;
334
+ this . _splineProperties . tightness = shape . _splineProperties . tightness ;
333
335
334
- if ( this . _splineEnds !== constants . EXCLUDE ) return added ;
336
+ if ( this . _splineProperties . ends !== constants . EXCLUDE ) return added ;
335
337
336
338
let verticesPushed = ! this . _belongsToShape ;
337
339
let lastPrimitive = shape . at ( - 1 , - 1 ) ;
@@ -367,9 +369,9 @@ class SplineSegment extends Segment {
367
369
368
370
// override method on base class
369
371
getEndVertex ( ) {
370
- if ( this . _splineEnds === constants . INCLUDE ) {
372
+ if ( this . _splineProperties . ends === constants . INCLUDE ) {
371
373
return super . getEndVertex ( ) ;
372
- } else if ( this . _splineEnds === constants . EXCLUDE ) {
374
+ } else if ( this . _splineProperties . ends === constants . EXCLUDE ) {
373
375
return this . vertices . at ( - 2 ) ;
374
376
} else {
375
377
return this . getStartVertex ( ) ;
@@ -389,10 +391,10 @@ class SplineSegment extends Segment {
389
391
}
390
392
391
393
const prevVertex = this . getStartVertex ( ) ;
392
- if ( this . _splineEnds === constants . INCLUDE ) {
394
+ if ( this . _splineProperties . ends === constants . INCLUDE ) {
393
395
points . unshift ( prevVertex ) ;
394
396
points . push ( this . vertices . at ( - 1 ) ) ;
395
- } else if ( this . _splineEnds === constants . JOIN ) {
397
+ } else if ( this . _splineProperties . ends === constants . JOIN ) {
396
398
points . unshift ( this . vertices . at ( - 1 ) , prevVertex ) ;
397
399
points . push ( prevVertex , this . vertices . at ( 0 ) ) ;
398
400
}
@@ -410,7 +412,7 @@ class SplineSegment extends Segment {
410
412
}
411
413
412
414
close ( ) {
413
- this . _splineEnds = constants . JOIN ;
415
+ this . _splineProperties . ends = constants . JOIN ;
414
416
}
415
417
}
416
418
@@ -581,10 +583,12 @@ class Shape {
581
583
#initialVertexProperties;
582
584
#primitiveShapeCreators;
583
585
#bezierOrder = 3 ;
584
- _splineTightness = 0 ;
585
586
kind = null ;
586
587
contours = [ ] ;
587
- _splineEnds = constants . INCLUDE ;
588
+ _splineProperties = {
589
+ tightness : 0 ,
590
+ ends : constants . INCLUDE
591
+ } ;
588
592
userVertexProperties = null ;
589
593
590
594
constructor (
@@ -828,12 +832,8 @@ class Shape {
828
832
this . #bezierOrder = order ;
829
833
}
830
834
831
- splineEnds ( mode ) {
832
- this . _splineEnds = mode ;
833
- }
834
-
835
- splineTightness ( tightness ) {
836
- this . _splineTightness = tightness ;
835
+ splineProperty ( key , value ) {
836
+ this . _splineProperties [ key ] = value ;
837
837
}
838
838
839
839
/*
@@ -1076,7 +1076,7 @@ class PrimitiveToPath2DConverter extends PrimitiveVisitor {
1076
1076
const shape = splineSegment . _shape ;
1077
1077
1078
1078
if (
1079
- splineSegment . _splineEnds === constants . EXCLUDE &&
1079
+ splineSegment . _splineProperties . ends === constants . EXCLUDE &&
1080
1080
! splineSegment . _comesAfterSegment
1081
1081
) {
1082
1082
let startVertex = splineSegment . _firstInterpolatedVertex ;
@@ -1088,7 +1088,7 @@ class PrimitiveToPath2DConverter extends PrimitiveVisitor {
1088
1088
) ;
1089
1089
let bezierArrays = shape . catmullRomToBezier (
1090
1090
arrayVertices ,
1091
- splineSegment . _splineTightness
1091
+ splineSegment . _splineProperties . tightness
1092
1092
) . map ( arr => arr . map ( vertArr => shape . arrayToVertex ( vertArr ) ) ) ;
1093
1093
for ( const array of bezierArrays ) {
1094
1094
const points = array . flatMap ( vert => [ vert . position . x , vert . position . y ] ) ;
@@ -1217,7 +1217,7 @@ class PrimitiveToVerticesConverter extends PrimitiveVisitor {
1217
1217
) ;
1218
1218
let bezierArrays = shape . catmullRomToBezier (
1219
1219
arrayVertices ,
1220
- splineSegment . _splineTightness
1220
+ splineSegment . _splineProperties . tightness
1221
1221
) ;
1222
1222
let startVertex = shape . vertexToArray ( splineSegment . _firstInterpolatedVertex ) ;
1223
1223
for ( const array of bezierArrays ) {
@@ -1596,10 +1596,11 @@ function customShapes(p5, fn) {
1596
1596
1597
1597
/**
1598
1598
* TODO: documentation
1599
- * @param {SHOW|HIDE } mode
1599
+ * @param {String } key
1600
+ * @param value
1600
1601
*/
1601
- fn . splineEnds = function ( mode ) {
1602
- return this . _renderer . splineEnds ( mode ) ;
1602
+ fn . splineProperty = function ( key , value ) {
1603
+ return this . _renderer . splineProperty ( key , value ) ;
1603
1604
} ;
1604
1605
1605
1606
/**
0 commit comments