litecanvas 0.207.1 → 0.208.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/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '0.207.1'
2
+ export const version = '0.208.0'
package/types/global.d.ts CHANGED
@@ -59,6 +59,19 @@ declare global {
59
59
  * @returns the value in degrees
60
60
  */
61
61
  function rad2deg(rads: number): number
62
+ /**
63
+ * Modulus (Euclidean division).
64
+ *
65
+ * Note: When `b == 0` returns `0`, rather than `NaN`.
66
+ *
67
+ * @param a dividend
68
+ * @param b divisor
69
+ * @returns the remainder
70
+ * @example
71
+ * mod(-1, 5) // => 4
72
+ * -1 % 5 // => -1
73
+ */
74
+ function mod(a: number, b: number): number
62
75
  /**
63
76
  * Returns the rounded value of an number to optional precision (number of digits after the decimal point).
64
77
  *
@@ -430,10 +443,23 @@ declare global {
430
443
  context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D
431
444
  ): CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D
432
445
  /**
433
- * saves the current drawing style settings and transformations
446
+ * Saves the current drawing style settings and, optionally, transforms (translate/rotate/scale) the canvas.
447
+ *
448
+ * @param [translateX]
449
+ * @param [translateY]
450
+ * @param [rotation] in radians
451
+ * @param [scaleX]
452
+ * @param [scaleY]
453
+ *
434
454
  * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/save
435
455
  */
436
- function push(): void
456
+ function push(
457
+ translateX?: number,
458
+ translateY?: number,
459
+ rotation?: number,
460
+ scaleX?: number,
461
+ scaleY?: number
462
+ ): void
437
463
  /**
438
464
  * restores the drawing style settings and transformations
439
465
  * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/restore
package/types/types.d.ts CHANGED
@@ -5,9 +5,9 @@ type LitecanvasInstance = {
5
5
  H: number
6
6
  /** the amount of time (in seconds) since the game started */
7
7
  T: number
8
- /** The current mouse's horizontal (X) position or -1 (if the mouse was not used or detected) */
8
+ /** The current mouse's horizontal (X) position or `-1` (if the mouse was not used or detected) */
9
9
  MX: number
10
- /** The current mouse's vertical (Y) position or -1 (if the mouse was not used or detected) */
10
+ /** The current mouse's vertical (Y) position or `-1` (if the mouse was not used or detected) */
11
11
  MY: number
12
12
 
13
13
  /** MATH API */
@@ -53,6 +53,19 @@ type LitecanvasInstance = {
53
53
  * @returns the value in degrees
54
54
  */
55
55
  rad2deg(rads: number): number
56
+ /**
57
+ * Modulus (Euclidean division).
58
+ *
59
+ * Note: When `b == 0` returns `0`, rather than `NaN`.
60
+ *
61
+ * @param a dividend
62
+ * @param b divisor
63
+ * @returns the remainder
64
+ * @example
65
+ * mod(-1, 5) // => 4
66
+ * -1 % 5 // => -1
67
+ */
68
+ mod(a: number, b: number): number
56
69
  /**
57
70
  * Returns the rounded value of an number to optional precision (number of digits after the decimal point).
58
71
  *
@@ -418,10 +431,23 @@ type LitecanvasInstance = {
418
431
  context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D
419
432
  ): CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D
420
433
  /**
421
- * saves the current drawing style settings and transformations
434
+ * Saves the current drawing style settings and, optionally, transforms (translate/rotate/scale) the canvas.
435
+ *
436
+ * @param [translateX]
437
+ * @param [translateY]
438
+ * @param [rotation] in radians
439
+ * @param [scaleX]
440
+ * @param [scaleY]
441
+ *
422
442
  * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/save
423
443
  */
424
- push(): void
444
+ push(
445
+ translateX?: number,
446
+ translateY?: number,
447
+ rotation?: number,
448
+ scaleX?: number,
449
+ scaleY?: number
450
+ ): void
425
451
  /**
426
452
  * restores the drawing style settings and transformations
427
453
  * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/restore