@js-draw/math 1.2.1 → 1.2.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.
@@ -111,6 +111,10 @@ class Color4 {
111
111
  canvas.width = 1;
112
112
  canvas.height = 1;
113
113
  const ctx = canvas.getContext('2d');
114
+ // Default to black if no canvas is available.
115
+ if (!ctx) {
116
+ return Color4.black;
117
+ }
114
118
  ctx.fillStyle = text;
115
119
  ctx.fillRect(0, 0, 1, 1);
116
120
  const data = ctx.getImageData(0, 0, 1, 1);
@@ -105,6 +105,10 @@ class Color4 {
105
105
  canvas.width = 1;
106
106
  canvas.height = 1;
107
107
  const ctx = canvas.getContext('2d');
108
+ // Default to black if no canvas is available.
109
+ if (!ctx) {
110
+ return Color4.black;
111
+ }
108
112
  ctx.fillStyle = text;
109
113
  ctx.fillRect(0, 0, 1, 1);
110
114
  const data = ctx.getImageData(0, 0, 1, 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@js-draw/math",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "A math library for js-draw. ",
5
5
  "types": "./dist/mjs/lib.d.ts",
6
6
  "main": "./dist/cjs/lib.js",
@@ -45,5 +45,5 @@
45
45
  "svg",
46
46
  "math"
47
47
  ],
48
- "gitHead": "0cb756d3150c8b33dd9a3217faa7d18229688f34"
48
+ "gitHead": "ced98ae289f299c44b54515571d0087aa6d32cdc"
49
49
  }
package/src/Color4.ts CHANGED
@@ -125,7 +125,13 @@ export default class Color4 {
125
125
  canvas.width = 1;
126
126
  canvas.height = 1;
127
127
 
128
- const ctx = canvas.getContext('2d')!;
128
+ const ctx = canvas.getContext('2d');
129
+
130
+ // Default to black if no canvas is available.
131
+ if (!ctx) {
132
+ return Color4.black;
133
+ }
134
+
129
135
  ctx.fillStyle = text;
130
136
  ctx.fillRect(0, 0, 1, 1);
131
137