@xterm/addon-webgl 0.20.0-beta.1 → 0.20.0-beta.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xterm/addon-webgl",
3
- "version": "0.20.0-beta.1",
3
+ "version": "0.20.0-beta.3",
4
4
  "author": {
5
5
  "name": "The xterm.js authors",
6
6
  "url": "https://xtermjs.org/"
@@ -23,8 +23,8 @@
23
23
  "prepublishOnly": "npm run package",
24
24
  "start": "node ../../demo/start"
25
25
  },
26
- "commit": "4237d82923548a550c4c22941b12f319bd477b8a",
26
+ "commit": "8308ede3f5a74b24e1a7aaed89be68404951e5bc",
27
27
  "peerDependencies": {
28
- "@xterm/xterm": "^6.1.0-beta.1"
28
+ "@xterm/xterm": "^6.1.0-beta.3"
29
29
  }
30
30
  }
@@ -3,6 +3,8 @@
3
3
  * @license MIT
4
4
  */
5
5
 
6
+ /* eslint-disable @typescript-eslint/naming-convention */
7
+
6
8
  import { throwIfFalsy } from 'browser/renderer/shared/RendererUtils';
7
9
 
8
10
  interface IBlockVector {
@@ -117,6 +119,185 @@ export const blockElementDefinitions: { [index: string]: IBlockVector[] | undefi
117
119
  '\u{1FB97}': [{ x: 0, y: 2, w: 8, h: 2 }, { x: 0, y: 6, w: 8, h: 2 }]
118
120
  };
119
121
 
122
+ /**
123
+ * Generates a drawing function for sextant characters. Sextants are a 2x3 grid where each cell
124
+ * can be on or off.
125
+ * @param pattern A 6-bit pattern where bit 0 = top-left, bit 1 = top-right, bit 2 = middle-left,
126
+ * bit 3 = middle-right, bit 4 = bottom-left, bit 5 = bottom-right
127
+ */
128
+ function sextant(pattern: number): DrawFunctionDefinition {
129
+ return () => {
130
+ // Sextant grid: 2 columns, 3 rows
131
+ // Row heights in 8ths: top=3, middle=2, bottom=3
132
+ // Column widths: left=4, right=4
133
+ const rects: string[] = [];
134
+ const colW = 0.5; // Each column is half width
135
+ const rowH = [3 / 8, 2 / 8, 3 / 8]; // Row heights as fractions
136
+ const rowY = [0, 3 / 8, 5 / 8]; // Row Y positions
137
+
138
+ for (let row = 0; row < 3; row++) {
139
+ const leftBit = (pattern >> (row * 2)) & 1;
140
+ const rightBit = (pattern >> (row * 2 + 1)) & 1;
141
+
142
+ if (leftBit && rightBit) {
143
+ // Full row
144
+ rects.push(`M0,${rowY[row]} L1,${rowY[row]} L1,${rowY[row] + rowH[row]} L0,${rowY[row] + rowH[row]} Z`);
145
+ } else if (leftBit) {
146
+ rects.push(`M0,${rowY[row]} L${colW},${rowY[row]} L${colW},${rowY[row] + rowH[row]} L0,${rowY[row] + rowH[row]} Z`);
147
+ } else if (rightBit) {
148
+ rects.push(`M${colW},${rowY[row]} L1,${rowY[row]} L1,${rowY[row] + rowH[row]} L${colW},${rowY[row] + rowH[row]} Z`);
149
+ }
150
+ }
151
+ return rects.join(' ');
152
+ };
153
+ }
154
+
155
+ export const symbolsForLegacyComputingDefinitions: { [index: string]: DrawFunctionDefinition | undefined } = {
156
+ // Block sextants (0x1FB00-0x1FB3B)
157
+ // Each sextant is a 2x3 grid of cells in an 8x8 block
158
+ // Cell positions: bit 0=top-left, bit 1=top-right, bit 2=middle-left, bit 3=middle-right,
159
+ // bit 4=bottom-left, bit 5=bottom-right
160
+ // Patterns 0 (empty), 21 (left half), 42 (right half), 63 (full) are excluded as they exist
161
+ // elsewhere
162
+ '\u{1FB00}': sextant(0b000001), // BLOCK SEXTANT-1
163
+ '\u{1FB01}': sextant(0b000010), // BLOCK SEXTANT-2
164
+ '\u{1FB02}': sextant(0b000011), // BLOCK SEXTANT-12 (upper one third block)
165
+ '\u{1FB03}': sextant(0b000100), // BLOCK SEXTANT-3
166
+ '\u{1FB04}': sextant(0b000101), // BLOCK SEXTANT-13
167
+ '\u{1FB05}': sextant(0b000110), // BLOCK SEXTANT-23
168
+ '\u{1FB06}': sextant(0b000111), // BLOCK SEXTANT-123
169
+ '\u{1FB07}': sextant(0b001000), // BLOCK SEXTANT-4
170
+ '\u{1FB08}': sextant(0b001001), // BLOCK SEXTANT-14
171
+ '\u{1FB09}': sextant(0b001010), // BLOCK SEXTANT-24
172
+ '\u{1FB0A}': sextant(0b001011), // BLOCK SEXTANT-124
173
+ '\u{1FB0B}': sextant(0b001100), // BLOCK SEXTANT-34 (middle one third block)
174
+ '\u{1FB0C}': sextant(0b001101), // BLOCK SEXTANT-134
175
+ '\u{1FB0D}': sextant(0b001110), // BLOCK SEXTANT-234
176
+ '\u{1FB0E}': sextant(0b001111), // BLOCK SEXTANT-1234 (upper two thirds block)
177
+ '\u{1FB0F}': sextant(0b010000), // BLOCK SEXTANT-5
178
+ '\u{1FB10}': sextant(0b010001), // BLOCK SEXTANT-15
179
+ '\u{1FB11}': sextant(0b010010), // BLOCK SEXTANT-25
180
+ '\u{1FB12}': sextant(0b010011), // BLOCK SEXTANT-125
181
+ '\u{1FB13}': sextant(0b010100), // BLOCK SEXTANT-35
182
+ // Pattern 21 (0x15 = 0b010101) = left half block, skipped (exists as U+258C)
183
+ '\u{1FB14}': sextant(0b010110), // BLOCK SEXTANT-235
184
+ '\u{1FB15}': sextant(0b010111), // BLOCK SEXTANT-1235
185
+ '\u{1FB16}': sextant(0b011000), // BLOCK SEXTANT-45
186
+ '\u{1FB17}': sextant(0b011001), // BLOCK SEXTANT-145
187
+ '\u{1FB18}': sextant(0b011010), // BLOCK SEXTANT-245
188
+ '\u{1FB19}': sextant(0b011011), // BLOCK SEXTANT-1245
189
+ '\u{1FB1A}': sextant(0b011100), // BLOCK SEXTANT-345
190
+ '\u{1FB1B}': sextant(0b011101), // BLOCK SEXTANT-1345
191
+ '\u{1FB1C}': sextant(0b011110), // BLOCK SEXTANT-2345
192
+ '\u{1FB1D}': sextant(0b011111), // BLOCK SEXTANT-12345
193
+ '\u{1FB1E}': sextant(0b100000), // BLOCK SEXTANT-6
194
+ '\u{1FB1F}': sextant(0b100001), // BLOCK SEXTANT-16
195
+ '\u{1FB20}': sextant(0b100010), // BLOCK SEXTANT-26
196
+ '\u{1FB21}': sextant(0b100011), // BLOCK SEXTANT-126
197
+ '\u{1FB22}': sextant(0b100100), // BLOCK SEXTANT-36
198
+ '\u{1FB23}': sextant(0b100101), // BLOCK SEXTANT-136
199
+ '\u{1FB24}': sextant(0b100110), // BLOCK SEXTANT-236
200
+ '\u{1FB25}': sextant(0b100111), // BLOCK SEXTANT-1236
201
+ '\u{1FB26}': sextant(0b101000), // BLOCK SEXTANT-46
202
+ '\u{1FB27}': sextant(0b101001), // BLOCK SEXTANT-146
203
+ // Pattern 42 (0x2A = 0b101010) = right half block, skipped (exists as U+2590)
204
+ '\u{1FB28}': sextant(0b101011), // BLOCK SEXTANT-1246
205
+ '\u{1FB29}': sextant(0b101100), // BLOCK SEXTANT-346
206
+ '\u{1FB2A}': sextant(0b101101), // BLOCK SEXTANT-1346
207
+ '\u{1FB2B}': sextant(0b101110), // BLOCK SEXTANT-2346
208
+ '\u{1FB2C}': sextant(0b101111), // BLOCK SEXTANT-12346
209
+ '\u{1FB2D}': sextant(0b110000), // BLOCK SEXTANT-56 (lower one third block)
210
+ '\u{1FB2E}': sextant(0b110001), // BLOCK SEXTANT-156
211
+ '\u{1FB2F}': sextant(0b110010), // BLOCK SEXTANT-256
212
+ '\u{1FB30}': sextant(0b110011), // BLOCK SEXTANT-1256 (upper and lower one
213
+ // third block)
214
+ '\u{1FB31}': sextant(0b110100), // BLOCK SEXTANT-356
215
+ '\u{1FB32}': sextant(0b110101), // BLOCK SEXTANT-1356
216
+ '\u{1FB33}': sextant(0b110110), // BLOCK SEXTANT-2356
217
+ '\u{1FB34}': sextant(0b110111), // BLOCK SEXTANT-12356
218
+ '\u{1FB35}': sextant(0b111000), // BLOCK SEXTANT-456
219
+ '\u{1FB36}': sextant(0b111001), // BLOCK SEXTANT-1456
220
+ '\u{1FB37}': sextant(0b111010), // BLOCK SEXTANT-2456
221
+ '\u{1FB38}': sextant(0b111011), // BLOCK SEXTANT-12456
222
+ '\u{1FB39}': sextant(0b111100), // BLOCK SEXTANT-3456 (lower two thirds block)
223
+ '\u{1FB3A}': sextant(0b111101), // BLOCK SEXTANT-13456
224
+ '\u{1FB3B}': sextant(0b111110), // BLOCK SEXTANT-23456
225
+ // Pattern 63 (0x3F = 0b111111) = full block, skipped (exists as U+2588)
226
+
227
+ // Smooth mosaic terminal graphic characters (0x1FB3C-0x1FB6F)
228
+ // These are triangular/diagonal shapes. "X BLOCK DIAGONAL A TO B" means the X region is filled,
229
+ // with a diagonal edge from point A to point B.
230
+ // Reference points: upper/lower = y (0/1), left/right = x (0/1), centre = x=0.5
231
+ // Vertical uses sextant grid: upper-middle = y=1/3, lower-middle = y=2/3
232
+
233
+ // LOWER LEFT BLOCK variants (1FB3C-1FB40) - filled region in lower-left
234
+ '\u{1FB3C}': () => `M0,${2/3} L0,1 L0.5,1 Z`, // LOWER LEFT BLOCK DIAGONAL LOWER MIDDLE LEFT TO LOWER CENTRE
235
+ '\u{1FB3D}': () => `M0,${2/3} L0,1 L1,1 Z`, // LOWER LEFT BLOCK DIAGONAL LOWER MIDDLE LEFT TO LOWER RIGHT
236
+ '\u{1FB3E}': () => `M0,${1/3} L0,1 L0.5,1 Z`, // LOWER LEFT BLOCK DIAGONAL UPPER MIDDLE LEFT TO LOWER CENTRE
237
+ '\u{1FB3F}': () => `M0,${1/3} L0,1 L1,1 Z`, // LOWER LEFT BLOCK DIAGONAL UPPER MIDDLE LEFT TO LOWER RIGHT
238
+ '\u{1FB40}': () => 'M0,0 L0,1 L0.5,1 Z', // LOWER LEFT BLOCK DIAGONAL UPPER LEFT TO LOWER CENTRE
239
+
240
+ // LOWER RIGHT BLOCK variants (1FB41-1FB4B) - filled region in lower-right
241
+ '\u{1FB41}': () => `M0,${1/3} L0.5,0 L1,0 L1,1 L0,1 Z`, // LOWER RIGHT BLOCK DIAGONAL UPPER MIDDLE LEFT TO UPPER CENTRE
242
+ '\u{1FB42}': () => `M0,${1/3} L1,0 L1,1 L0,1 Z`, // LOWER RIGHT BLOCK DIAGONAL UPPER MIDDLE LEFT TO UPPER RIGHT
243
+ '\u{1FB43}': () => `M0,${2/3} L0.5,0 L1,0 L1,1 L0,1 Z`, // LOWER RIGHT BLOCK DIAGONAL LOWER MIDDLE LEFT TO UPPER CENTRE
244
+ '\u{1FB44}': () => `M0,${2/3} L1,0 L1,1 L0,1 Z`, // LOWER RIGHT BLOCK DIAGONAL LOWER MIDDLE LEFT TO UPPER RIGHT
245
+ '\u{1FB45}': () => 'M0,1 L0.5,0 L1,0 L1,1 Z', // LOWER RIGHT BLOCK DIAGONAL LOWER LEFT TO UPPER CENTRE
246
+ '\u{1FB46}': () => `M0,${2/3} L1,${1/3} L1,1 L0,1 Z`, // LOWER RIGHT BLOCK DIAGONAL LOWER MIDDLE LEFT TO UPPER MIDDLE RIGHT
247
+ '\u{1FB47}': () => `M0.5,1 L1,${2/3} L1,1 Z`, // LOWER RIGHT BLOCK DIAGONAL LOWER CENTRE TO LOWER MIDDLE RIGHT
248
+ '\u{1FB48}': () => `M0,1 L1,${2/3} L1,1 Z`, // LOWER RIGHT BLOCK DIAGONAL LOWER LEFT TO LOWER MIDDLE RIGHT
249
+ '\u{1FB49}': () => `M0.5,1 L1,${1/3} L1,1 Z`, // LOWER RIGHT BLOCK DIAGONAL LOWER CENTRE TO UPPER MIDDLE RIGHT
250
+ '\u{1FB4A}': () => `M0,1 L1,${1/3} L1,1 Z`, // LOWER RIGHT BLOCK DIAGONAL LOWER LEFT TO UPPER MIDDLE RIGHT
251
+ '\u{1FB4B}': () => 'M0.5,1 L1,0 L1,1 Z', // LOWER RIGHT BLOCK DIAGONAL LOWER CENTRE TO UPPER RIGHT
252
+
253
+ // LOWER LEFT BLOCK variants continued (1FB4C-1FB51) - large fills with upper-right cut
254
+ '\u{1FB4C}': () => `M0.5,0 L0,0 L0,1 L1,1 L1,${1/3} Z`, // LOWER LEFT BLOCK DIAGONAL UPPER CENTRE TO UPPER MIDDLE RIGHT
255
+ '\u{1FB4D}': () => `M0,0 L0,1 L1,1 L1,${1/3} Z`, // LOWER LEFT BLOCK DIAGONAL UPPER LEFT TO UPPER MIDDLE RIGHT
256
+ '\u{1FB4E}': () => `M0.5,0 L0,0 L0,1 L1,1 L1,${2/3} Z`, // LOWER LEFT BLOCK DIAGONAL UPPER CENTRE TO LOWER MIDDLE RIGHT
257
+ '\u{1FB4F}': () => `M0,0 L0,1 L1,1 L1,${2/3} Z`, // LOWER LEFT BLOCK DIAGONAL UPPER LEFT TO LOWER MIDDLE RIGHT
258
+ '\u{1FB50}': () => 'M0.5,0 L0,0 L0,1 L1,1 Z', // LOWER LEFT BLOCK DIAGONAL UPPER CENTRE TO LOWER RIGHT
259
+ '\u{1FB51}': () => `M0,${1/3} L0,1 L1,1 L1,${2/3} Z`, // LOWER LEFT BLOCK DIAGONAL UPPER MIDDLE LEFT TO LOWER MIDDLE RIGHT
260
+
261
+ // UPPER RIGHT BLOCK variants (1FB52-1FB56) - large fills with lower-left cut
262
+ '\u{1FB52}': () => `M0,${2/3} L0.5,1 L1,1 L1,0 L0,0 Z`, // UPPER RIGHT BLOCK DIAGONAL LOWER MIDDLE LEFT TO LOWER CENTRE
263
+ '\u{1FB53}': () => `M0,${2/3} L1,1 L1,0 L0,0 Z`, // UPPER RIGHT BLOCK DIAGONAL LOWER MIDDLE LEFT TO LOWER RIGHT
264
+ '\u{1FB54}': () => `M0,${1/3} L0.5,1 L1,1 L1,0 L0,0 Z`, // UPPER RIGHT BLOCK DIAGONAL UPPER MIDDLE LEFT TO LOWER CENTRE
265
+ '\u{1FB55}': () => `M0,${1/3} L1,1 L1,0 L0,0 Z`, // UPPER RIGHT BLOCK DIAGONAL UPPER MIDDLE LEFT TO LOWER RIGHT
266
+ '\u{1FB56}': () => 'M0,0 L0.5,1 L1,1 L1,0 Z', // UPPER RIGHT BLOCK DIAGONAL UPPER LEFT TO LOWER CENTRE
267
+
268
+ // UPPER LEFT BLOCK variants (1FB57-1FB61) - small to large fills in upper-left
269
+ '\u{1FB57}': () => `M0,${1/3} L0,0 L0.5,0 Z`, // UPPER LEFT BLOCK DIAGONAL UPPER MIDDLE LEFT TO UPPER CENTRE
270
+ '\u{1FB58}': () => `M0,${1/3} L0,0 L1,0 Z`, // UPPER LEFT BLOCK DIAGONAL UPPER MIDDLE LEFT TO UPPER RIGHT
271
+ '\u{1FB59}': () => `M0,${2/3} L0,0 L0.5,0 Z`, // UPPER LEFT BLOCK DIAGONAL LOWER MIDDLE LEFT TO UPPER CENTRE
272
+ '\u{1FB5A}': () => `M0,${2/3} L0,0 L1,0 Z`, // UPPER LEFT BLOCK DIAGONAL LOWER MIDDLE LEFT TO UPPER RIGHT
273
+ '\u{1FB5B}': () => 'M0,1 L0,0 L0.5,0 Z', // UPPER LEFT BLOCK DIAGONAL LOWER LEFT TO UPPER CENTRE
274
+ '\u{1FB5C}': () => `M0,${2/3} L0,0 L1,0 L1,${1/3} Z`, // UPPER LEFT BLOCK DIAGONAL LOWER MIDDLE LEFT TO UPPER MIDDLE RIGHT
275
+ '\u{1FB5D}': () => `M0.5,1 L0,1 L0,0 L1,0 L1,${2/3} Z`, // UPPER LEFT BLOCK DIAGONAL LOWER CENTRE TO LOWER MIDDLE RIGHT
276
+ '\u{1FB5E}': () => `M0,1 L0,0 L1,0 L1,${2/3} Z`, // UPPER LEFT BLOCK DIAGONAL LOWER LEFT TO LOWER MIDDLE RIGHT
277
+ '\u{1FB5F}': () => `M0.5,1 L0,1 L0,0 L1,0 L1,${1/3} Z`, // UPPER LEFT BLOCK DIAGONAL LOWER CENTRE TO UPPER MIDDLE RIGHT
278
+ '\u{1FB60}': () => `M0,1 L0,0 L1,0 L1,${1/3} Z`, // UPPER LEFT BLOCK DIAGONAL LOWER LEFT TO UPPER MIDDLE RIGHT
279
+ '\u{1FB61}': () => 'M0.5,1 L0,1 L0,0 L1,0 Z', // UPPER LEFT BLOCK DIAGONAL LOWER CENTRE TO UPPER RIGHT
280
+
281
+ // UPPER RIGHT BLOCK variants continued (1FB62-1FB67) - small to medium fills in upper-right
282
+ '\u{1FB62}': () => `M0.5,0 L1,0 L1,${1/3} Z`, // UPPER RIGHT BLOCK DIAGONAL UPPER CENTRE TO UPPER MIDDLE RIGHT
283
+ '\u{1FB63}': () => `M0,0 L1,0 L1,${1/3} Z`, // UPPER RIGHT BLOCK DIAGONAL UPPER LEFT TO UPPER MIDDLE RIGHT
284
+ '\u{1FB64}': () => `M0.5,0 L1,0 L1,${2/3} Z`, // UPPER RIGHT BLOCK DIAGONAL UPPER CENTRE TO LOWER MIDDLE RIGHT
285
+ '\u{1FB65}': () => `M0,0 L1,0 L1,${2/3} Z`, // UPPER RIGHT BLOCK DIAGONAL UPPER LEFT TO LOWER MIDDLE RIGHT
286
+ '\u{1FB66}': () => 'M0.5,0 L1,0 L1,1 Z', // UPPER RIGHT BLOCK DIAGONAL UPPER CENTRE TO LOWER RIGHT
287
+ '\u{1FB67}': () => `M0,${1/3} L1,${2/3} L1,0 L0,0 Z`, // UPPER RIGHT BLOCK DIAGONAL UPPER MIDDLE LEFT TO LOWER MIDDLE RIGHT
288
+
289
+ // Triangular blocks (1FB68-1FB6F)
290
+ // Three-quarter blocks: full block minus one triangular quarter pointing to center
291
+ '\u{1FB68}': () => 'M0,0 L1,0 L1,1 L0,1 L0.5,0.5 Z', // UPPER AND RIGHT AND LOWER TRIANGULAR THREE QUARTERS BLOCK (missing left)
292
+ '\u{1FB69}': () => 'M0,0 L0.5,0.5 L1,0 L1,1 L0,1 Z', // LEFT AND LOWER AND RIGHT TRIANGULAR THREE QUARTERS BLOCK (missing upper)
293
+ '\u{1FB6A}': () => 'M0,0 L1,0 L0.5,0.5 L1,1 L0,1 Z', // UPPER AND LEFT AND LOWER TRIANGULAR THREE QUARTERS BLOCK (missing right)
294
+ '\u{1FB6B}': () => 'M0,0 L1,0 L1,1 L0.5,0.5 L0,1 Z', // LEFT AND UPPER AND RIGHT TRIANGULAR THREE QUARTERS BLOCK (missing lower)
295
+ '\u{1FB6C}': () => 'M0,0 L0.5,0.5 L0,1 Z', // LEFT TRIANGULAR ONE QUARTER BLOCK
296
+ '\u{1FB6D}': () => 'M0,0 L1,0 L0.5,0.5 Z', // UPPER TRIANGULAR ONE QUARTER BLOCK
297
+ '\u{1FB6E}': () => 'M1,0 L1,1 L0.5,0.5 Z', // RIGHT TRIANGULAR ONE QUARTER BLOCK
298
+ '\u{1FB6F}': () => 'M0,1 L1,1 L0.5,0.5 Z' // LOWER TRIANGULAR ONE QUARTER BLOCK
299
+ };
300
+
120
301
  type PatternDefinition = number[][];
121
302
 
122
303
  /**
@@ -411,7 +592,13 @@ export function tryDrawCustomChar(
411
592
  ): boolean {
412
593
  const blockElementDefinition = blockElementDefinitions[c];
413
594
  if (blockElementDefinition) {
414
- drawBlockElementChar(ctx, blockElementDefinition, xOffset, yOffset, deviceCellWidth, deviceCellHeight);
595
+ drawBlockVectorChar(ctx, blockElementDefinition, xOffset, yOffset, deviceCellWidth, deviceCellHeight);
596
+ return true;
597
+ }
598
+
599
+ const symbolsForLegacyComputingDefinition = symbolsForLegacyComputingDefinitions[c];
600
+ if (symbolsForLegacyComputingDefinition) {
601
+ drawPathDefinitionCharacter(ctx, symbolsForLegacyComputingDefinition, xOffset, yOffset, deviceCellWidth, deviceCellHeight);
415
602
  return true;
416
603
  }
417
604
 
@@ -436,7 +623,7 @@ export function tryDrawCustomChar(
436
623
  return false;
437
624
  }
438
625
 
439
- function drawBlockElementChar(
626
+ function drawBlockVectorChar(
440
627
  ctx: CanvasRenderingContext2D,
441
628
  charDefinition: IBlockVector[],
442
629
  xOffset: number,
@@ -457,6 +644,40 @@ function drawBlockElementChar(
457
644
  }
458
645
  }
459
646
 
647
+ function drawPathDefinitionCharacter(
648
+ ctx: CanvasRenderingContext2D,
649
+ charDefinition: DrawFunctionDefinition,
650
+ xOffset: number,
651
+ yOffset: number,
652
+ deviceCellWidth: number,
653
+ deviceCellHeight: number
654
+ ): void {
655
+ const instructions = charDefinition(0, 0);
656
+ ctx.beginPath();
657
+ for (const instruction of instructions.split(' ')) {
658
+ const type = instruction[0];
659
+ const args: string[] = instruction.substring(1).split(',');
660
+ if (!args[0] || !args[1]) {
661
+ if (type === 'Z') {
662
+ ctx.closePath();
663
+ }
664
+ continue;
665
+ }
666
+ const translatedArgs = args.map((e, i) => {
667
+ const val = parseFloat(e);
668
+ return i % 2 === 0
669
+ ? xOffset + val * deviceCellWidth
670
+ : yOffset + val * deviceCellHeight;
671
+ });
672
+ if (type === 'M') {
673
+ ctx.moveTo(translatedArgs[0], translatedArgs[1]);
674
+ } else if (type === 'L') {
675
+ ctx.lineTo(translatedArgs[0], translatedArgs[1]);
676
+ }
677
+ }
678
+ ctx.fill();
679
+ }
680
+
460
681
  const cachedPatterns: Map<PatternDefinition, Map</* fillStyle */string, CanvasPattern>> = new Map();
461
682
 
462
683
  function drawPatternChar(