We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 871153f commit 24e2e03Copy full SHA for 24e2e03
src/utils/webgl-utils.ts
@@ -190,13 +190,14 @@ export function degreesToRadians(degrees: number) {
190
}
191
192
// to avoid recreating the ctx each time
193
-const colorConvertCtx = document.createElement("canvas").getContext("2d");
+let ctx: CanvasRenderingContext2D | null;
194
195
function colorToRgbOrHex(color: string): string {
196
- // because cavnas 2D context automagically converts
+ // because canvas 2D context automagically converts
197
// any valid css color to a hex string
198
// or an RGBA string
199
- const ctx = colorConvertCtx;
+ ctx = ctx ?? document.createElement("canvas").getContext("2d");
200
+
201
if (!ctx) {
202
return "#000000";
203
0 commit comments