You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add strokeAttenuation property for constant stroke width
Introduces the strokeAttenuation property to Path, Points, Text, and Group objects, allowing stroke width to remain constant in screen space regardless of transformations when set to false. Adds getEffectiveStrokeWidth utility and updates renderers to use it for stroke width calculations. This enables more flexible visual control over stroke rendering, especially for zooming and scaling scenarios.
* @property {Boolean} - When set to `true`, stroke width scales with transformations (default behavior). When `false`, stroke width remains constant in screen space.
5331
+
* @description When `strokeAttenuation` is `false`, the stroke width is automatically adjusted to compensate for the object's world transform scale, maintaining constant visual thickness regardless of zoom level. When `true` (default), stroke width scales normally with transformations.
5332
+
*/
5333
+
strokeAttenuation: {
5334
+
enumerable: true,
5335
+
get: function(){
5336
+
returnthis._strokeAttenuation;
5337
+
},
5338
+
set: function(v){
5339
+
this._strokeAttenuation=!!v;
5340
+
this._flagStrokeAttenuation=true;
5341
+
this._flagLinewidth=true;
5342
+
}
5294
5343
}
5295
5344
};
5296
5345
functionFlagVertices(){
@@ -6769,6 +6818,7 @@ var Two = (() => {
6769
6818
_flagVisible=true;
6770
6819
_flagSize=true;
6771
6820
_flagSizeAttenuation=true;
6821
+
_flagStrokeAttenuation=true;
6772
6822
_length=0;
6773
6823
_fill="#fff";
6774
6824
_stroke="#000";
@@ -6780,6 +6830,7 @@ var Two = (() => {
6780
6830
_beginning=0;
6781
6831
_ending=1;
6782
6832
_dashes=null;
6833
+
_strokeAttenuation=true;
6783
6834
constructor(vertices){
6784
6835
super();
6785
6836
for(letpropinproto16){
@@ -6821,7 +6872,8 @@ var Two = (() => {
6821
6872
"sizeAttenuation",
6822
6873
"beginning",
6823
6874
"ending",
6824
-
"dashes"
6875
+
"dashes",
6876
+
"strokeAttenuation"
6825
6877
];
6826
6878
/**
6827
6879
* @name Two.Points.fromObject
@@ -7216,6 +7268,22 @@ var Two = (() => {
7216
7268
}
7217
7269
this._dashes=v;
7218
7270
}
7271
+
},
7272
+
/**
7273
+
* @name Two.Points#strokeAttenuation
7274
+
* @property {Boolean} - When set to `true`, stroke width scales with transformations (default behavior). When `false`, stroke width remains constant in screen space.
7275
+
* @description When `strokeAttenuation` is `false`, the stroke width is automatically adjusted to compensate for the object's world transform scale, maintaining constant visual thickness regardless of zoom level. When `true` (default), stroke width scales normally with transformations.
* @description Release the text's renderer resources and detach all events.
8356
-
* This method disposes fill and stroke effects (calling dispose() on
8437
+
* This method disposes fill and stroke effects (calling dispose() on
8357
8438
* Gradients and Textures for thorough cleanup) while preserving the
8358
8439
* renderer type for potential re-attachment to a new renderer.
8359
8440
*/
@@ -8655,6 +8736,22 @@ var Two = (() => {
8655
8736
}
8656
8737
this._dashes=v;
8657
8738
}
8739
+
},
8740
+
/**
8741
+
* @name Two.Text#strokeAttenuation
8742
+
* @property {Boolean} - When set to `true`, stroke width scales with transformations (default behavior). When `false`, stroke width remains constant in screen space.
8743
+
* @description When `strokeAttenuation` is `false`, the stroke width is automatically adjusted to compensate for the object's world transform scale, maintaining constant visual thickness regardless of zoom level. When `true` (default), stroke width scales normally with transformations.
8744
+
*/
8745
+
strokeAttenuation: {
8746
+
enumerable: true,
8747
+
get: function(){
8748
+
returnthis._strokeAttenuation;
8749
+
},
8750
+
set: function(v){
8751
+
this._strokeAttenuation=!!v;
8752
+
this._flagStrokeAttenuation=true;
8753
+
this._flagLinewidth=true;
8754
+
}
8658
8755
}
8659
8756
};
8660
8757
functionFlagFill2(){
@@ -9265,6 +9362,12 @@ var Two = (() => {
9265
9362
* @property {Two.Shape} - The Two.js object to clip from a group's rendering.
9266
9363
*/
9267
9364
_mask=null;
9365
+
/**
9366
+
* @name Two.Group#_strokeAttenuation
9367
+
* @private
9368
+
* @see {@link Two.Group#strokeAttenuation}
9369
+
*/
9370
+
_strokeAttenuation=true;
9268
9371
constructor(children){
9269
9372
super();
9270
9373
for(letpropinproto22){
@@ -9999,6 +10102,26 @@ var Two = (() => {
9999
10102
v.clip=true;
10000
10103
}
10001
10104
}
10105
+
},
10106
+
/**
10107
+
* @name Two.Group#strokeAttenuation
10108
+
* @property {Boolean} - When set to `true`, stroke width scales with transformations (default behavior). When `false`, stroke width remains constant in screen space for all child shapes.
10109
+
* @description When `strokeAttenuation` is `false`, this property is applied to all child shapes, making their stroke widths automatically adjust to compensate for the group's world transform scale, maintaining constant visual thickness regardless of zoom level. When `true` (default), stroke widths scale normally with transformations.
0 commit comments