plotboilerplate 1.13.0 → 1.14.0

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/src/ts/Vertex.ts CHANGED
@@ -22,7 +22,9 @@
22
22
  * @modified 2020-05-26 Added functions addX(number) and addY(number).
23
23
  * @modified 2020-10-30 Changed the warnings in `sub(...)` and `add(...)` into real errors.
24
24
  * @modified 2021-03-01 Changed the second param `center` in the `rotate` function from Vertex to XYCoords.
25
- * @version 2.4.2
25
+ * @modified 2021-12-01 Changed the type of param of `scale` to XYCoords.
26
+ * @modified 2021-12-01 Added function `scaleXY` for non uniform scaling.
27
+ * @version 2.5.0
26
28
  *
27
29
  * @file Vertex
28
30
  * @public
@@ -406,19 +408,36 @@ export class Vertex implements XYCoords, SVGSerializable {
406
408
 
407
409
  /**
408
410
  * This is a vector-like behavior and 'scales' this vertex
409
- * towards/from a given center.
411
+ * towards/from a given center by one uniform scale factor.
410
412
  *
411
413
  * @method scale
412
414
  * @param {number} factor - The factor to 'scale' this vertex; 1.0 means no change.
413
- * @param {Vertex=} center - The origin of scaling; default is (0,0).
415
+ * @param {XYCoords=} center - The origin of scaling; default is (0,0).
414
416
  * @return {Vertex} this
415
417
  * @instance
416
418
  * @memberof Vertex
417
419
  **/
418
- scale(factor: number, center?: Vertex): Vertex {
419
- if (!center || typeof center === "undefined") center = new Vertex(0, 0);
420
- this.x = center.x + (this.x - center.x) * factor;
421
- this.y = center.y + (this.y - center.y) * factor;
420
+ scale(factor: number, center?: XYCoords): Vertex {
421
+ return this.scaleXY({ x: factor, y: factor }, center);
422
+ }
423
+
424
+ /**
425
+ * This is a vector-like behavior and 'scales' this vertex
426
+ * towards/from a given center by two independent x- and y- scale factors.
427
+ *
428
+ * @method scale
429
+ * @param {number} factor - The factor to 'scale' this vertex; 1.0 means no change.
430
+ * @param {XYCoords=} center - The origin of scaling; default is (0,0).
431
+ * @return {Vertex} this
432
+ * @instance
433
+ * @memberof Vertex
434
+ **/
435
+ scaleXY(factors: XYCoords, center?: XYCoords): Vertex {
436
+ if (!center || typeof center === "undefined") {
437
+ center = { x: 0, y: 0 };
438
+ }
439
+ this.x = center.x + (this.x - center.x) * factors.x;
440
+ this.y = center.y + (this.y - center.y) * factors.y;
422
441
  return this;
423
442
  }
424
443
 
@@ -1,8 +0,0 @@
1
- /**
2
- * index.es6 v0.1.17
3
- * super tiny size multi-touch gestures library for the web. Cloned from alloyfinger
4
- *
5
- * @author dntzhang
6
- * @license MIT
7
- * @preserve
8
- */