@ntf/math 1.3.1 → 1.3.2
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 +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +10 -24
- package/dist/index.mjs +10 -24
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -337,7 +337,6 @@ declare class Rectangle implements IRectangle, IGeometryObject, IToString {
|
|
|
337
337
|
static cast(a: unknown): Rectangle | undefined;
|
|
338
338
|
static is(a: unknown): a is RectangleLike;
|
|
339
339
|
constructor(pos: Vec2Like, size: SizeLike);
|
|
340
|
-
constructor(x: number, y: number, width: number, height: number);
|
|
341
340
|
toArray(w?: boolean): RectangleArray;
|
|
342
341
|
toString(w?: boolean): RectangleString;
|
|
343
342
|
toJSON(): IRectangle;
|
package/dist/index.d.ts
CHANGED
|
@@ -337,7 +337,6 @@ declare class Rectangle implements IRectangle, IGeometryObject, IToString {
|
|
|
337
337
|
static cast(a: unknown): Rectangle | undefined;
|
|
338
338
|
static is(a: unknown): a is RectangleLike;
|
|
339
339
|
constructor(pos: Vec2Like, size: SizeLike);
|
|
340
|
-
constructor(x: number, y: number, width: number, height: number);
|
|
341
340
|
toArray(w?: boolean): RectangleArray;
|
|
342
341
|
toString(w?: boolean): RectangleString;
|
|
343
342
|
toJSON(): IRectangle;
|
package/dist/index.js
CHANGED
|
@@ -1259,9 +1259,9 @@ var Rectangle = class _Rectangle {
|
|
|
1259
1259
|
if (a == null || typeof a == "undefined")
|
|
1260
1260
|
return void 0;
|
|
1261
1261
|
if (check_number_array(a, 4))
|
|
1262
|
-
return new this(a[0], a[1], a[2], a[3]);
|
|
1262
|
+
return new this([a[0], a[1]], [a[2], a[3]]);
|
|
1263
1263
|
if (check_number_array(a, 5)) {
|
|
1264
|
-
const rect = new this(a[0], a[1], a[3], a[4]);
|
|
1264
|
+
const rect = new this([a[0], a[1]], [a[3], a[4]]);
|
|
1265
1265
|
rect.w = a[2];
|
|
1266
1266
|
return rect;
|
|
1267
1267
|
}
|
|
@@ -1271,12 +1271,12 @@ var Rectangle = class _Rectangle {
|
|
|
1271
1271
|
const size = Size.cast(ssize);
|
|
1272
1272
|
if (typeof pos == "undefined" || typeof size == "undefined")
|
|
1273
1273
|
return void 0;
|
|
1274
|
-
const rect = new this(pos.x, pos.y, size.width, size.height);
|
|
1274
|
+
const rect = new this([pos.x, pos.y], [size.width, size.height]);
|
|
1275
1275
|
rect.w = pos.w;
|
|
1276
1276
|
return rect;
|
|
1277
1277
|
}
|
|
1278
1278
|
if (has_property(a, "x", "number") && has_property(a, "y", "number") && has_property(a, "width", "number") && has_property(a, "height", "number")) {
|
|
1279
|
-
const rect = new this(a.x, a.y, a.width, a.height);
|
|
1279
|
+
const rect = new this([a.x, a.y], [a.width, a.height]);
|
|
1280
1280
|
if (has_property(a, "w", "number"))
|
|
1281
1281
|
rect.w = a.w;
|
|
1282
1282
|
return rect;
|
|
@@ -1286,23 +1286,9 @@ var Rectangle = class _Rectangle {
|
|
|
1286
1286
|
static is(a) {
|
|
1287
1287
|
return typeof this.cast(a) != "undefined";
|
|
1288
1288
|
}
|
|
1289
|
-
constructor(
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
const x = typeof a == "number" ? a : vec?.x;
|
|
1293
|
-
if (!check_number(x))
|
|
1294
|
-
throw new TypeError("expected number for x position");
|
|
1295
|
-
const y = typeof b == "number" ? b : vec?.y;
|
|
1296
|
-
if (!check_number(y))
|
|
1297
|
-
throw new TypeError("expected number for y position");
|
|
1298
|
-
const width = typeof c == "number" ? c : size?.width;
|
|
1299
|
-
if (!check_number(width))
|
|
1300
|
-
throw new TypeError("expected number for width");
|
|
1301
|
-
const height = typeof d == "number" ? d : size?.height;
|
|
1302
|
-
if (!check_number(height))
|
|
1303
|
-
throw new TypeError("expected number for height");
|
|
1304
|
-
this.position = new Vec2(x, y);
|
|
1305
|
-
this.size = new Size(width, height);
|
|
1289
|
+
constructor(pos, size) {
|
|
1290
|
+
this.position = Vec2.resolve(pos);
|
|
1291
|
+
this.size = Size.resolve(size);
|
|
1306
1292
|
}
|
|
1307
1293
|
toArray(w = false) {
|
|
1308
1294
|
return [...this.position.toArray(w), ...this.size.toArray()];
|
|
@@ -1405,7 +1391,7 @@ var BoundingBox = class _BoundingBox {
|
|
|
1405
1391
|
return new Size(this.width, this.height);
|
|
1406
1392
|
}
|
|
1407
1393
|
toRectangle() {
|
|
1408
|
-
return new Rectangle(this.left, this.top, this.width, this.height);
|
|
1394
|
+
return new Rectangle([this.left, this.top], [this.width, this.height]);
|
|
1409
1395
|
}
|
|
1410
1396
|
inside(a) {
|
|
1411
1397
|
const bbox = _BoundingBox.resolve(a);
|
|
@@ -2427,7 +2413,7 @@ var RGBAColor = class _RGBAColor {
|
|
|
2427
2413
|
} : this.alpha == 1 ? { red: this.red, green: this.green, blue: this.blue } : this.toJSON(true);
|
|
2428
2414
|
}
|
|
2429
2415
|
toString(withAlpha = false) {
|
|
2430
|
-
return withAlpha ? `rgba(${_fix_integer(this.red)},${_fix_integer(this.green)},${_fix_integer(this.blue)},${
|
|
2416
|
+
return withAlpha ? `rgba(${_fix_integer(this.red)},${_fix_integer(this.green)},${_fix_integer(this.blue)},${this.alpha})` : this.alpha == 1 ? `rgb(${_fix_integer(this.red)},${_fix_integer(this.green)},${_fix_integer(this.blue)})` : this.toString(true);
|
|
2431
2417
|
}
|
|
2432
2418
|
toHSL(withAlpha = true) {
|
|
2433
2419
|
const red = this.red, green = this.green, blue = this.blue;
|
|
@@ -2542,7 +2528,7 @@ var HSLColor = class _HSLColor {
|
|
|
2542
2528
|
} : this.alpha == 1 ? { hue: this.hue, saturation: this.saturation, luminace: this.luminace } : this.toJSON(true);
|
|
2543
2529
|
}
|
|
2544
2530
|
toString(withAlpha = false) {
|
|
2545
|
-
return withAlpha ? `hsla(${_fix_integer(this.hue)},${_fix_integer(this.saturation)},${_fix_integer(this.luminace)},${
|
|
2531
|
+
return withAlpha ? `hsla(${_fix_integer(this.hue)},${_fix_integer(this.saturation)},${_fix_integer(this.luminace)},${this.alpha})` : this.alpha == 1 ? `hsl(${_fix_integer(this.hue)},${_fix_integer(this.saturation)},${_fix_integer(this.luminace)})` : this.toString(true);
|
|
2546
2532
|
}
|
|
2547
2533
|
toRGB(withAlpha = true) {
|
|
2548
2534
|
if (this.saturation == 0)
|
package/dist/index.mjs
CHANGED
|
@@ -1187,9 +1187,9 @@ var Rectangle = class _Rectangle {
|
|
|
1187
1187
|
if (a == null || typeof a == "undefined")
|
|
1188
1188
|
return void 0;
|
|
1189
1189
|
if (check_number_array(a, 4))
|
|
1190
|
-
return new this(a[0], a[1], a[2], a[3]);
|
|
1190
|
+
return new this([a[0], a[1]], [a[2], a[3]]);
|
|
1191
1191
|
if (check_number_array(a, 5)) {
|
|
1192
|
-
const rect = new this(a[0], a[1], a[3], a[4]);
|
|
1192
|
+
const rect = new this([a[0], a[1]], [a[3], a[4]]);
|
|
1193
1193
|
rect.w = a[2];
|
|
1194
1194
|
return rect;
|
|
1195
1195
|
}
|
|
@@ -1199,12 +1199,12 @@ var Rectangle = class _Rectangle {
|
|
|
1199
1199
|
const size = Size.cast(ssize);
|
|
1200
1200
|
if (typeof pos == "undefined" || typeof size == "undefined")
|
|
1201
1201
|
return void 0;
|
|
1202
|
-
const rect = new this(pos.x, pos.y, size.width, size.height);
|
|
1202
|
+
const rect = new this([pos.x, pos.y], [size.width, size.height]);
|
|
1203
1203
|
rect.w = pos.w;
|
|
1204
1204
|
return rect;
|
|
1205
1205
|
}
|
|
1206
1206
|
if (has_property(a, "x", "number") && has_property(a, "y", "number") && has_property(a, "width", "number") && has_property(a, "height", "number")) {
|
|
1207
|
-
const rect = new this(a.x, a.y, a.width, a.height);
|
|
1207
|
+
const rect = new this([a.x, a.y], [a.width, a.height]);
|
|
1208
1208
|
if (has_property(a, "w", "number"))
|
|
1209
1209
|
rect.w = a.w;
|
|
1210
1210
|
return rect;
|
|
@@ -1214,23 +1214,9 @@ var Rectangle = class _Rectangle {
|
|
|
1214
1214
|
static is(a) {
|
|
1215
1215
|
return typeof this.cast(a) != "undefined";
|
|
1216
1216
|
}
|
|
1217
|
-
constructor(
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
const x = typeof a == "number" ? a : vec?.x;
|
|
1221
|
-
if (!check_number(x))
|
|
1222
|
-
throw new TypeError("expected number for x position");
|
|
1223
|
-
const y = typeof b == "number" ? b : vec?.y;
|
|
1224
|
-
if (!check_number(y))
|
|
1225
|
-
throw new TypeError("expected number for y position");
|
|
1226
|
-
const width = typeof c == "number" ? c : size?.width;
|
|
1227
|
-
if (!check_number(width))
|
|
1228
|
-
throw new TypeError("expected number for width");
|
|
1229
|
-
const height = typeof d == "number" ? d : size?.height;
|
|
1230
|
-
if (!check_number(height))
|
|
1231
|
-
throw new TypeError("expected number for height");
|
|
1232
|
-
this.position = new Vec2(x, y);
|
|
1233
|
-
this.size = new Size(width, height);
|
|
1217
|
+
constructor(pos, size) {
|
|
1218
|
+
this.position = Vec2.resolve(pos);
|
|
1219
|
+
this.size = Size.resolve(size);
|
|
1234
1220
|
}
|
|
1235
1221
|
toArray(w = false) {
|
|
1236
1222
|
return [...this.position.toArray(w), ...this.size.toArray()];
|
|
@@ -1333,7 +1319,7 @@ var BoundingBox = class _BoundingBox {
|
|
|
1333
1319
|
return new Size(this.width, this.height);
|
|
1334
1320
|
}
|
|
1335
1321
|
toRectangle() {
|
|
1336
|
-
return new Rectangle(this.left, this.top, this.width, this.height);
|
|
1322
|
+
return new Rectangle([this.left, this.top], [this.width, this.height]);
|
|
1337
1323
|
}
|
|
1338
1324
|
inside(a) {
|
|
1339
1325
|
const bbox = _BoundingBox.resolve(a);
|
|
@@ -2355,7 +2341,7 @@ var RGBAColor = class _RGBAColor {
|
|
|
2355
2341
|
} : this.alpha == 1 ? { red: this.red, green: this.green, blue: this.blue } : this.toJSON(true);
|
|
2356
2342
|
}
|
|
2357
2343
|
toString(withAlpha = false) {
|
|
2358
|
-
return withAlpha ? `rgba(${_fix_integer(this.red)},${_fix_integer(this.green)},${_fix_integer(this.blue)},${
|
|
2344
|
+
return withAlpha ? `rgba(${_fix_integer(this.red)},${_fix_integer(this.green)},${_fix_integer(this.blue)},${this.alpha})` : this.alpha == 1 ? `rgb(${_fix_integer(this.red)},${_fix_integer(this.green)},${_fix_integer(this.blue)})` : this.toString(true);
|
|
2359
2345
|
}
|
|
2360
2346
|
toHSL(withAlpha = true) {
|
|
2361
2347
|
const red = this.red, green = this.green, blue = this.blue;
|
|
@@ -2470,7 +2456,7 @@ var HSLColor = class _HSLColor {
|
|
|
2470
2456
|
} : this.alpha == 1 ? { hue: this.hue, saturation: this.saturation, luminace: this.luminace } : this.toJSON(true);
|
|
2471
2457
|
}
|
|
2472
2458
|
toString(withAlpha = false) {
|
|
2473
|
-
return withAlpha ? `hsla(${_fix_integer(this.hue)},${_fix_integer(this.saturation)},${_fix_integer(this.luminace)},${
|
|
2459
|
+
return withAlpha ? `hsla(${_fix_integer(this.hue)},${_fix_integer(this.saturation)},${_fix_integer(this.luminace)},${this.alpha})` : this.alpha == 1 ? `hsl(${_fix_integer(this.hue)},${_fix_integer(this.saturation)},${_fix_integer(this.luminace)})` : this.toString(true);
|
|
2474
2460
|
}
|
|
2475
2461
|
toRGB(withAlpha = true) {
|
|
2476
2462
|
if (this.saturation == 0)
|