@pictogrammers/components 0.5.14 → 0.5.17
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 +1 -1
- package/pg/autocompleteItem/__examples__/basic/basic.html +3 -0
- package/pg/autocompleteItem/autocompleteItem.css +55 -0
- package/pg/autocompleteItem/autocompleteItem.html +1 -0
- package/pg/autocompleteItem/autocompleteItem.ts +65 -0
- package/pg/button/button.css +5 -0
- package/pg/buttonMenu/buttonMenu.ts +1 -1
- package/pg/inputCombobox/__examples__/basic/basic.ts +33 -0
- package/pg/inputCombobox/inputCombobox.ts +158 -0
- package/pg/inputCombobox/inputCombobox.ts.tmp.44252.751480cb81cc +158 -0
- package/pg/inputCombobox/inputCombobox.ts.tmp.44252.dcea847c40a8 +156 -0
- package/pg/inputNumber/inputNumber.ts +31 -13
- package/pg/inputPill/inputPill.html +6 -0
- package/pg/inputPill/inputPill.html.tmp.26852.84ac63f4c46f +6 -0
- package/pg/inputPill/inputPill.ts +41 -0
- package/pg/inputPills/__examples__/basic/basic.html +9 -0
- package/pg/inputPills/__examples__/basic/basic.html.tmp.26852.4771e4cad5b7 +9 -0
- package/pg/inputPills/__examples__/basic/basic.ts.tmp.26852.d8fe41df18bd +0 -0
- package/pg/inputPixelEditor/README.md +104 -69
- package/pg/inputPixelEditor/README.md.tmp.42596.658de5f0a6f5 +0 -0
- package/pg/inputPixelEditor/__examples__/basic/basic.ts +6 -5
- package/pg/inputPixelEditor/inputPixelEditor.ts +95 -23
- package/pg/inputPixelEditor/inputPixelEditor.ts.tmp.38516.96529dd82670 +1703 -0
- package/pg/inputPixelEditor/inputPixelEditor.ts.tmp.42596.48ecc3ad9c72 +1724 -0
- package/pg/inputPixelEditor/utils/bitmapToMask.ts +113 -79
- package/pg/inputPixelEditor/utils/getLassoPixels.ts +51 -0
- package/pg/inputRange/inputRange.css +7 -0
- package/pg/inputSelect/__examples__/basic/basic.ts +2 -2
- package/pg/inputSelect/inputSelect.css +1 -1
- package/pg/inputSelect/inputSelect.ts +62 -5
- package/pg/inputText/README.md +6 -6
- package/pg/inputText/__examples__/basic/basic.ts +1 -1
- package/pg/inputText/inputText.css +2 -2
- package/pg/inputText copy/README.md +38 -0
- package/pg/inputText copy/inputText.css +41 -0
- package/pg/inputText copy/inputText.html +1 -0
- package/pg/inputText copy/inputText.spec.ts +59 -0
- package/pg/inputText copy/inputText.ts +67 -0
- package/pg/inputTextarea/README.md +39 -0
- package/pg/inputTextarea/__examples__/basic/basic.html +9 -0
- package/pg/inputTextarea/__examples__/basic/basic.ts +30 -0
- package/pg/inputTextarea/inputTextarea.ts +121 -0
- package/pg/inputTextarea copy/README.md +39 -0
- package/pg/inputTextarea copy/inputTextarea.css +41 -0
- package/pg/inputTextarea copy/inputTextarea.html +1 -0
- package/pg/inputTextarea copy/inputTextarea.spec.ts +59 -0
- package/pg/inputTextarea copy/inputTextarea.ts +79 -0
- package/pg/inputTextareaAutocomplete/README.md +70 -0
- package/pg/inputTextareaAutocomplete/__examples__/basic/basic.ts +67 -0
- package/pg/inputTextareaAutocomplete/inputTextareaAutocomplete.ts +267 -0
- package/pg/node/README.md +35 -0
- package/pg/node/__examples__/basic/basic.ts +34 -0
- package/pg/node/index.ts +3 -0
- package/pg/node/node.css +53 -0
- package/pg/node/node.html +5 -0
- package/pg/node/node.ts +270 -0
- package/pg/nodeEditorLink/nodeEditorLink.css +69 -0
- package/pg/nodeEditorLink/nodeEditorLink.css.tmp.1408.09e961fd0dcc +69 -0
- package/pg/nodeEditorLink/nodeEditorLink.html +9 -0
- package/pg/nodeEditorNumber/nodeEditorNumber.css +59 -0
- package/pg/nodeEditorNumber/nodeEditorNumber.ts +57 -0
- package/pg/nodeEditorRange/nodeEditorRange.css +23 -0
- package/pg/nodeEditorRange/nodeEditorRange.ts +69 -0
- package/pg/nodeEditorText/__examples__/basic/basic.html +9 -0
- package/pg/nodeEditorText/__examples__/basic/basic.ts +30 -0
- package/pg/nodeEditorText/nodeEditorText.css +17 -0
- package/pg/nodeEditorText/nodeEditorText.html +4 -0
- package/pg/nodeEditorText/nodeEditorText.ts +57 -0
- package/pg/nodeEditorText copy/README.md +35 -0
- package/pg/nodeEditorText copy/nodeEditorText.css +49 -0
- package/pg/nodeEditorText copy/nodeEditorText.html +4 -0
- package/pg/nodeEditorText copy/nodeEditorText.ts +50 -0
- package/pg/nodeEditorTextArray/nodeEditorTextArray.css +68 -0
- package/pg/nodeEditorTextArray/nodeEditorTextArray.html +9 -0
- package/pg/nodeEditorTextArray/nodeEditorTextArray.ts +162 -0
- package/pg/nodeEntry/nodeEntry.css +61 -0
- package/pg/nodeEntry/nodeEntry.ts +164 -0
- package/pg/nodeEntry/nodeEntry.ts.tmp.28724.dda67762bca5 +164 -0
- package/pg/nodeInputText/nodeInputText.css +75 -0
- package/pg/nodeInputText/nodeInputText.html +4 -0
- package/pg/nodeInputText/nodeInputText.ts +105 -0
- package/pg/nodeOutput/nodeOutput.css +32 -0
- package/pg/nodeResize/README.md +3 -0
- package/pg/nodeResize/THINKING.md +81 -0
- package/pg/nodeResize/THINKING.md.tmp.24812.99a70ba81062 +81 -0
- package/pg/nodeResize/basic/basic.ts +17 -0
- package/pg/nodeResize/dragUtil.ts +105 -0
- package/pg/nodeResize/dragUtil.ts.tmp.34372.787464c73309 +75 -0
- package/pg/nodeResize/nodeResize.css +187 -0
- package/pg/nodeResize/nodeResize.html +9 -0
- package/pg/nodeResize/nodeResize.ts +156 -0
- package/pg/nodes/README.md +177 -0
- package/pg/nodes/__examples__/basic/basic.html +33 -0
- package/pg/nodes/__examples__/basic/basic.ts +716 -0
- package/pg/nodes/__examples__/basic/exampleNodes.ts +129 -0
- package/pg/nodes/__examples__/basic/exampleScripts.ts +129 -0
- package/pg/nodes/__examples__/basic/keystore.ts +38 -0
- package/pg/nodes/executeInSandbox.ts +32 -0
- package/pg/nodes/index.ts +3 -0
- package/pg/nodes/nodes.css +69 -0
- package/pg/nodes/nodes.html +6 -0
- package/pg/nodes/nodes.ts +1240 -0
- package/pg/nodes copy/nodes.css +41 -0
- package/pg/nodes copy/nodes.html +1 -0
- package/pg/overlayContextMenu/__examples__/filter/filter.ts +87 -0
- package/pg/overlayContextMenu/overlayContextMenu.css +14 -0
- package/pg/overlayContextMenu/overlayContextMenu.html +4 -3
- package/pg/overlayContextMenu/overlayContextMenu.ts +6 -2
- package/pg/overlayContextMenu/overlayContextMenu.ts.tmp.37088.530ff1c0a321 +0 -0
- package/pg/overlayMenu/overlayMenu.css +3 -1
- package/pg/overlayMenu/overlayMenu.ts +11 -2
- package/pg/overlayMenu/overlayMenu.ts.tmp.44252.9bb22fd59ede +80 -0
- package/pg/overlaySelectMenu/overlaySelectMenu.css +2 -0
- package/pg/overlaySubMenu/overlaySubMenu.css +8 -6
- package/pg/poco/README.md +22 -0
- package/pg/poco/__examples__/basic/basic.html +11 -0
- package/pg/poco/__examples__/basic/basic.ts +95 -0
- package/pg/poco/__examples__/basic/examples.ts +258 -0
- package/pg/poco/__examples__/basic/myFont.ts +1300 -0
- package/pg/poco/index.ts +3 -0
- package/pg/poco/mockPoco.ts +640 -0
- package/pg/poco/poco.css +7 -0
- package/pg/poco/poco.html +1 -0
- package/pg/poco/poco.ts +75 -0
- package/pg/popover/README.md +47 -0
- package/pg/popover/__examples__/basic/basic.html +3 -0
- package/pg/popover/popover.html +3 -0
- package/pg/popover/popover.ts +44 -0
- package/pg/popoverAutocomplete/__examples__/basic/basic.html +4 -0
- package/pg/popoverAutocomplete/__examples__/basic/basic.ts +46 -0
- package/pg/popoverAutocomplete/popoverAutocomplete.css +25 -0
- package/pg/popoverAutocomplete/popoverAutocomplete.html +1 -0
- package/pg/popoverAutocomplete/popoverAutocomplete.ts +134 -0
- package/pg/popoverAutocompleteItem/popoverAutocompleteItem.css +69 -0
- package/pg/popoverAutocompleteItem/popoverAutocompleteItem.ts +90 -0
- package/pg/table/__examples__/basic/basic.ts +1 -0
- package/pg/tableCellFileLocal/tableCellFileLocal.html +3 -0
- package/pg/tableCellFileLocal/tableCellFileLocal.html.tmp.20484.68ee2e30710e +3 -0
- package/pg/tableCellFileLocal/tableCellFileLocal.ts +44 -0
- package/pg/tableCellSelect/tableCellSelect.html +3 -0
- package/pg/tableCellSelect/tableCellSelect.html.tmp.41808.99c1a6f14340 +3 -0
- package/pg/tableCellSelect/tableCellSelect.ts +51 -0
- package/pg/tree/__examples__/basic/basic.ts +12 -5
- package/pg/tree/tree.html +1 -1
- package/pg/tree/tree.ts +385 -227
- package/pg/tree/tree.ts.tmp.38376.07d376a04f41 +343 -0
- package/pg/tree/tree.ts.tmp.38376.2a04599ade9f +361 -0
- package/pg/tree/tree.ts.tmp.38376.6cb2c663d476 +0 -0
- package/pg/tree/tree.ts.tmp.38376.ac5af1aff2b0 +393 -0
- package/pg/tree/tree.ts.tmp.38376.ac9acfc4f95f +324 -0
- package/pg/treeItem/treeItem.ts +536 -558
- package/pg/treeItem/treeItem.ts.tmp.38376.145d3121d648 +530 -0
- package/pg/treeItem/treeItem.ts.tmp.38376.b5224d48e5c0 +0 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
export const demos = [
|
|
2
|
+
{
|
|
3
|
+
label: "fillRectangle",
|
|
4
|
+
detail: "poco.fillRectangle(color, x, y, w, h) — fills a solid rectangle.",
|
|
5
|
+
run({ poco }) {
|
|
6
|
+
const black = poco.makeColor(0, 0, 0);
|
|
7
|
+
const white = poco.makeColor(255, 255, 255);
|
|
8
|
+
poco.begin();
|
|
9
|
+
poco.fillRectangle(white, 0, 0, poco.width, poco.height);
|
|
10
|
+
const cols = 8, rows = 5, pw = 48, ph = 46;
|
|
11
|
+
for (let r = 0; r < rows; r++)
|
|
12
|
+
for (let c = 0; c < cols; c++) {
|
|
13
|
+
const color = ((r + c) % 2 === 0) ? black : white;
|
|
14
|
+
poco.fillRectangle(color, c * pw, r * ph, pw - 1, ph - 1);
|
|
15
|
+
}
|
|
16
|
+
poco.end();
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
label: "blendRectangle",
|
|
21
|
+
detail: "poco.blendRectangle(color, blend, x, y, w, h) — blends color over background. blend 0=transparent, 255=opaque.",
|
|
22
|
+
run({ poco }) {
|
|
23
|
+
const black = poco.makeColor(0, 0, 0);
|
|
24
|
+
const white = poco.makeColor(255, 255, 255);
|
|
25
|
+
poco.begin();
|
|
26
|
+
poco.fillRectangle(white, 0, 0, poco.width, poco.height);
|
|
27
|
+
const steps = 16;
|
|
28
|
+
const sw = Math.floor(poco.width / steps);
|
|
29
|
+
for (let i = 0; i < steps; i++) {
|
|
30
|
+
const blend = Math.round((i + 1) * (255 / steps));
|
|
31
|
+
poco.blendRectangle(black, blend, i * sw, 0, sw, poco.height);
|
|
32
|
+
}
|
|
33
|
+
poco.end();
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
label: "drawPixel",
|
|
38
|
+
detail: "poco.drawPixel(color, x, y) — draws one pixel at a time.",
|
|
39
|
+
run({ poco }) {
|
|
40
|
+
const black = poco.makeColor(0, 0, 0);
|
|
41
|
+
const white = poco.makeColor(255, 255, 255);
|
|
42
|
+
poco.begin();
|
|
43
|
+
poco.fillRectangle(white, 0, 0, poco.width, poco.height);
|
|
44
|
+
for (let i = 0; i < Math.min(poco.width, poco.height); i += 2)
|
|
45
|
+
poco.drawPixel(black, i, i);
|
|
46
|
+
for (let i = 0; i < 600; i++) {
|
|
47
|
+
const x = Math.floor(Math.random() * poco.width);
|
|
48
|
+
const y = Math.floor(Math.random() * poco.height);
|
|
49
|
+
poco.drawPixel(black, x, y);
|
|
50
|
+
}
|
|
51
|
+
poco.end();
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
label: "drawBitmap",
|
|
56
|
+
detail: "poco.drawBitmap(bits, x, y [,sx,sy,sw,sh]) — draws a full or partial bitmap.",
|
|
57
|
+
run({ poco, parseBMP, Resource }) {
|
|
58
|
+
const white = poco.makeColor(255, 255, 255);
|
|
59
|
+
const colorBitmap = parseBMP(new Resource("colorBitmap.bmp"));
|
|
60
|
+
poco.begin();
|
|
61
|
+
poco.fillRectangle(white, 0, 0, poco.width, poco.height);
|
|
62
|
+
poco.drawBitmap(colorBitmap, 10, 10);
|
|
63
|
+
poco.drawBitmap(colorBitmap, 70, 10, 0, 0, 20, 20);
|
|
64
|
+
for (let x = 0; x < poco.width; x += 42)
|
|
65
|
+
poco.drawBitmap(colorBitmap, x, poco.height - 42);
|
|
66
|
+
poco.end();
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
label: "drawMonochrome",
|
|
71
|
+
detail: "poco.drawMonochrome(bits, fore, back, x, y) — draws 1-bit bitmap with explicit fore/back colors (undefined = skip that layer).",
|
|
72
|
+
run({ poco, parseBMP, Resource }) {
|
|
73
|
+
const black = poco.makeColor(0, 0, 0);
|
|
74
|
+
const white = poco.makeColor(255, 255, 255);
|
|
75
|
+
const monoBitmap = parseBMP(new Resource("monoBitmap.bmp"));
|
|
76
|
+
poco.begin();
|
|
77
|
+
poco.fillRectangle(black, 0, 0, poco.width, poco.height);
|
|
78
|
+
poco.drawMonochrome(monoBitmap, black, white, 10, 10);
|
|
79
|
+
poco.drawMonochrome(monoBitmap, black, undefined, 60, 10);
|
|
80
|
+
poco.drawMonochrome(monoBitmap, undefined, black, 110, 10);
|
|
81
|
+
poco.drawMonochrome(monoBitmap, white, black, 160, 10);
|
|
82
|
+
poco.end();
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
label: "drawGray",
|
|
87
|
+
detail: "poco.drawGray(bits, color, x, y [,sx,sy,sw,sh,blend]) — pixel brightness as alpha, blending color onto background.",
|
|
88
|
+
run({ poco, parseBMP, Resource }) {
|
|
89
|
+
const black = poco.makeColor(0, 0, 0);
|
|
90
|
+
const white = poco.makeColor(255, 255, 255);
|
|
91
|
+
const grayBitmap = parseBMP(new Resource("grayBitmap.bmp"));
|
|
92
|
+
poco.begin();
|
|
93
|
+
poco.fillRectangle(white, 0, 0, poco.width, poco.height);
|
|
94
|
+
for (let i = 0; i < 5; i++) {
|
|
95
|
+
const blend = Math.round(((i + 1) / 5) * 255);
|
|
96
|
+
poco.drawGray(grayBitmap, black, 10 + i * 75, 20, 0, 0, 32, 32, blend);
|
|
97
|
+
}
|
|
98
|
+
poco.fillRectangle(black, 0, 110, poco.width, 60);
|
|
99
|
+
for (let i = 0; i < 5; i++) {
|
|
100
|
+
const blend = Math.round(((i + 1) / 5) * 255);
|
|
101
|
+
poco.drawGray(grayBitmap, white, 10 + i * 75, 114, 0, 0, 32, 32, blend);
|
|
102
|
+
}
|
|
103
|
+
poco.end();
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
label: "drawMasked",
|
|
108
|
+
detail: "poco.drawMasked(bits, x, y, sx, sy, sw, sh, mask, msx, msy [,blend]) — alpha-blends a bitmap through a gray-16 mask.",
|
|
109
|
+
run({ poco, parseBMP, Resource }) {
|
|
110
|
+
const black = poco.makeColor(0, 0, 0);
|
|
111
|
+
const white = poco.makeColor(255, 255, 255);
|
|
112
|
+
const colorBitmap = parseBMP(new Resource("colorBitmap.bmp"));
|
|
113
|
+
const circleMask = parseBMP(new Resource("circleMask.bmp"));
|
|
114
|
+
poco.begin();
|
|
115
|
+
poco.fillRectangle(white, 0, 0, poco.width, poco.height);
|
|
116
|
+
poco.drawMasked(colorBitmap, 10, 10, 0, 0, 40, 40, circleMask, 0, 0);
|
|
117
|
+
poco.drawMasked(colorBitmap, 60, 10, 0, 0, 40, 40, circleMask, 0, 0, 128);
|
|
118
|
+
poco.drawMasked(colorBitmap, 110, 10, 0, 0, 40, 40, circleMask, 0, 0, 64);
|
|
119
|
+
poco.fillRectangle(black, 0, 80, poco.width, 80);
|
|
120
|
+
poco.drawMasked(colorBitmap, 10, 90, 0, 0, 40, 40, circleMask, 0, 0);
|
|
121
|
+
poco.drawMasked(colorBitmap, 60, 90, 0, 0, 40, 40, circleMask, 0, 0, 180);
|
|
122
|
+
poco.end();
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
label: "fillPattern",
|
|
127
|
+
detail: "poco.fillPattern(bits, x, y, w, h [,sx,sy,sw,sh]) — tiles a bitmap region to fill an area.",
|
|
128
|
+
run({ poco, parseBMP, Resource }) {
|
|
129
|
+
const patternBitmap = parseBMP(new Resource("patternBitmap.bmp"));
|
|
130
|
+
poco.begin();
|
|
131
|
+
poco.fillPattern(patternBitmap, 0, 0, poco.width, poco.height);
|
|
132
|
+
poco.fillPattern(patternBitmap, 100, 60, 200, 120, 10, 10, 10, 10);
|
|
133
|
+
poco.end();
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
label: "drawText",
|
|
138
|
+
detail: "poco.drawText(text, font, color, x, y [,width]) — draws text using MyFont bitmap font; optional width truncates with '…'.",
|
|
139
|
+
run({ poco, parseBMF, parseBMP, Resource }) {
|
|
140
|
+
const black = poco.makeColor(0, 0, 0);
|
|
141
|
+
const white = poco.makeColor(255, 255, 255);
|
|
142
|
+
const myFont = parseBMF(new Resource("myFont.fnt"));
|
|
143
|
+
myFont.bitmap = parseBMP(new Resource("myFont.bmp"));
|
|
144
|
+
poco.begin();
|
|
145
|
+
poco.fillRectangle(black, 0, 0, poco.width, poco.height);
|
|
146
|
+
poco.drawText("Hello, Poco!", myFont, white, 10, 10);
|
|
147
|
+
poco.drawText("MyFont bitmap font.", myFont, black, 10, 10 + myFont.height + 4);
|
|
148
|
+
poco.fillRectangle(white, 0, 80, poco.width, 1);
|
|
149
|
+
poco.drawText("This text is too long to fit without truncation.", myFont, black, 10, 90, 195);
|
|
150
|
+
poco.drawText("Full width fits fine.", myFont, black, 10, 90 + myFont.height + 4, poco.width - 20);
|
|
151
|
+
poco.end();
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
label: "getTextWidth",
|
|
156
|
+
detail: "poco.getTextWidth(text, font) — measures pixel width using MyFont glyph metrics; used here to center and right-align strings.",
|
|
157
|
+
run({ poco, parseBMF, parseBMP, Resource }) {
|
|
158
|
+
const black = poco.makeColor(0, 0, 0);
|
|
159
|
+
const myFont = parseBMF(new Resource("myFont.fnt"));
|
|
160
|
+
myFont.bitmap = parseBMP(new Resource("myFont.bmp"));
|
|
161
|
+
poco.begin();
|
|
162
|
+
poco.fillRectangle(black, 0, 0, poco.width, poco.height);
|
|
163
|
+
poco.drawText("Top Left", myFont, black, 4, 4);
|
|
164
|
+
const trW = poco.getTextWidth("Top Right", myFont);
|
|
165
|
+
poco.drawText("Top Right", myFont, black, poco.width - 4 - trW, 4);
|
|
166
|
+
const cW = poco.getTextWidth("Center", myFont);
|
|
167
|
+
poco.drawText(
|
|
168
|
+
"Center",
|
|
169
|
+
myFont,
|
|
170
|
+
black,
|
|
171
|
+
Math.floor((poco.width - cW) / 2),
|
|
172
|
+
Math.floor((poco.height - myFont.height) / 2)
|
|
173
|
+
);
|
|
174
|
+
poco.drawText("Bottom Left", myFont, black, 4, poco.height - 4 - myFont.height);
|
|
175
|
+
const brW = poco.getTextWidth("Bottom Right", myFont);
|
|
176
|
+
poco.drawText("Bottom Right", myFont, black, poco.width - 4 - brW, poco.height - 4 - myFont.height);
|
|
177
|
+
poco.end();
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
label: "clip",
|
|
182
|
+
detail: "poco.clip(x,y,w,h) / poco.clip() — push/pop intersecting clip rectangles.",
|
|
183
|
+
run({ poco }) {
|
|
184
|
+
const black = poco.makeColor(0, 0, 0);
|
|
185
|
+
const white = poco.makeColor(255, 255, 255);
|
|
186
|
+
const gray = poco.makeColor(180, 180, 180);
|
|
187
|
+
poco.begin();
|
|
188
|
+
poco.fillRectangle(white, 0, 0, poco.width, poco.height);
|
|
189
|
+
poco.clip(20, 20, poco.width - 40, poco.height - 40);
|
|
190
|
+
poco.fillRectangle(gray, 0, 0, poco.width, poco.height);
|
|
191
|
+
poco.clip(20, 20, 160, 100);
|
|
192
|
+
poco.fillRectangle(black, 0, 0, poco.width, poco.height);
|
|
193
|
+
poco.clip();
|
|
194
|
+
poco.fillRectangle(black, poco.width / 2 - 1, 0, 2, poco.height);
|
|
195
|
+
poco.clip();
|
|
196
|
+
poco.fillRectangle(black, 0, 0, 18, poco.height);
|
|
197
|
+
poco.end();
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
label: "origin",
|
|
202
|
+
detail: "poco.origin(x,y) / poco.origin() — push/pop drawing origin offsets.",
|
|
203
|
+
run({ poco }) {
|
|
204
|
+
const black = poco.makeColor(0, 0, 0);
|
|
205
|
+
const white = poco.makeColor(255, 255, 255);
|
|
206
|
+
poco.begin();
|
|
207
|
+
poco.fillRectangle(white, 0, 0, poco.width, poco.height);
|
|
208
|
+
poco.origin(10, 10);
|
|
209
|
+
poco.fillRectangle(black, 0, 0, 60, 40);
|
|
210
|
+
poco.origin(70, 0);
|
|
211
|
+
poco.fillRectangle(black, 0, 0, 60, 40);
|
|
212
|
+
poco.origin(0, 50);
|
|
213
|
+
poco.fillRectangle(black, 0, 0, 60, 40);
|
|
214
|
+
poco.origin();
|
|
215
|
+
poco.origin();
|
|
216
|
+
poco.origin();
|
|
217
|
+
poco.fillRectangle(black, poco.width - 20, poco.height - 20, 20, 20);
|
|
218
|
+
poco.end();
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
// ToDo: support resizing images if someone requests this feature
|
|
222
|
+
// {
|
|
223
|
+
// label: "drawFrame",
|
|
224
|
+
// detail: "poco.drawFrame(frame, {width, height}, x, y) — renders a ColorCell compressed image (placeholder in this mock).",
|
|
225
|
+
// run({ poco }) {
|
|
226
|
+
// const white = poco.makeColor(255, 255, 255);
|
|
227
|
+
// poco.begin();
|
|
228
|
+
// poco.fillRectangle(white, 0, 0, poco.width, poco.height);
|
|
229
|
+
// poco.drawFrame(null, { width: 80, height: 60 }, 10, 10);
|
|
230
|
+
// poco.drawFrame(null, { width: 120, height: 80 }, 110, 10);
|
|
231
|
+
// poco.drawFrame(null, { width: 50, height: 50 }, 10, 80);
|
|
232
|
+
// poco.end();
|
|
233
|
+
// }
|
|
234
|
+
// },
|
|
235
|
+
{
|
|
236
|
+
label: "drawCharmander",
|
|
237
|
+
detail: "animates a charmander with 107 sprites",
|
|
238
|
+
run({ poco, parseBMP, Resource, Timer }) {
|
|
239
|
+
const white = poco.makeColor(200, 255, 255);
|
|
240
|
+
const charmander = parseBMP(new Resource("charmander.bmp"));
|
|
241
|
+
poco.begin();
|
|
242
|
+
poco.fillRectangle(white, 0, 0, poco.width, poco.height);
|
|
243
|
+
poco.drawBitmap(charmander, 10, 60);
|
|
244
|
+
poco.end();
|
|
245
|
+
let i = 0;
|
|
246
|
+
Timer.set(() => {
|
|
247
|
+
if (++i === 107) { i = 0; }
|
|
248
|
+
poco.begin();
|
|
249
|
+
poco.fillRectangle(white, 10, 10, 42, 42);
|
|
250
|
+
// src, x, y, sx, sy, sw, sh
|
|
251
|
+
const sx = (i % 10) * 42;
|
|
252
|
+
const sy = Math.floor((i / 10)) * 42;
|
|
253
|
+
poco.drawBitmap(charmander, 10, 10, sx, sy, 42, 42);
|
|
254
|
+
poco.end();
|
|
255
|
+
}, 40, 40);
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
];
|