@pictogrammers/components 0.4.9 → 0.5.1
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/annoy/annoy.css +1 -1
- package/pg/button/button.css +5 -4
- package/pg/buttonLink/buttonLink.css +1 -1
- package/pg/buttonMenu/__examples__/basic/basic.ts +2 -2
- package/pg/buttonMenu/buttonMenu.ts +4 -1
- package/pg/cardUser/cardUser.css +1 -1
- package/pg/database/__examples__/basic/basic.ts +0 -1
- package/pg/grid/__examples__/basic/basic.ts +1 -4
- package/pg/grid/grid.css +1 -1
- package/pg/header/header.css +1 -1
- package/pg/icon/__examples__/basic/basic.ts +1 -1
- package/pg/inputCheck/__examples__/basic/basic.ts +1 -1
- package/pg/inputCheck/inputCheck.css +5 -0
- package/pg/inputCheck/inputCheck.ts +4 -0
- package/pg/inputCheckList/__examples__/basic/basic.ts +1 -1
- package/pg/inputFileLocal/inputFileLocal.css +1 -1
- package/pg/inputNumber/README.md +27 -0
- package/pg/inputNumber/__examples__/basic/basic.html +9 -0
- package/pg/inputNumber/__examples__/basic/basic.ts +30 -0
- package/pg/inputNumber/inputNumber.css +34 -0
- package/pg/inputNumber/inputNumber.html +1 -0
- package/pg/inputNumber/inputNumber.spec.ts +59 -0
- package/pg/inputNumber/inputNumber.ts +63 -0
- package/pg/inputPixelEditor/README.md +212 -29
- package/pg/inputPixelEditor/__examples__/basic/basic.css +8 -0
- package/pg/inputPixelEditor/__examples__/basic/basic.html +29 -7
- package/pg/inputPixelEditor/__examples__/basic/basic.ts +274 -13
- package/pg/inputPixelEditor/__examples__/basic/constants.ts +62 -0
- package/pg/inputPixelEditor/inputPixelEditor.css +37 -2
- package/pg/inputPixelEditor/inputPixelEditor.html +22 -0
- package/pg/inputPixelEditor/inputPixelEditor.ts +826 -80
- package/pg/inputPixelEditor/utils/bitmapToMask.ts +22 -8
- package/pg/inputPixelEditor/utils/blobToImage.ts +11 -0
- package/pg/inputPixelEditor/utils/canvasToPngBuffer.ts +12 -0
- package/pg/inputPixelEditor/utils/constants.ts +55 -1
- package/pg/inputPixelEditor/utils/crc32.ts +116 -0
- package/pg/inputPixelEditor/utils/diffMap.ts +32 -0
- package/pg/inputPixelEditor/utils/generateGradient.ts +112 -0
- package/pg/inputPixelEditor/utils/getFloodFill.ts +83 -0
- package/pg/inputPixelEditor/utils/getGridColorIndexes.ts +13 -0
- package/pg/inputPixelEditor/utils/getOutline.ts +92 -0
- package/pg/inputPixelEditor/utils/inputMode.ts +7 -1
- package/pg/inputPixelEditor/utils/pixelSizes.ts +47 -0
- package/pg/inputPixelEditor/utils/pngMetadata.ts +487 -0
- package/pg/inputSelect/inputSelect.css +4 -4
- package/pg/inputText/inputText.css +14 -7
- package/pg/inputText/inputText.ts +5 -1
- package/pg/json/README.md +59 -0
- package/pg/json/__examples__/basic/basic.html +4 -0
- package/pg/json/__examples__/basic/basic.ts +31 -0
- package/pg/json/json.css +9 -0
- package/pg/json/json.html +1 -0
- package/pg/json/json.ts +124 -0
- package/pg/jsonArray/README.md +3 -0
- package/pg/jsonArray/jsonArray.css +15 -0
- package/pg/jsonArray/jsonArray.html +7 -0
- package/pg/jsonArray/jsonArray.ts +55 -0
- package/pg/jsonBoolean/README.md +3 -0
- package/pg/jsonBoolean/jsonBoolean.css +27 -0
- package/pg/jsonBoolean/jsonBoolean.html +5 -0
- package/pg/jsonBoolean/jsonBoolean.ts +69 -0
- package/pg/jsonNumber/README.md +3 -0
- package/pg/jsonNumber/jsonNumber.css +21 -0
- package/pg/jsonNumber/jsonNumber.html +5 -0
- package/pg/jsonNumber/jsonNumber.ts +42 -0
- package/pg/jsonObject/README.md +3 -0
- package/pg/jsonObject/jsonObject.css +11 -0
- package/pg/jsonObject/jsonObject.html +5 -0
- package/pg/jsonObject/jsonObject.ts +55 -0
- package/pg/jsonString/README.md +3 -0
- package/pg/jsonString/jsonString.css +21 -0
- package/pg/jsonString/jsonString.html +5 -0
- package/pg/jsonString/jsonString.ts +42 -0
- package/pg/menu/menu.ts +6 -5
- package/pg/menuItem/README.md +13 -2
- package/pg/menuItem/menuItem.css +17 -22
- package/pg/menuItem/menuItem.ts +8 -3
- package/pg/menuItemIcon/__examples__/basic/basic.html +1 -1
- package/pg/menuItemIcon/__examples__/basic/basic.ts +7 -0
- package/pg/menuItemIcon/menuItemIcon.css +18 -15
- package/pg/menuItemIcon/menuItemIcon.ts +8 -4
- package/pg/modification/__examples__/basic/basic.ts +1 -1
- package/pg/overlayMenu/overlayMenu.ts +6 -2
- package/pg/overlaySelectMenu/overlaySelectMenu.ts +6 -0
- package/pg/overlaySubMenu/overlaySubMenu.ts +6 -2
- package/pg/scroll/__examples__/basic/basic.ts +1 -1
- package/pg/search/search.css +1 -1
- package/pg/table/README.md +108 -0
- package/pg/table/__examples__/basic/basic.css +0 -0
- package/pg/table/__examples__/basic/basic.html +10 -0
- package/pg/table/__examples__/basic/basic.ts +111 -0
- package/pg/table/table.css +20 -0
- package/pg/table/table.html +6 -0
- package/pg/table/table.ts +86 -0
- package/pg/tableCellButtonIcon/README.md +3 -0
- package/pg/tableCellButtonIcon/tableCellButtonIcon.css +16 -0
- package/pg/tableCellButtonIcon/tableCellButtonIcon.html +5 -0
- package/pg/tableCellButtonIcon/tableCellButtonIcon.ts +34 -0
- package/pg/tableCellCheck/README.md +3 -0
- package/pg/tableCellCheck/tableCellCheck.css +15 -0
- package/pg/tableCellCheck/tableCellCheck.html +3 -0
- package/pg/tableCellCheck/tableCellCheck.ts +43 -0
- package/pg/tableCellNumber/README.md +3 -0
- package/pg/tableCellNumber/tableCellNumber.css +11 -0
- package/pg/tableCellNumber/tableCellNumber.html +3 -0
- package/pg/tableCellNumber/tableCellNumber.ts +40 -0
- package/pg/tableCellText/README.md +3 -0
- package/pg/tableCellText/tableCellText.css +11 -0
- package/pg/tableCellText/tableCellText.html +3 -0
- package/pg/tableCellText/tableCellText.ts +62 -0
- package/pg/tableColumn/README.md +3 -0
- package/pg/tableColumn/tableColumn.css +12 -0
- package/pg/tableColumn/tableColumn.html +1 -0
- package/pg/tableColumn/tableColumn.ts +29 -0
- package/pg/tableRow/README.md +3 -0
- package/pg/tableRow/tableRow.css +11 -0
- package/pg/tableRow/tableRow.html +1 -0
- package/pg/tableRow/tableRow.ts +77 -0
- package/pg/tabs/tabs.css +1 -1
- package/pg/tree/README.md +0 -3
- package/pg/tree/__examples__/basic/basic.ts +0 -1
- package/pg/treeItem/treeItem.css +3 -3
- package/favicon.svg +0 -20
- package/index.html +0 -321
- package/main.js +0 -2
- package/main.js.LICENSE.txt +0 -10
- package/pgAnnoy.js +0 -1
- package/pgApp.js +0 -1
- package/pgAvatar.js +0 -1
- package/pgButton.js +0 -1
- package/pgButtonGroup.js +0 -1
- package/pgButtonLink.js +0 -1
- package/pgButtonMenu.js +0 -1
- package/pgButtonToggle.js +0 -1
- package/pgCard.js +0 -1
- package/pgCardUser.js +0 -1
- package/pgColor.js +0 -1
- package/pgDatabase.js +0 -1
- package/pgDropdown.js +0 -1
- package/pgGrid.js +0 -1
- package/pgHeader.js +0 -1
- package/pgIcon.js +0 -1
- package/pgInputCheck.js +0 -1
- package/pgInputCheckList.js +0 -1
- package/pgInputFileLocal.js +0 -1
- package/pgInputHexRgb.js +0 -1
- package/pgInputPixelEditor.js +0 -1
- package/pgInputRange.js +0 -1
- package/pgInputSelect.js +0 -1
- package/pgInputText.js +0 -1
- package/pgInputTextIcon.js +0 -1
- package/pgInputUserSelect.js +0 -1
- package/pgListTag.js +0 -1
- package/pgMarkdown.js +0 -2
- package/pgMarkdown.js.LICENSE.txt +0 -10
- package/pgMenu.js +0 -1
- package/pgMenuDivider.js +0 -1
- package/pgMenuIcon.js +0 -1
- package/pgMenuItem.js +0 -1
- package/pgMenuItemIcon.js +0 -1
- package/pgModal.js +0 -1
- package/pgModalAlert.js +0 -1
- package/pgModification.js +0 -1
- package/pgNav.js +0 -1
- package/pgOverlay.js +0 -1
- package/pgOverlayContextMenu.js +0 -1
- package/pgOverlayMenu.js +0 -1
- package/pgOverlaySelectMenu.js +0 -1
- package/pgOverlaySubMenu.js +0 -1
- package/pgPicker.js +0 -1
- package/pgPreview.js +0 -1
- package/pgScroll.js +0 -1
- package/pgSearch.js +0 -1
- package/pgTab.js +0 -1
- package/pgTabs.js +0 -1
- package/pgToast.js +0 -1
- package/pgToasts.js +0 -1
- package/pgTooltip.js +0 -1
- package/pgTree.js +0 -1
- package/pgTreeButtonIcon.js +0 -1
- package/pgTreeItem.js +0 -1
|
@@ -4,7 +4,10 @@ The `pg-input-pixel-editor` component is used to edit images. Tailored for pen o
|
|
|
4
4
|
|
|
5
5
|
```typescript
|
|
6
6
|
import '@pictogrammers/components/pgInputPixelEditor';
|
|
7
|
-
import
|
|
7
|
+
import PgInputPixelEditor, {
|
|
8
|
+
InputMode,
|
|
9
|
+
LayerType,
|
|
10
|
+
} from '@pictogrammers/components/pgInputPixelEditor';
|
|
8
11
|
```
|
|
9
12
|
|
|
10
13
|
```html
|
|
@@ -23,10 +26,18 @@ import { PgInputPixelEditor } from '@pictogrammers/components/pgInputPixelEditor
|
|
|
23
26
|
|
|
24
27
|
## Events
|
|
25
28
|
|
|
26
|
-
| Events
|
|
27
|
-
|
|
|
28
|
-
| `change`
|
|
29
|
-
| `
|
|
29
|
+
| Events | Tested | Description |
|
|
30
|
+
| ----------- | -------- | ----------- |
|
|
31
|
+
| `change` | | `{ detail: { value }` |
|
|
32
|
+
| `reference` | | `{ detail: { id, callback } }` |
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
this.$input.addEventListener('reference', (e: any) => {
|
|
36
|
+
const { id, callback } = e.detail;
|
|
37
|
+
// async request
|
|
38
|
+
// callback(file: File)
|
|
39
|
+
});
|
|
40
|
+
```
|
|
30
41
|
|
|
31
42
|
## Methods
|
|
32
43
|
|
|
@@ -34,32 +45,62 @@ See usage for each method below.
|
|
|
34
45
|
|
|
35
46
|
| Method | Tested | Description |
|
|
36
47
|
| ---------- | -------- | ----------- |
|
|
37
|
-
| `
|
|
38
|
-
| `
|
|
48
|
+
| `getJson(options)` | - | Get JSON file. |
|
|
49
|
+
| `getData()` | - | Get layer data. |
|
|
50
|
+
| `setData()` | - | Set layer data. |
|
|
51
|
+
| `setJson(json)` | - | Set JSON file. |
|
|
52
|
+
| `reset()` | - | Reset canvas and data. |
|
|
53
|
+
| `getExportCanvas()` | - | Get new canvas of export. |
|
|
54
|
+
| `await getExportPng(options, meta)` | - | Get image. |
|
|
39
55
|
| `undo()` | - | Undo. |
|
|
40
56
|
| `hasUndo()` | - | Has undo |
|
|
41
57
|
| `hasRedo()` | - | Has redo |
|
|
42
58
|
| `redo()` | - | Redo. |
|
|
43
|
-
| `
|
|
59
|
+
| `getHistory()` | - | History list. |
|
|
60
|
+
| `inputModeSelectRectangle()` | - | Input Mode Select Rectangle |
|
|
61
|
+
| `inputModeSelectEllipse()` | - | Input Mode Select Ellipse |
|
|
62
|
+
| `inputModeSelectLasso()` | - | Input Mode Lasso |
|
|
63
|
+
| `inputModeSelectMagicWand()` | - | Input Mode Magic Wand |
|
|
64
|
+
| `inputModePixel()` | - | Input Mode Pixel |
|
|
65
|
+
| `inputModeStamp(stamp)` | - | Input Mode Stamp |
|
|
66
|
+
| `inputModeLine()` | - | Input Mode Line |
|
|
67
|
+
| `inputModeRectangle()` | - | Input Mode Rectangle |
|
|
68
|
+
| `inputModeRectangleOutline()` | - | Input Mode Rectangle Outline |
|
|
69
|
+
| `inputModeEllipse()` | - | Input Mode Ellipse |
|
|
70
|
+
| `inputModeEllipseOutline()` | - | Input Mode Ellipse Outline |
|
|
71
|
+
| `selectLayer(index)` | - | Select layer. |
|
|
44
72
|
| `getLayers()` | - | Get layer array. |
|
|
45
73
|
| `addLayer(option)` | - | Add layer. |
|
|
46
74
|
| `removeLayer(index)` | - | Remove layer. |
|
|
47
75
|
| `flattenLayers(layerIndexes)` | - | Flatten layers. |
|
|
48
|
-
| `
|
|
76
|
+
| `getColor()` | - | Get selected color |
|
|
49
77
|
| `getColors()` | - | Get colors. |
|
|
78
|
+
| `getLayerColorIndexes()` | - | Get selected layer colors. |
|
|
79
|
+
| `selectColor(index)` | - | Select color. |
|
|
80
|
+
| `setColor(index, r, g, b, a)` | - | Set Color. |
|
|
50
81
|
| `addColor(r, g, b, a)` | - | Add color. |
|
|
51
82
|
| `removeColor(index)` | - | Remove color. |
|
|
52
83
|
| `moveColor(startIndex, endIndex)` | - | Move index. |
|
|
53
84
|
| `rotateClockwise()` | - | Rotate. |
|
|
54
85
|
| `rotateCounterclockwise()` | - | Rotate. |
|
|
55
86
|
| `move(x, y[, layer])` | - | Move. |
|
|
56
|
-
| `
|
|
57
|
-
| `
|
|
87
|
+
| `getSelection()` | - | Get selection pixels. |
|
|
88
|
+
| `clearSelection()` | - | Clear selection. |
|
|
89
|
+
| `moveSelection(x, y)` | - | Move selection. |
|
|
90
|
+
| `flipHorizontal()` | - | Flip horizontal selection. |
|
|
91
|
+
| `flipVertical()` | - | Flip vertical selection. |
|
|
58
92
|
| `invert()` | - | Invert layer. |
|
|
93
|
+
| `outline()` | - | Outline layer with selected color. |
|
|
94
|
+
| `glow()` | - | Glow layer with selected color. |
|
|
95
|
+
| `drawPixels([[x, y, color], ...])` | - | Draw pixels. Color optional. |
|
|
96
|
+
| `drawRectangle(x, y, width, height, isOutline)` | - | Draw rectangle |
|
|
97
|
+
| `drawEllipse(x, y, width, height, isOutline)` | - | Draw ellipse. |
|
|
98
|
+
| `drawLine()` | - | Draw line. |
|
|
99
|
+
| `flush()` | - | Flush changes to history. |
|
|
59
100
|
|
|
60
|
-
### `
|
|
101
|
+
### `getJson(options)` Method
|
|
61
102
|
|
|
62
|
-
The
|
|
103
|
+
The `getJson` method allows getting the JSON representation of the current editor. Optionally this can snapshot the entire undo history. To get only data by layer call `getData()`.
|
|
63
104
|
|
|
64
105
|
```typescript
|
|
65
106
|
@Part() $editor: PgInputPixelEditor;
|
|
@@ -73,7 +114,7 @@ handleSave() {
|
|
|
73
114
|
}
|
|
74
115
|
```
|
|
75
116
|
|
|
76
|
-
### `
|
|
117
|
+
### `setJson(json)` Method
|
|
77
118
|
|
|
78
119
|
The open method allows loading json for previously created images.
|
|
79
120
|
|
|
@@ -88,11 +129,26 @@ handleOpen() {
|
|
|
88
129
|
}
|
|
89
130
|
```
|
|
90
131
|
|
|
132
|
+
## Events
|
|
133
|
+
|
|
134
|
+
### `change`
|
|
135
|
+
|
|
136
|
+
### `selectLayer`
|
|
137
|
+
|
|
138
|
+
Using `InputMode.Cursor` individual pixels can be clicked on to select the layer. Note, selecting a layer does not automatically select it. The event must be handled.
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
this.$input.addEventListener('selectlayer', (e: any) => {
|
|
142
|
+
const { color, index } = e.detail;
|
|
143
|
+
this.selectLayers([index]);
|
|
144
|
+
})
|
|
145
|
+
```
|
|
146
|
+
|
|
91
147
|
## JSON Format
|
|
92
148
|
|
|
93
149
|
- `width` - Image width.
|
|
94
150
|
- `height` - Image width.
|
|
95
|
-
- `transparent` -
|
|
151
|
+
- `transparent` - Override the transparent color. This has no impact on the exported background.
|
|
96
152
|
|
|
97
153
|
A complete JSON storage for a 10x10 image.
|
|
98
154
|
|
|
@@ -100,33 +156,160 @@ A complete JSON storage for a 10x10 image.
|
|
|
100
156
|
{
|
|
101
157
|
"width": 10,
|
|
102
158
|
"height": 10,
|
|
103
|
-
"
|
|
159
|
+
"gridSize": 10,
|
|
160
|
+
"transparent": null,
|
|
104
161
|
"colors": [
|
|
105
162
|
[0, 0, 0, 0],
|
|
106
|
-
[0, 0, 0, 1]
|
|
163
|
+
[0, 0, 0, 1],
|
|
164
|
+
[255, 255, 255, 1]
|
|
107
165
|
],
|
|
108
166
|
"layers": [
|
|
109
167
|
{
|
|
110
168
|
"name": "Layer 1",
|
|
111
|
-
"
|
|
169
|
+
"exclude": false,
|
|
112
170
|
"locked": false,
|
|
113
|
-
"
|
|
171
|
+
"hidden": false,
|
|
172
|
+
"type": "pixel",
|
|
114
173
|
"opacity": 1
|
|
115
174
|
}
|
|
116
175
|
],
|
|
117
176
|
"data": [
|
|
118
177
|
[
|
|
119
|
-
[
|
|
120
|
-
[
|
|
121
|
-
[0, 1, 0, 0, 0, 0, 0, 0, 1, 0],
|
|
122
|
-
[0, 1, 0, 0, 0, 0, 0, 0, 1, 0],
|
|
123
|
-
[0, 1, 0, 0, 0, 0, 0, 0, 1, 0],
|
|
124
|
-
[0, 1, 0, 0, 0, 0, 0, 0, 1, 0],
|
|
125
|
-
[0, 1, 0, 0, 0, 0, 0, 0, 1, 0],
|
|
126
|
-
[0, 1, 0, 0, 0, 0, 0, 0, 1, 0],
|
|
127
|
-
[0, 1, 1, 1, 1, 1, 1, 1, 1, 0],
|
|
128
|
-
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
178
|
+
[{ "color": 1, "path": "M...Z" }],
|
|
179
|
+
[{ "color": 2, "path": "M...Z" }]
|
|
129
180
|
]
|
|
181
|
+
],
|
|
182
|
+
"history": []
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Layer Type
|
|
187
|
+
|
|
188
|
+
There are currently 6 differnet layer types.
|
|
189
|
+
|
|
190
|
+
- `pixel` - Raster artboard of pixels.
|
|
191
|
+
- `color: 0` - colorIndex
|
|
192
|
+
- `path: ''` - pixels
|
|
193
|
+
- `reference`
|
|
194
|
+
- `id: 'uuid'` - uuid of frame
|
|
195
|
+
- `position: [x, y]`
|
|
196
|
+
- `pattern` - Repeat an existing frame
|
|
197
|
+
- `id: 'uuid'` - uuid of frame
|
|
198
|
+
- `position: [x, y]` - required
|
|
199
|
+
- `size: [x, y]` - optional, size to clip at
|
|
200
|
+
- `offset [x, y]` - optional, offset pattern
|
|
201
|
+
- `linear` - Linear gradient.
|
|
202
|
+
- `start: [x, y]`
|
|
203
|
+
- `end: [x, y]`
|
|
204
|
+
- `path: ''` - optional, mask
|
|
205
|
+
- `stops: [[stop, colorIndex], [stop, colorIndex]]`
|
|
206
|
+
- `dither: 'bayer4' | 'bayer8', 'bayer16'`
|
|
207
|
+
- `radial` - Radial gradients.
|
|
208
|
+
- `start: [x, y]`
|
|
209
|
+
- `end: [x, y]`
|
|
210
|
+
- `transform: [1, 0, 0, 0.5, 0, 0]` to create ellipses
|
|
211
|
+
- `stops: [[stop, colorIndex], [stop, colorIndex]]`
|
|
212
|
+
- `dither: 'bayer4' | 'bayer8' | 'bayer16'`
|
|
213
|
+
- `text` - Text, maybe???
|
|
214
|
+
- `id: 'uuid'` - file uuid
|
|
215
|
+
- `value: ''` - string
|
|
216
|
+
|
|
217
|
+
### Layer `pixel` Type
|
|
218
|
+
|
|
219
|
+
The most common layer type.
|
|
220
|
+
|
|
221
|
+
```json
|
|
222
|
+
{
|
|
223
|
+
"data": [
|
|
224
|
+
[
|
|
225
|
+
{ "color": 1, "path": "M...Z" },
|
|
226
|
+
{ "color": 2, "path": "M...Z" }
|
|
227
|
+
]
|
|
228
|
+
]
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Layer `reference` Type
|
|
233
|
+
|
|
234
|
+
Using an existing canvas in a design can be done with a reference layer.
|
|
235
|
+
|
|
236
|
+
```json
|
|
237
|
+
{
|
|
238
|
+
"data": [
|
|
239
|
+
[{ "id": "uuid", "position": [0, 0] }]
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Layer `pattern` Type
|
|
245
|
+
|
|
246
|
+
Using an existing canvas, but in a repeating pattern.
|
|
247
|
+
|
|
248
|
+
```json
|
|
249
|
+
{
|
|
250
|
+
"data": [
|
|
251
|
+
[{ "id": "uuid", "position": [0, 0], "size": [100, 100] }],
|
|
252
|
+
[{ "id": "uuid", "position": [0, 0], "offset": [0, -2] }]
|
|
253
|
+
]
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### Layer `linear` / `radial` Type
|
|
258
|
+
|
|
259
|
+
Linear and radial gradient between 2 points. Both allow a mask to be applied.
|
|
260
|
+
|
|
261
|
+
```json
|
|
262
|
+
{
|
|
263
|
+
"data": [
|
|
264
|
+
[{ "id": "uuid", "start": [0, 0], "end": [100, 100] }],
|
|
265
|
+
[{ "id": "uuid", "start": [0, 0], "end": [100, 0], "stops": [] }]
|
|
130
266
|
]
|
|
131
267
|
}
|
|
132
268
|
```
|
|
269
|
+
|
|
270
|
+
### Layer `text` Type
|
|
271
|
+
|
|
272
|
+
Pull down a known font and use it as a reference.
|
|
273
|
+
|
|
274
|
+
```json
|
|
275
|
+
{
|
|
276
|
+
"data": [
|
|
277
|
+
[{ "id": "uuid", "value": "Hello World!", "position": [0, 0] }],
|
|
278
|
+
[{ "id": "uuid", "value": "Hello World!", "position": [0, 0], "wrap": 100 }]
|
|
279
|
+
]
|
|
280
|
+
}
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
If a `id` is not found in the current file it will call the `reference` event. This event will need to return the found file to the `callback`. This could slow down initial project load.
|
|
284
|
+
|
|
285
|
+
```typescript
|
|
286
|
+
this.$input.addEventListener('reference', (e: any) => {
|
|
287
|
+
const { id, callback } = e.detail;
|
|
288
|
+
if (id === 'uuid') {
|
|
289
|
+
callback(file);
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
## History
|
|
295
|
+
|
|
296
|
+
The history list contains every change made to the canvas. All feature insert an entry into history. Pens and pattern tools will group as to cut down history entries.
|
|
297
|
+
|
|
298
|
+
Note: Calling the `draw*()` commands programatically will group into a single history item. To create multiple entries call `flush()`.
|
|
299
|
+
|
|
300
|
+
- Undo a change
|
|
301
|
+
- Redo an undo
|
|
302
|
+
- Timeline - Commonly used to generate progression clips. `getHistoryGif({ delay: 0.05 })` for instance generates a gif with 0.05 second delay between each change.
|
|
303
|
+
|
|
304
|
+
### History Format
|
|
305
|
+
|
|
306
|
+
For plugins or tools generating timelines the `getHistory()` returns an array with all entries. Note the `getHistoryPng(index)` is very CPU intensive and will recreate every change up to the index.
|
|
307
|
+
|
|
308
|
+
```json
|
|
309
|
+
[ // history
|
|
310
|
+
[ // history item
|
|
311
|
+
{}, // group
|
|
312
|
+
{}
|
|
313
|
+
]
|
|
314
|
+
]
|
|
315
|
+
```
|
|
@@ -29,10 +29,23 @@
|
|
|
29
29
|
<button part="reset">Reset</button>
|
|
30
30
|
<button part="clear">Clear</button>
|
|
31
31
|
<button part="invert">Invert</button>
|
|
32
|
+
<button part="outline">Outline</button>
|
|
33
|
+
<button part="glow">Glow</button>
|
|
34
|
+
|
|
|
35
|
+
<button part="undo">Undo</button>
|
|
36
|
+
<button part="redo">Redo</button>
|
|
32
37
|
|
|
|
33
38
|
<button part="save">Save</button>
|
|
34
39
|
<button part="open">Open</button>
|
|
35
40
|
</div>
|
|
41
|
+
<div>
|
|
42
|
+
<h3>Selection Tools</h3>
|
|
43
|
+
<button part="cursor">Cursor</button>
|
|
44
|
+
<button part="selectRectangle">Select Rectangle</button>
|
|
45
|
+
<button part="selectEllipse">Select Circle</button>
|
|
46
|
+
<button part="selectLasso">Select Lasso</button>
|
|
47
|
+
<button part="selectMagic">Select Magic Wand</button>
|
|
48
|
+
</div>
|
|
36
49
|
<div>
|
|
37
50
|
<h3>Drawing Tools</h3>
|
|
38
51
|
<button part="modePixel">Pixel</button>
|
|
@@ -43,20 +56,29 @@
|
|
|
43
56
|
<button part="modeEllipseOutline">Ellipse Outline</button>
|
|
44
57
|
</div>
|
|
45
58
|
<div>
|
|
46
|
-
|
|
47
|
-
<button part="
|
|
48
|
-
<
|
|
59
|
+
Stamps:
|
|
60
|
+
<button part="modeStamp1" data-stamp="1">1 Pixel</button>
|
|
61
|
+
<button part="modeStamp2" data-stamp="3-circle">3 Pixel Circle</button>
|
|
62
|
+
<button part="modeStamp3" data-stamp="3-square">3 Pixel Square</button>
|
|
63
|
+
<button part="modeStamp4" data-stamp="heart">Heart</button>
|
|
64
|
+
</div>
|
|
65
|
+
<div>
|
|
66
|
+
<h3>Color Tools <button part="addColor">Add Color</button></h3>
|
|
67
|
+
<pg-table part="colors"></pg-table>
|
|
49
68
|
</div>
|
|
50
69
|
<div>
|
|
51
|
-
<h3>Layer Tools</h3>
|
|
52
|
-
<
|
|
53
|
-
|
|
70
|
+
<h3>Layer Tools <small>(inversed, lower index is a higher layer)</small></h3>
|
|
71
|
+
<div>
|
|
72
|
+
<button part="addLayer">Add Pixel Layer</button>
|
|
73
|
+
<button part="addLayerReference">Add Reference Layer</button>
|
|
74
|
+
</div>
|
|
75
|
+
<pg-table part="layers"></table>
|
|
54
76
|
</div>
|
|
55
77
|
<div>
|
|
56
78
|
<h3>Example Tools</h3>
|
|
57
79
|
<input part="file" type="file" />
|
|
58
80
|
<button part="saveSvg">Save SVG</button>
|
|
59
|
-
<button part="savePng">Save
|
|
81
|
+
<button part="savePng">Save PNG</button>
|
|
60
82
|
</div>
|
|
61
83
|
<div part="debug"></div>
|
|
62
84
|
<pre part="output" contenteditable></pre>
|