@thi.ng/text-canvas 2.6.21 → 2.6.23
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/CHANGELOG.md +1 -1
- package/README.md +1 -1
- package/api.js +95 -79
- package/bars.js +37 -31
- package/canvas.js +164 -135
- package/circle.js +55 -66
- package/format.js +14 -20
- package/hvline.js +64 -61
- package/image.js +231 -310
- package/line.js +66 -73
- package/package.json +15 -13
- package/rect.js +66 -88
- package/style.js +30 -26
- package/table.js +133 -118
- package/text.js +86 -108
- package/utils.js +13 -8
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
package/api.js
CHANGED
|
@@ -1,85 +1,101 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
})(Align ||
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
})(Border ||
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
dot: ".",
|
|
1
|
+
var Align = /* @__PURE__ */ ((Align2) => {
|
|
2
|
+
Align2[Align2["LEFT"] = 0] = "LEFT";
|
|
3
|
+
Align2[Align2["RIGHT"] = 1] = "RIGHT";
|
|
4
|
+
Align2[Align2["CENTER"] = 2] = "CENTER";
|
|
5
|
+
return Align2;
|
|
6
|
+
})(Align || {});
|
|
7
|
+
var Border = /* @__PURE__ */ ((Border2) => {
|
|
8
|
+
Border2[Border2["NONE"] = 0] = "NONE";
|
|
9
|
+
Border2[Border2["H"] = 1] = "H";
|
|
10
|
+
Border2[Border2["V"] = 2] = "V";
|
|
11
|
+
Border2[Border2["ALL"] = 3] = "ALL";
|
|
12
|
+
Border2[Border2["FRAME"] = 4] = "FRAME";
|
|
13
|
+
Border2[Border2["FRAME_H"] = 5] = "FRAME_H";
|
|
14
|
+
Border2[Border2["FRAME_V"] = 6] = "FRAME_V";
|
|
15
|
+
return Border2;
|
|
16
|
+
})(Border || {});
|
|
17
|
+
const STYLE_ASCII = {
|
|
18
|
+
hl: "-",
|
|
19
|
+
vl: "|",
|
|
20
|
+
tl: "+",
|
|
21
|
+
tr: "+",
|
|
22
|
+
bl: "+",
|
|
23
|
+
br: "+",
|
|
24
|
+
tjl: "+",
|
|
25
|
+
tjr: "+",
|
|
26
|
+
tjt: "+",
|
|
27
|
+
tjb: "+",
|
|
28
|
+
jct: "+",
|
|
29
|
+
dot: "."
|
|
31
30
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
31
|
+
const STYLE_THIN = {
|
|
32
|
+
hl: "\u2500",
|
|
33
|
+
vl: "\u2502",
|
|
34
|
+
tl: "\u250C",
|
|
35
|
+
tr: "\u2510",
|
|
36
|
+
bl: "\u2514",
|
|
37
|
+
br: "\u2518",
|
|
38
|
+
tjl: "\u251C",
|
|
39
|
+
tjr: "\u2524",
|
|
40
|
+
tjt: "\u252C",
|
|
41
|
+
tjb: "\u2534",
|
|
42
|
+
jct: "\u253C",
|
|
43
|
+
dot: "\u2022"
|
|
45
44
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
const STYLE_THIN_ROUNDED = {
|
|
46
|
+
...STYLE_THIN,
|
|
47
|
+
tl: "\u256D",
|
|
48
|
+
tr: "\u256E",
|
|
49
|
+
bl: "\u2570",
|
|
50
|
+
br: "\u256F"
|
|
52
51
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
const STYLE_DASHED = {
|
|
53
|
+
...STYLE_THIN,
|
|
54
|
+
hl: "\u254C",
|
|
55
|
+
vl: "\u2506"
|
|
57
56
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
const STYLE_DASHED_ROUNDED = {
|
|
58
|
+
...STYLE_DASHED,
|
|
59
|
+
tl: "\u256D",
|
|
60
|
+
tr: "\u256E",
|
|
61
|
+
bl: "\u2570",
|
|
62
|
+
br: "\u256F"
|
|
64
63
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
64
|
+
const STYLE_DOUBLE = {
|
|
65
|
+
hl: "\u2550",
|
|
66
|
+
vl: "\u2551",
|
|
67
|
+
tl: "\u2554",
|
|
68
|
+
tr: "\u2557",
|
|
69
|
+
bl: "\u255A",
|
|
70
|
+
br: "\u255D",
|
|
71
|
+
tjl: "\u2560",
|
|
72
|
+
tjr: "\u2563",
|
|
73
|
+
tjt: "\u2566",
|
|
74
|
+
tjb: "\u2569",
|
|
75
|
+
jct: "\u256C",
|
|
76
|
+
dot: "\u2022"
|
|
77
|
+
};
|
|
78
|
+
const ENDINGS = "()[]{}<>^v\u25C0\u25B6\u25B2\u25BC\u2022\u25CF";
|
|
79
|
+
const BARS_H = " \u258F\u258E\u258D\u258C\u258B\u258A\u2589\u2588";
|
|
80
|
+
const BARS_V = " \u2581\u2582\u2583\u2584\u2585\u2586\u2587\u2588";
|
|
81
|
+
const SHADES_ASCII_10 = " .-:=+*#%@";
|
|
82
|
+
const SHADES_ASCII_16 = " .,-:+=il3GXOQW0";
|
|
83
|
+
const SHADES_BLOCK = " \u2591\u2592\u2593\u2588";
|
|
84
|
+
const SHADES_BLOCK_ALT = " \u2596\u259E\u259F\u2588";
|
|
85
|
+
export {
|
|
86
|
+
Align,
|
|
87
|
+
BARS_H,
|
|
88
|
+
BARS_V,
|
|
89
|
+
Border,
|
|
90
|
+
ENDINGS,
|
|
91
|
+
SHADES_ASCII_10,
|
|
92
|
+
SHADES_ASCII_16,
|
|
93
|
+
SHADES_BLOCK,
|
|
94
|
+
SHADES_BLOCK_ALT,
|
|
95
|
+
STYLE_ASCII,
|
|
96
|
+
STYLE_DASHED,
|
|
97
|
+
STYLE_DASHED_ROUNDED,
|
|
98
|
+
STYLE_DOUBLE,
|
|
99
|
+
STYLE_THIN,
|
|
100
|
+
STYLE_THIN_ROUNDED
|
|
78
101
|
};
|
|
79
|
-
export const ENDINGS = "()[]{}<>^v◀▶▲▼•●";
|
|
80
|
-
export const BARS_H = " ▏▎▍▌▋▊▉█";
|
|
81
|
-
export const BARS_V = " ▁▂▃▄▅▆▇█";
|
|
82
|
-
export const SHADES_ASCII_10 = " .-:=+*#%@";
|
|
83
|
-
export const SHADES_ASCII_16 = " .,-:+=il3GXOQW0";
|
|
84
|
-
export const SHADES_BLOCK = " ░▒▓█";
|
|
85
|
-
export const SHADES_BLOCK_ALT = " ▖▞▟█";
|
package/bars.js
CHANGED
|
@@ -8,39 +8,45 @@ import { map } from "@thi.ng/transducers/map";
|
|
|
8
8
|
import { max as $max } from "@thi.ng/transducers/max";
|
|
9
9
|
import { min as $min } from "@thi.ng/transducers/min";
|
|
10
10
|
import { BARS_H, BARS_V } from "./api.js";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
res.push(line);
|
|
11
|
+
const barChartHLines = (height, vals, min, max) => {
|
|
12
|
+
const $vals = ensureArray(vals);
|
|
13
|
+
min = min !== void 0 ? min : $min($vals);
|
|
14
|
+
max = max !== void 0 ? max : $max($vals);
|
|
15
|
+
const bars = [...map((x) => barVertical(height, x, min, max, ""), $vals)];
|
|
16
|
+
const num = bars.length;
|
|
17
|
+
const res = [];
|
|
18
|
+
for (let i = 0; i < height; i++) {
|
|
19
|
+
let line = "";
|
|
20
|
+
for (let j = 0; j < num; j++) {
|
|
21
|
+
line += bars[j][i];
|
|
24
22
|
}
|
|
25
|
-
|
|
23
|
+
res.push(line);
|
|
24
|
+
}
|
|
25
|
+
return res;
|
|
26
26
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
const barChartHStr = (height, vals, min, max) => barChartHLines(height, vals, min, max).join("\n");
|
|
28
|
+
const barChartVLines = (width, vals, min, max) => {
|
|
29
|
+
const $vals = ensureArray(vals);
|
|
30
|
+
min = min !== void 0 ? min : $min($vals);
|
|
31
|
+
max = max !== void 0 ? max : $max($vals);
|
|
32
|
+
return [...map((x) => barHorizontal(width, x, min, max), $vals)];
|
|
33
33
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
const barChartVStr = (width, vals, min, max) => barChartVLines(width, vals, min, max).join("\n");
|
|
35
|
+
const barHorizontal = (width, x, min = 0, max = 1) => bar(BARS_H, width, false, x, min, max, "");
|
|
36
|
+
const barVertical = (height, x, min = 0, max = 1, delim = "\n") => bar(BARS_V, height, true, x, min, max, delim);
|
|
37
37
|
const bar = (chars, size, left, x, min, max, delim) => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
x = fitClamped(x, min, max, 0, size);
|
|
39
|
+
const f = fract(x) * 9 | 0;
|
|
40
|
+
const full = repeat(chars[8] + delim, x | 0);
|
|
41
|
+
const partial = f > 0 ? chars[f] + delim : "";
|
|
42
|
+
size += size * delim.length;
|
|
43
|
+
return left ? padLeft(size, " ")(partial + full) : padRight(size, " ")(full + partial);
|
|
44
|
+
};
|
|
45
|
+
export {
|
|
46
|
+
barChartHLines,
|
|
47
|
+
barChartHStr,
|
|
48
|
+
barChartVLines,
|
|
49
|
+
barChartVStr,
|
|
50
|
+
barHorizontal,
|
|
51
|
+
barVertical
|
|
46
52
|
};
|
package/canvas.js
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result)
|
|
9
|
+
__defProp(target, key, result);
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
import {
|
|
13
|
+
nomixin
|
|
14
|
+
} from "@thi.ng/api";
|
|
4
15
|
import { IGrid2DMixin } from "@thi.ng/api/mixins/igrid";
|
|
5
16
|
import { peek } from "@thi.ng/arrays/peek";
|
|
6
17
|
import { assert } from "@thi.ng/errors/assert";
|
|
@@ -11,147 +22,165 @@ import { max } from "@thi.ng/transducers/max";
|
|
|
11
22
|
import { transduce } from "@thi.ng/transducers/transduce";
|
|
12
23
|
import { STYLE_ASCII } from "./api.js";
|
|
13
24
|
import { charCode, intersectRect } from "./utils.js";
|
|
14
|
-
let Canvas =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
25
|
+
let Canvas = class {
|
|
26
|
+
data;
|
|
27
|
+
size;
|
|
28
|
+
stride;
|
|
29
|
+
format;
|
|
30
|
+
defaultFormat;
|
|
31
|
+
styles;
|
|
32
|
+
clipRects;
|
|
33
|
+
constructor(width, height, format = NONE, style = STYLE_ASCII) {
|
|
34
|
+
this.size = [width, height];
|
|
35
|
+
this.stride = [1, this.width];
|
|
36
|
+
this.format = this.defaultFormat = format;
|
|
37
|
+
this.data = new Uint32Array(width * height).fill(
|
|
38
|
+
charCode(32, format)
|
|
39
|
+
);
|
|
40
|
+
this.styles = [style];
|
|
41
|
+
this.clipRects = [
|
|
42
|
+
{ x1: 0, y1: 0, x2: width, y2: height, w: width, h: height }
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
get width() {
|
|
46
|
+
return this.size[0];
|
|
47
|
+
}
|
|
48
|
+
get height() {
|
|
49
|
+
return this.size[1];
|
|
50
|
+
}
|
|
51
|
+
get offset() {
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
get dim() {
|
|
55
|
+
return 2;
|
|
56
|
+
}
|
|
57
|
+
copy() {
|
|
58
|
+
const res = new Canvas(this.width, this.height, this.format);
|
|
59
|
+
res.data.set(this.data);
|
|
60
|
+
res.stride = this.stride.slice();
|
|
61
|
+
res.styles = this.styles.slice();
|
|
62
|
+
res.clipRects = this.clipRects.slice();
|
|
63
|
+
return res;
|
|
64
|
+
}
|
|
65
|
+
// @ts-ignore mixin
|
|
66
|
+
order() {
|
|
67
|
+
}
|
|
68
|
+
// @ts-ignore mixin
|
|
69
|
+
includes(d0, d1) {
|
|
70
|
+
}
|
|
71
|
+
// @ts-ignore mixin
|
|
72
|
+
indexAt(d0, d1) {
|
|
73
|
+
}
|
|
74
|
+
// @ts-ignore mixin
|
|
75
|
+
indexAtUnsafe(d0, d1) {
|
|
76
|
+
}
|
|
77
|
+
// @ts-ignore mixin
|
|
78
|
+
getAt(x, y) {
|
|
79
|
+
}
|
|
80
|
+
// @ts-ignore mixin
|
|
81
|
+
getAtUnsafe(x, y) {
|
|
82
|
+
}
|
|
83
|
+
setAt(x, y, val) {
|
|
84
|
+
return this.includes(x, y) ? (this.data[this.indexAtUnsafe(x, y)] = charCode(
|
|
85
|
+
val,
|
|
86
|
+
this.format
|
|
87
|
+
), true) : false;
|
|
88
|
+
}
|
|
89
|
+
// @ts-ignore mixin
|
|
90
|
+
setAtUnsafe(x, y, col) {
|
|
91
|
+
}
|
|
72
92
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
], Canvas.prototype, "setAt",
|
|
76
|
-
Canvas =
|
|
77
|
-
|
|
93
|
+
__decorateClass([
|
|
94
|
+
nomixin
|
|
95
|
+
], Canvas.prototype, "setAt", 1);
|
|
96
|
+
Canvas = __decorateClass([
|
|
97
|
+
IGrid2DMixin
|
|
78
98
|
], Canvas);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
assert(height > 0, "require at least 1 line of text");
|
|
96
|
-
const width = transduce(map((x) => x.length), max(), lines);
|
|
97
|
-
const res = canvas(width, height, format);
|
|
98
|
-
fill !== undefined && res.data.fill(charCode(fill, format));
|
|
99
|
-
format <<= 16;
|
|
100
|
-
for (let y = 0; y < height; y++) {
|
|
101
|
-
const line = lines[y];
|
|
102
|
-
for (let x = 0, i = y * width, n = Math.min(width, line.length); x < n; x++, i++) {
|
|
103
|
-
res.data[i] = line.charCodeAt(x) | format;
|
|
104
|
-
}
|
|
99
|
+
const canvas = (width, height, format, style) => new Canvas(width, height, format, style);
|
|
100
|
+
const canvasFromText = (lines, format = NONE, fill) => {
|
|
101
|
+
const height = lines.length;
|
|
102
|
+
assert(height > 0, "require at least 1 line of text");
|
|
103
|
+
const width = transduce(
|
|
104
|
+
map((x) => x.length),
|
|
105
|
+
max(),
|
|
106
|
+
lines
|
|
107
|
+
);
|
|
108
|
+
const res = canvas(width, height, format);
|
|
109
|
+
fill !== void 0 && res.data.fill(charCode(fill, format));
|
|
110
|
+
format <<= 16;
|
|
111
|
+
for (let y = 0; y < height; y++) {
|
|
112
|
+
const line = lines[y];
|
|
113
|
+
for (let x = 0, i = y * width, n = Math.min(width, line.length); x < n; x++, i++) {
|
|
114
|
+
res.data[i] = line.charCodeAt(x) | format;
|
|
105
115
|
}
|
|
106
|
-
|
|
116
|
+
}
|
|
117
|
+
return res;
|
|
107
118
|
};
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
+
const beginClip = (canvas2, x, y, w, h) => {
|
|
120
|
+
x |= 0;
|
|
121
|
+
y |= 0;
|
|
122
|
+
w |= 0;
|
|
123
|
+
h |= 0;
|
|
124
|
+
const { width, height } = canvas2;
|
|
125
|
+
const x2 = clamp(x + w, 0, width);
|
|
126
|
+
const y2 = clamp(y + h, 0, height);
|
|
127
|
+
const x1 = clamp(x, 0, width);
|
|
128
|
+
const y1 = clamp(y, 0, height);
|
|
129
|
+
canvas2.clipRects.push(
|
|
130
|
+
intersectRect(
|
|
131
|
+
{ x1, y1, x2, y2, w: x2 - x1, h: y2 - y1 },
|
|
132
|
+
peek(canvas2.clipRects)
|
|
133
|
+
)
|
|
134
|
+
);
|
|
119
135
|
};
|
|
120
136
|
const pop = (stack) => stack.length > 1 && stack.pop();
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
137
|
+
const endClip = (canvas2) => pop(canvas2.clipRects);
|
|
138
|
+
const withClip = (canvas2, x, y, w, h, fn) => {
|
|
139
|
+
beginClip(canvas2, x, y, w, h);
|
|
140
|
+
fn();
|
|
141
|
+
canvas2.clipRects.pop();
|
|
142
|
+
};
|
|
143
|
+
const beginStyle = (canvas2, style) => {
|
|
144
|
+
canvas2.styles.push(style);
|
|
126
145
|
};
|
|
127
|
-
|
|
128
|
-
|
|
146
|
+
const endStyle = (canvas2) => pop(canvas2.styles);
|
|
147
|
+
const withStyle = (canvas2, style, fn) => {
|
|
148
|
+
canvas2.styles.push(style);
|
|
149
|
+
fn();
|
|
150
|
+
canvas2.styles.pop();
|
|
129
151
|
};
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
152
|
+
const setFormat = (canvas2, format) => canvas2.format = format;
|
|
153
|
+
const withFormat = (canvas2, format, fn) => {
|
|
154
|
+
const prev = canvas2.format;
|
|
155
|
+
canvas2.format = format;
|
|
156
|
+
fn();
|
|
157
|
+
canvas2.format = prev;
|
|
135
158
|
};
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
fn();
|
|
141
|
-
canvas.format = prev;
|
|
159
|
+
const getAt = (canvas2, x, y) => {
|
|
160
|
+
x |= 0;
|
|
161
|
+
y |= 0;
|
|
162
|
+
return x >= 0 && y >= 0 && x < canvas2.width && y < canvas2.height ? canvas2.data[x + y * canvas2.width] : 0;
|
|
142
163
|
};
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
164
|
+
const setAt = (canvas2, x, y, code, format = canvas2.format) => {
|
|
165
|
+
x |= 0;
|
|
166
|
+
y |= 0;
|
|
167
|
+
const { x1, y1, x2, y2 } = peek(canvas2.clipRects);
|
|
168
|
+
if (x < x1 || y < y1 || x >= x2 || y >= y2)
|
|
169
|
+
return;
|
|
170
|
+
canvas2.data[x + y * canvas2.width] = charCode(code, format);
|
|
149
171
|
};
|
|
150
|
-
export
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
172
|
+
export {
|
|
173
|
+
Canvas,
|
|
174
|
+
beginClip,
|
|
175
|
+
beginStyle,
|
|
176
|
+
canvas,
|
|
177
|
+
canvasFromText,
|
|
178
|
+
endClip,
|
|
179
|
+
endStyle,
|
|
180
|
+
getAt,
|
|
181
|
+
setAt,
|
|
182
|
+
setFormat,
|
|
183
|
+
withClip,
|
|
184
|
+
withFormat,
|
|
185
|
+
withStyle
|
|
157
186
|
};
|