litecanvas 0.78.0 → 0.78.1

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/dist.dev.js CHANGED
@@ -136,7 +136,9 @@
136
136
  return 180 / PI * rads;
137
137
  },
138
138
  /**
139
- * Calculates the integer closest to a number and optional precision.
139
+ * Returns the rounded value of an number to optional precision (number of digits after the decimal point).
140
+ *
141
+ * Note: precision is optional but must be >= 0
140
142
  *
141
143
  * @param {number} n number to round.
142
144
  * @param {number} [precision] number of decimal digits to round to, default is 0.
package/dist/dist.js CHANGED
@@ -126,7 +126,9 @@
126
126
  return 180 / PI * rads;
127
127
  },
128
128
  /**
129
- * Calculates the integer closest to a number and optional precision.
129
+ * Returns the rounded value of an number to optional precision (number of digits after the decimal point).
130
+ *
131
+ * Note: precision is optional but must be >= 0
130
132
  *
131
133
  * @param {number} n number to round.
132
134
  * @param {number} [precision] number of decimal digits to round to, default is 0.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "litecanvas",
3
- "version": "0.78.0",
3
+ "version": "0.78.1",
4
4
  "description": "Lightweight HTML5 canvas game engine suitable for small projects and creative coding. Inspired by PICO-8 and P5/Processing.",
5
5
  "license": "MIT",
6
6
  "author": "Luiz Bills <luizbills@pm.me>",
package/src/index.js CHANGED
@@ -191,7 +191,9 @@ export default function litecanvas(settings = {}) {
191
191
  },
192
192
 
193
193
  /**
194
- * Calculates the integer closest to a number and optional precision.
194
+ * Returns the rounded value of an number to optional precision (number of digits after the decimal point).
195
+ *
196
+ * Note: precision is optional but must be >= 0
195
197
  *
196
198
  * @param {number} n number to round.
197
199
  * @param {number} [precision] number of decimal digits to round to, default is 0.
package/types/index.d.ts CHANGED
@@ -72,6 +72,14 @@ declare global {
72
72
  * @returns the value in degrees
73
73
  */
74
74
  function rad2deg(rads: number): number
75
+ /**
76
+ * Returns the rounded value of an number to optional precision (number of digits after the decimal point).
77
+ *
78
+ * @param n number to round.
79
+ * @param [precision] number of decimal digits to round to, default is 0.
80
+ * @returns the rounded number.
81
+ */
82
+ function round(n: number, precision?: number): number
75
83
  /**
76
84
  * Constrains a number between `min` and `max`.
77
85
  *
package/types/types.d.ts CHANGED
@@ -61,6 +61,14 @@ type LitecanvasInstance = {
61
61
  * @returns the value in degrees
62
62
  */
63
63
  rad2deg(rads: number): number
64
+ /**
65
+ * Returns the rounded value of an number to optional precision (number of digits after the decimal point).
66
+ *
67
+ * @param n number to round.
68
+ * @param [precision] number of decimal digits to round to, default is 0.
69
+ * @returns the rounded number.
70
+ */
71
+ round(n: number, precision?: number): number
64
72
  /**
65
73
  * Constrains a number between `min` and `max`.
66
74
  *