@pictogrammers/components 0.4.8 → 0.5.0
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 +211 -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 +822 -82
- 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/getEllipsePixels.ts +131 -19
- 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/modal/README.md +29 -0
- package/pg/modal/__examples__/basic/basic.html +4 -0
- package/pg/modal/__examples__/basic/basic.ts +42 -0
- package/pg/modal/index.ts +3 -0
- package/pg/modal/modal.css +40 -0
- package/pg/modal/modal.html +9 -0
- package/pg/modal/modal.ts +14 -0
- 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 +10 -4
- package/pg/tree/__examples__/basic/basic.html +1 -0
- package/pg/tree/__examples__/basic/basic.ts +6 -1
- package/pg/tree/tree.css +1 -0
- 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/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,61 @@ 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
|
+
| `setJson(json)` | - | Set JSON file. |
|
|
51
|
+
| `reset()` | - | Reset canvas and data. |
|
|
52
|
+
| `getExportCanvas()` | - | Get new canvas of export. |
|
|
53
|
+
| `await getExportPng(options, meta)` | - | Get image. |
|
|
39
54
|
| `undo()` | - | Undo. |
|
|
40
55
|
| `hasUndo()` | - | Has undo |
|
|
41
56
|
| `hasRedo()` | - | Has redo |
|
|
42
57
|
| `redo()` | - | Redo. |
|
|
43
|
-
| `
|
|
58
|
+
| `getHistory()` | - | History list. |
|
|
59
|
+
| `inputModeSelectRectangle()` | - | Input Mode Select Rectangle |
|
|
60
|
+
| `inputModeSelectEllipse()` | - | Input Mode Select Ellipse |
|
|
61
|
+
| `inputModeSelectLasso()` | - | Input Mode Lasso |
|
|
62
|
+
| `inputModeSelectMagicWand()` | - | Input Mode Magic Wand |
|
|
63
|
+
| `inputModePixel()` | - | Input Mode Pixel |
|
|
64
|
+
| `inputModeStamp(stamp)` | - | Input Mode Stamp |
|
|
65
|
+
| `inputModeLine()` | - | Input Mode Line |
|
|
66
|
+
| `inputModeRectangle()` | - | Input Mode Rectangle |
|
|
67
|
+
| `inputModeRectangleOutline()` | - | Input Mode Rectangle Outline |
|
|
68
|
+
| `inputModeEllipse()` | - | Input Mode Ellipse |
|
|
69
|
+
| `inputModeEllipseOutline()` | - | Input Mode Ellipse Outline |
|
|
70
|
+
| `selectLayer(index)` | - | Select layer. |
|
|
44
71
|
| `getLayers()` | - | Get layer array. |
|
|
45
72
|
| `addLayer(option)` | - | Add layer. |
|
|
46
73
|
| `removeLayer(index)` | - | Remove layer. |
|
|
47
74
|
| `flattenLayers(layerIndexes)` | - | Flatten layers. |
|
|
48
|
-
| `
|
|
75
|
+
| `getColor()` | - | Get selected color |
|
|
49
76
|
| `getColors()` | - | Get colors. |
|
|
77
|
+
| `getLayerColorIndexes()` | - | Get selected layer colors. |
|
|
78
|
+
| `selectColor(index)` | - | Select color. |
|
|
79
|
+
| `setColor(index, r, g, b, a)` | - | Set Color. |
|
|
50
80
|
| `addColor(r, g, b, a)` | - | Add color. |
|
|
51
81
|
| `removeColor(index)` | - | Remove color. |
|
|
52
82
|
| `moveColor(startIndex, endIndex)` | - | Move index. |
|
|
53
83
|
| `rotateClockwise()` | - | Rotate. |
|
|
54
84
|
| `rotateCounterclockwise()` | - | Rotate. |
|
|
55
85
|
| `move(x, y[, layer])` | - | Move. |
|
|
56
|
-
| `
|
|
57
|
-
| `
|
|
86
|
+
| `getSelection()` | - | Get selection pixels. |
|
|
87
|
+
| `clearSelection()` | - | Clear selection. |
|
|
88
|
+
| `moveSelection(x, y)` | - | Move selection. |
|
|
89
|
+
| `flipHorizontal()` | - | Flip horizontal selection. |
|
|
90
|
+
| `flipVertical()` | - | Flip vertical selection. |
|
|
58
91
|
| `invert()` | - | Invert layer. |
|
|
92
|
+
| `outline()` | - | Outline layer with selected color. |
|
|
93
|
+
| `glow()` | - | Glow layer with selected color. |
|
|
94
|
+
| `drawPixels([[x, y, color], ...])` | - | Draw pixels. Color optional. |
|
|
95
|
+
| `drawRectangle(x, y, width, height, isOutline)` | - | Draw rectangle |
|
|
96
|
+
| `drawEllipse(x, y, width, height, isOutline)` | - | Draw ellipse. |
|
|
97
|
+
| `drawLine()` | - | Draw line. |
|
|
98
|
+
| `flush()` | - | Flush changes to history. |
|
|
59
99
|
|
|
60
|
-
### `
|
|
100
|
+
### `getJson(options)` Method
|
|
61
101
|
|
|
62
|
-
The
|
|
102
|
+
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
103
|
|
|
64
104
|
```typescript
|
|
65
105
|
@Part() $editor: PgInputPixelEditor;
|
|
@@ -73,7 +113,7 @@ handleSave() {
|
|
|
73
113
|
}
|
|
74
114
|
```
|
|
75
115
|
|
|
76
|
-
### `
|
|
116
|
+
### `setJson(json)` Method
|
|
77
117
|
|
|
78
118
|
The open method allows loading json for previously created images.
|
|
79
119
|
|
|
@@ -88,11 +128,26 @@ handleOpen() {
|
|
|
88
128
|
}
|
|
89
129
|
```
|
|
90
130
|
|
|
131
|
+
## Events
|
|
132
|
+
|
|
133
|
+
### `change`
|
|
134
|
+
|
|
135
|
+
### `selectLayer`
|
|
136
|
+
|
|
137
|
+
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.
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
this.$input.addEventListener('selectlayer', (e: any) => {
|
|
141
|
+
const { color, index } = e.detail;
|
|
142
|
+
this.selectLayers([index]);
|
|
143
|
+
})
|
|
144
|
+
```
|
|
145
|
+
|
|
91
146
|
## JSON Format
|
|
92
147
|
|
|
93
148
|
- `width` - Image width.
|
|
94
149
|
- `height` - Image width.
|
|
95
|
-
- `transparent` -
|
|
150
|
+
- `transparent` - Override the transparent color. This has no impact on the exported background.
|
|
96
151
|
|
|
97
152
|
A complete JSON storage for a 10x10 image.
|
|
98
153
|
|
|
@@ -100,33 +155,160 @@ A complete JSON storage for a 10x10 image.
|
|
|
100
155
|
{
|
|
101
156
|
"width": 10,
|
|
102
157
|
"height": 10,
|
|
103
|
-
"
|
|
158
|
+
"gridSize": 10,
|
|
159
|
+
"transparent": null,
|
|
104
160
|
"colors": [
|
|
105
161
|
[0, 0, 0, 0],
|
|
106
|
-
[0, 0, 0, 1]
|
|
162
|
+
[0, 0, 0, 1],
|
|
163
|
+
[255, 255, 255, 1]
|
|
107
164
|
],
|
|
108
165
|
"layers": [
|
|
109
166
|
{
|
|
110
167
|
"name": "Layer 1",
|
|
111
|
-
"
|
|
168
|
+
"exclude": false,
|
|
112
169
|
"locked": false,
|
|
113
|
-
"
|
|
170
|
+
"hidden": false,
|
|
171
|
+
"type": "pixel",
|
|
114
172
|
"opacity": 1
|
|
115
173
|
}
|
|
116
174
|
],
|
|
117
175
|
"data": [
|
|
118
176
|
[
|
|
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]
|
|
177
|
+
[{ "color": 1, "path": "M...Z" }],
|
|
178
|
+
[{ "color": 2, "path": "M...Z" }]
|
|
129
179
|
]
|
|
180
|
+
],
|
|
181
|
+
"history": []
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Layer Type
|
|
186
|
+
|
|
187
|
+
There are currently 6 differnet layer types.
|
|
188
|
+
|
|
189
|
+
- `pixel` - Raster artboard of pixels.
|
|
190
|
+
- `color: 0` - colorIndex
|
|
191
|
+
- `path: ''` - pixels
|
|
192
|
+
- `reference`
|
|
193
|
+
- `id: 'uuid'` - uuid of frame
|
|
194
|
+
- `position: [x, y]`
|
|
195
|
+
- `pattern` - Repeat an existing frame
|
|
196
|
+
- `id: 'uuid'` - uuid of frame
|
|
197
|
+
- `position: [x, y]` - required
|
|
198
|
+
- `size: [x, y]` - optional, size to clip at
|
|
199
|
+
- `offset [x, y]` - optional, offset pattern
|
|
200
|
+
- `linear` - Linear gradient.
|
|
201
|
+
- `start: [x, y]`
|
|
202
|
+
- `end: [x, y]`
|
|
203
|
+
- `path: ''` - optional, mask
|
|
204
|
+
- `stops: [[stop, colorIndex], [stop, colorIndex]]`
|
|
205
|
+
- `dither: 'bayer4' | 'bayer8', 'bayer16'`
|
|
206
|
+
- `radial` - Radial gradients.
|
|
207
|
+
- `start: [x, y]`
|
|
208
|
+
- `end: [x, y]`
|
|
209
|
+
- `transform: [1, 0, 0, 0.5, 0, 0]` to create ellipses
|
|
210
|
+
- `stops: [[stop, colorIndex], [stop, colorIndex]]`
|
|
211
|
+
- `dither: 'bayer4' | 'bayer8' | 'bayer16'`
|
|
212
|
+
- `text` - Text, maybe???
|
|
213
|
+
- `id: 'uuid'` - file uuid
|
|
214
|
+
- `value: ''` - string
|
|
215
|
+
|
|
216
|
+
### Layer `pixel` Type
|
|
217
|
+
|
|
218
|
+
The most common layer type.
|
|
219
|
+
|
|
220
|
+
```json
|
|
221
|
+
{
|
|
222
|
+
"data": [
|
|
223
|
+
[
|
|
224
|
+
{ "color": 1, "path": "M...Z" },
|
|
225
|
+
{ "color": 2, "path": "M...Z" }
|
|
226
|
+
]
|
|
227
|
+
]
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Layer `reference` Type
|
|
232
|
+
|
|
233
|
+
Using an existing canvas in a design can be done with a reference layer.
|
|
234
|
+
|
|
235
|
+
```json
|
|
236
|
+
{
|
|
237
|
+
"data": [
|
|
238
|
+
[{ "id": "uuid", "position": [0, 0] }]
|
|
239
|
+
]
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Layer `pattern` Type
|
|
244
|
+
|
|
245
|
+
Using an existing canvas, but in a repeating pattern.
|
|
246
|
+
|
|
247
|
+
```json
|
|
248
|
+
{
|
|
249
|
+
"data": [
|
|
250
|
+
[{ "id": "uuid", "position": [0, 0], "size": [100, 100] }],
|
|
251
|
+
[{ "id": "uuid", "position": [0, 0], "offset": [0, -2] }]
|
|
252
|
+
]
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Layer `linear` / `radial` Type
|
|
257
|
+
|
|
258
|
+
Linear and radial gradient between 2 points. Both allow a mask to be applied.
|
|
259
|
+
|
|
260
|
+
```json
|
|
261
|
+
{
|
|
262
|
+
"data": [
|
|
263
|
+
[{ "id": "uuid", "start": [0, 0], "end": [100, 100] }],
|
|
264
|
+
[{ "id": "uuid", "start": [0, 0], "end": [100, 0], "stops": [] }]
|
|
130
265
|
]
|
|
131
266
|
}
|
|
132
267
|
```
|
|
268
|
+
|
|
269
|
+
### Layer `text` Type
|
|
270
|
+
|
|
271
|
+
Pull down a known font and use it as a reference.
|
|
272
|
+
|
|
273
|
+
```json
|
|
274
|
+
{
|
|
275
|
+
"data": [
|
|
276
|
+
[{ "id": "uuid", "value": "Hello World!", "position": [0, 0] }],
|
|
277
|
+
[{ "id": "uuid", "value": "Hello World!", "position": [0, 0], "wrap": 100 }]
|
|
278
|
+
]
|
|
279
|
+
}
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
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.
|
|
283
|
+
|
|
284
|
+
```typescript
|
|
285
|
+
this.$input.addEventListener('reference', (e: any) => {
|
|
286
|
+
const { id, callback } = e.detail;
|
|
287
|
+
if (id === 'uuid') {
|
|
288
|
+
callback(file);
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
## History
|
|
294
|
+
|
|
295
|
+
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.
|
|
296
|
+
|
|
297
|
+
Note: Calling the `draw*()` commands programatically will group into a single history item. To create multiple entries call `flush()`.
|
|
298
|
+
|
|
299
|
+
- Undo a change
|
|
300
|
+
- Redo an undo
|
|
301
|
+
- Timeline - Commonly used to generate progression clips. `getHistoryGif({ delay: 0.05 })` for instance generates a gif with 0.05 second delay between each change.
|
|
302
|
+
|
|
303
|
+
### History Format
|
|
304
|
+
|
|
305
|
+
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.
|
|
306
|
+
|
|
307
|
+
```json
|
|
308
|
+
[ // history
|
|
309
|
+
[ // history item
|
|
310
|
+
{}, // group
|
|
311
|
+
{}
|
|
312
|
+
]
|
|
313
|
+
]
|
|
314
|
+
```
|
|
@@ -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>
|