Skip to content

Commit 79917fd

Browse files
committed
bump tools and pixel editor stuff
1 parent dba98e2 commit 79917fd

5 files changed

Lines changed: 99 additions & 16 deletions

File tree

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"devDependencies": {
2828
"@pictogrammers/element": "0.0.71",
29-
"@pictogrammers/element-esbuild": "^0.0.13",
29+
"@pictogrammers/element-esbuild": "^0.0.15",
3030
"@pictogrammers/element-jest": "^0.1.10",
3131
"cross-env": "^7.0.3",
3232
"npm-run-all": "^4.1.5",

src/components/pg/inputPixelEditor/README.md

Lines changed: 87 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,18 +167,20 @@ A complete JSON storage for a 10x10 image.
167167
There are currently 6 differnet layer types.
168168

169169
- `pixel` - Raster artboard of pixels.
170-
- `path` - pixels
171-
- `color` - colorIndex
170+
- `color: 0` - colorIndex
171+
- `path: ''` - pixels
172172
- `reference`
173-
- `id` - uuid of frame
173+
- `id: 'uuid'` - uuid of frame
174174
- `position: [x, y]`
175175
- `pattern` - Repeat an existing frame
176-
- `path` - pixels
177-
- `id` - uuid of frame
178-
- `offset [x, y]` - offset pattern
176+
- `id: 'uuid'` - uuid of frame
177+
- `position: [x, y]` - required
178+
- `size: [x, y]` - optional, size to clip at
179+
- `offset [x, y]` - optional, offset pattern
179180
- `linear` - Linear gradient.
180181
- `start: [x, y]`
181182
- `end: [x, y]`
183+
- `path: ''` - optional, mask
182184
- `stops: [[stop, colorIndex], [stop, colorIndex]]`
183185
- `dither: 'bayer4' | 'bayer8', 'bayer16'`
184186
- `radial` - Radial gradients.
@@ -188,8 +190,85 @@ There are currently 6 differnet layer types.
188190
- `stops: [[stop, colorIndex], [stop, colorIndex]]`
189191
- `dither: 'bayer4' | 'bayer8' | 'bayer16'`
190192
- `text` - Text, maybe???
191-
- `id` - file uuid
192-
- `value` - string
193+
- `id: 'uuid'` - file uuid
194+
- `value: ''` - string
195+
196+
### Layer `pixel` Type
197+
198+
The most common layer type.
199+
200+
```json
201+
{
202+
"data": [
203+
[
204+
[{ "color": 1, "path": "M...Z" }],
205+
[{ "color": 2, "path": "M...Z" }]
206+
]
207+
]
208+
}
209+
```
210+
211+
### Layer `reference` Type
212+
213+
Using an existing canvas in a design can be done with a reference layer.
214+
215+
```json
216+
{
217+
"data": [
218+
[{ "id": "uuid", "position": [0, 0] }]
219+
]
220+
}
221+
```
222+
223+
### Layer `pattern` Type
224+
225+
Using an existing canvas, but in a repeating pattern.
226+
227+
```json
228+
{
229+
"data": [
230+
[{ "id": "uuid", "position": [0, 0], "size": [100, 100] }],
231+
[{ "id": "uuid", "position": [0, 0], "offset": [0, -2] }]
232+
]
233+
}
234+
```
235+
236+
### Layer `linear` / `radial` Type
237+
238+
Linear and radial gradient between 2 points. Both allow a mask to be applied.
239+
240+
```json
241+
{
242+
"data": [
243+
[{ "id": "uuid", "start": [0, 0], "end": [100, 100] }],
244+
[{ "id": "uuid", "start": [0, 0], "end": [100, 0], "stops": [] }]
245+
]
246+
}
247+
```
248+
249+
### Layer `text` Type
250+
251+
Pull down a known font and use it as a reference.
252+
253+
```json
254+
{
255+
"data": [
256+
[{ "id": "uuid", "value": "Hello World!", "position": [0, 0] }],
257+
[{ "id": "uuid", "value": "Hello World!", "position": [0, 0], "wrap": 100 }]
258+
]
259+
}
260+
```
261+
262+
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.
263+
264+
```typescript
265+
this.$input.addEventListener('reference', (e: any) => {
266+
const { id, callback } = e.detail;
267+
if (id === 'uuid') {
268+
callback(file);
269+
}
270+
});
271+
```
193272

194273
## History
195274

src/components/pg/inputPixelEditor/__examples__/basic/basic.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ <h3>Color Tools <button part="addColor">Add Color</button></h3>
6666
<pg-table part="colors"></pg-table>
6767
</div>
6868
<div>
69-
<h3>Layer Tools <button part="addLayer">Add Layer</button></h3>
69+
<h3>Layer Tools&nbsp;<small>(inversed, lower index is a higher layer)</small> <button part="addLayer">Add Layer</button></h3>
7070
<pg-table part="layers"></table>
7171
</div>
7272
<div>

src/components/pg/inputPixelEditor/inputPixelEditor.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,10 +1370,14 @@ export default class PgInputPixelEditor extends HTMLElement {
13701370
}
13711371

13721372
/**
1373-
* Flatten layers, first index determines the color
1373+
* Flatten layers, always merges to lowest layer
1374+
* Note 0 is the lowest layer.
13741375
*/
13751376
flattenLayers(indexes: number[]) {
1376-
1377+
// ${x},${y} = [x, y, color]
1378+
const changedPixels = new Map<string, number[]>();
1379+
//this.#data[index]
1380+
// Update preview
13771381
}
13781382

13791383
getLayerColorIndexes(layerIndex = this.#layer[0]) {

0 commit comments

Comments
 (0)