pts 0.12.8 → 0.12.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +24 -32
- package/dist/index.d.ts +24 -32
- package/dist/index.js +17 -26
- package/dist/index.mjs +17 -26
- package/dist/pts.js +17 -26
- package/dist/pts.min.js +3 -3
- package/package.json +3 -3
package/dist/pts.js
CHANGED
|
@@ -902,11 +902,11 @@ See https://github.com/williamngan/pts for details. */
|
|
|
902
902
|
/**
|
|
903
903
|
* Create a new circle that either fits within or encloses the rectangle. Same as [`Circle.fromRect`](#link).
|
|
904
904
|
* @param pts a Group or an Iterable<Pt> with 2 Pt representing a rectangle
|
|
905
|
-
* @param
|
|
905
|
+
* @param enclose if `true`, the circle will enclose the rectangle. If `false`, the circle will fit inside the rectangle.
|
|
906
906
|
* @returns a Group that represents a circle
|
|
907
907
|
*/
|
|
908
|
-
static toCircle(pts,
|
|
909
|
-
return Circle.fromRect(pts,
|
|
908
|
+
static toCircle(pts, enclose = true) {
|
|
909
|
+
return Circle.fromRect(pts, enclose);
|
|
910
910
|
}
|
|
911
911
|
/**
|
|
912
912
|
* Create a square that either fits within or encloses a rectangle.
|
|
@@ -4102,8 +4102,6 @@ See https://github.com/williamngan/pts for details. */
|
|
|
4102
4102
|
super(...args);
|
|
4103
4103
|
this._center = new Pt();
|
|
4104
4104
|
this._size = new Pt();
|
|
4105
|
-
this._topLeft = new Pt();
|
|
4106
|
-
this._bottomRight = new Pt();
|
|
4107
4105
|
this._inited = false;
|
|
4108
4106
|
this.init();
|
|
4109
4107
|
}
|
|
@@ -4137,10 +4135,6 @@ See https://github.com/williamngan/pts for details. */
|
|
|
4137
4135
|
this._inited = true;
|
|
4138
4136
|
}
|
|
4139
4137
|
if (this.p1 && this.p2) {
|
|
4140
|
-
const a = this.p1;
|
|
4141
|
-
const b = this.p2;
|
|
4142
|
-
this.topLeft = a.$min(b);
|
|
4143
|
-
this._bottomRight = a.$max(b);
|
|
4144
4138
|
this._updateSize();
|
|
4145
4139
|
this._inited = true;
|
|
4146
4140
|
}
|
|
@@ -4149,33 +4143,33 @@ See https://github.com/williamngan/pts for details. */
|
|
|
4149
4143
|
* Clone this bound and return a new one.
|
|
4150
4144
|
*/
|
|
4151
4145
|
clone() {
|
|
4152
|
-
return new _Bound(this.
|
|
4146
|
+
return new _Bound(this.topLeft.clone(), this.bottomRight.clone());
|
|
4153
4147
|
}
|
|
4154
4148
|
/**
|
|
4155
4149
|
* Recalculte size and center.
|
|
4156
4150
|
*/
|
|
4157
4151
|
_updateSize() {
|
|
4158
|
-
this._size = this.
|
|
4152
|
+
this._size = this.bottomRight.$subtract(this.topLeft).abs();
|
|
4159
4153
|
this._updateCenter();
|
|
4160
4154
|
}
|
|
4161
4155
|
/**
|
|
4162
4156
|
* Recalculate center.
|
|
4163
4157
|
*/
|
|
4164
4158
|
_updateCenter() {
|
|
4165
|
-
this._center = this._size.$multiply(0.5).add(this.
|
|
4159
|
+
this._center = this._size.$multiply(0.5).add(this.topLeft);
|
|
4166
4160
|
}
|
|
4167
4161
|
/**
|
|
4168
4162
|
* Recalculate based on top-left position and size.
|
|
4169
4163
|
*/
|
|
4170
4164
|
_updatePosFromTop() {
|
|
4171
|
-
this.
|
|
4165
|
+
this.bottomRight = this.topLeft.$add(this._size);
|
|
4172
4166
|
this._updateCenter();
|
|
4173
4167
|
}
|
|
4174
4168
|
/**
|
|
4175
4169
|
* Recalculate based on bottom-right position and size.
|
|
4176
4170
|
*/
|
|
4177
4171
|
_updatePosFromBottom() {
|
|
4178
|
-
this.
|
|
4172
|
+
this.topLeft = this.bottomRight.$subtract(this._size);
|
|
4179
4173
|
this._updateCenter();
|
|
4180
4174
|
}
|
|
4181
4175
|
/**
|
|
@@ -4183,8 +4177,8 @@ See https://github.com/williamngan/pts for details. */
|
|
|
4183
4177
|
*/
|
|
4184
4178
|
_updatePosFromCenter() {
|
|
4185
4179
|
const half = this._size.$multiply(0.5);
|
|
4186
|
-
this.
|
|
4187
|
-
this.
|
|
4180
|
+
this.topLeft = this._center.$subtract(half);
|
|
4181
|
+
this.bottomRight = this._center.$add(half);
|
|
4188
4182
|
}
|
|
4189
4183
|
/**
|
|
4190
4184
|
* Size of this Bound
|
|
@@ -4210,22 +4204,20 @@ See https://github.com/williamngan/pts for details. */
|
|
|
4210
4204
|
* Top-left position of this Bound
|
|
4211
4205
|
*/
|
|
4212
4206
|
get topLeft() {
|
|
4213
|
-
return new Pt(this
|
|
4207
|
+
return new Pt(this[0]);
|
|
4214
4208
|
}
|
|
4215
4209
|
set topLeft(p) {
|
|
4216
|
-
this
|
|
4217
|
-
this[0] = this._topLeft;
|
|
4210
|
+
this[0] = new Pt(p);
|
|
4218
4211
|
this._updateSize();
|
|
4219
4212
|
}
|
|
4220
4213
|
/**
|
|
4221
4214
|
* Bottom-right position of this Bound
|
|
4222
4215
|
*/
|
|
4223
4216
|
get bottomRight() {
|
|
4224
|
-
return new Pt(this
|
|
4217
|
+
return new Pt(this[1]);
|
|
4225
4218
|
}
|
|
4226
4219
|
set bottomRight(p) {
|
|
4227
|
-
this
|
|
4228
|
-
this[1] = this._bottomRight;
|
|
4220
|
+
this[1] = new Pt(p);
|
|
4229
4221
|
this._updateSize();
|
|
4230
4222
|
}
|
|
4231
4223
|
/**
|
|
@@ -4287,8 +4279,8 @@ See https://github.com/williamngan/pts for details. */
|
|
|
4287
4279
|
* It's simpler and preferable to change the Bound's properties (eg, topLeft, bottomRight) instead of updating the Bound's Pts.
|
|
4288
4280
|
*/
|
|
4289
4281
|
update() {
|
|
4290
|
-
this.
|
|
4291
|
-
this.
|
|
4282
|
+
this.topLeft = this[0];
|
|
4283
|
+
this.bottomRight = this[1];
|
|
4292
4284
|
this._updateSize();
|
|
4293
4285
|
return this;
|
|
4294
4286
|
}
|
|
@@ -5988,8 +5980,7 @@ See https://github.com/williamngan/pts for details. */
|
|
|
5988
5980
|
this.autoResize = opt.resize != void 0 ? opt.resize : false;
|
|
5989
5981
|
if (opt.retina !== false) {
|
|
5990
5982
|
const r1 = window ? window.devicePixelRatio || 1 : 1;
|
|
5991
|
-
|
|
5992
|
-
this._pixelScale = Math.max(1, r1 / r2);
|
|
5983
|
+
this._pixelScale = Math.max(1, r1);
|
|
5993
5984
|
}
|
|
5994
5985
|
if (opt.offscreen) {
|
|
5995
5986
|
this._offscreen = true;
|