@pixerate/editor 0.103.0 → 0.104.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor",
3
- "version": "0.103.0",
3
+ "version": "0.104.0",
4
4
  "description": "UI-agnostic rich text and media editing core library",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -172,8 +172,9 @@ batching.
172
172
  ### Photoshop files
173
173
 
174
174
  1. **Inspect before opening.** `inspect_psd` lists every layer with the type it would become and
175
- a status: `mapped` (held exactly), `approximated` (type, smart-object, fill and shape layers
176
- come in as their stored pixels; Dissolve becomes Normal; effects with gradient midpoints or
175
+ a status: `mapped` (held exactly), `approximated` (type, fill and shape layers come in as their
176
+ stored pixels; linked smart objects as their stored pixels; Photoshop smart filters other than
177
+ Box Blur are kept but not drawn; Dissolve becomes Normal; effects with gradient midpoints or
177
178
  smoothness, noise gradients, glow jitter, legacy bevels or patterns missing from the file are
178
179
  drawn approximately) or
179
180
  `dropped` (Brightness/Contrast, Exposure, Channel Mixer, Gradient Map, Selective Color and
@@ -187,12 +188,20 @@ batching.
187
188
  and 32-bit files are converted to 8-bit RGB, and ICC profiles are ignored; the warnings say
188
189
  so. Afterwards work with `list_layers` as usual: there is no Background source image, every
189
190
  pixel comes from the layers.
190
- 4. **`export_psd` writes the stack as it is**, in the source frame: crop and rotation are not
191
+ 4. **Smart objects come in live**: embedded contents (a PSB opens as a nested document you can
192
+ edit with `edit_smart_object_contents`, a PNG as raster contents), the placement and warp, the
193
+ smart filters and the filter mask; the layer shows Photoshop's own pixels until you change it.
194
+ JPEG, TIFF and SVG contents are decoded only in a browser, so elsewhere such a smart object
195
+ cannot be transformed (the error says so). Photoshop filters we do not model stay in the list
196
+ (kind `psd`): hide, reorder, re-blend or remove them, and `export_psd` writes them back.
197
+ 5. **`export_psd` writes the stack as it is**, in the source frame: crop and rotation are not
191
198
  applied, layer filters and depth masks are baked, annotation layers are rasterized (only in
192
199
  a browser). Effects are written as Photoshop layer styles: an effects block opened from a PSD
193
200
  goes back byte for byte while its effects are unchanged, and the patterns effects use (the
194
201
  built-in ones too) are embedded. Only the first outer glow, inner glow, bevel, satin and
195
- pattern overlay of a layer fit in a PSD. Read its `warnings` and pass them on. The file comes back as base64 (`data`).
202
+ pattern overlay of a layer fit in a PSD. Smart objects are written as smart objects (an
203
+ unchanged one byte for byte); a Develop smart filter has no Photoshop filter and is left out of
204
+ the list (the pixels still show it). Read its `warnings` and pass them on. The file comes back as base64 (`data`).
196
205
 
197
206
  ## Best practices
198
207
 
@@ -277,7 +286,7 @@ batching.
277
286
  | `get_image_info` | Read the geometry: source `image` size, `crop` box (source pixels, or null), `rotation` degrees, `flipH` / `flipV`, the `output` size after crop and rotation, the layer count and `canUndo` / `canRedo`. Call before cropping or selecting so coordinates are right. |
278
287
  | `get_histogram` | Judge exposure numerically: per channel and luminance `mean`, `p1` and `p99` (0..255), and `clipping` percent at pure black and white per channel. Reads the last render, so call `render_preview` first. `bins` (16, 32, 64 or 256) adds the counts. Cheaper than another image for checking a tonal change. |
279
288
  | `render_preview` | See the edited image (crop, adjustments, layers, annotations) as a PNG, or with `layerId` one layer alone. `maxSide` 16..2048 px, default 512. Images cost tokens: render after a group of edits, use 512 for overall look and 1024+ to judge clipping, edges and masks. Fails in environments without rendering. |
280
- | `inspect_psd` | Read a PSD / PSB (`data` base64) without opening it: size, `depth`, `colorMode`, `resolution`, every layer bottom first with `psdKind`, the `type` it would become and `status` (`mapped`, `approximated`, `dropped`) with `notes`, and the import `warnings`. Call before `import_psd`. |
289
+ | `inspect_psd` | Read a PSD / PSB (`data` base64) without opening it: size, `depth`, `colorMode`, `resolution`, every layer bottom first with `psdKind`, the `type` it would become (`smart` for smart objects) and `status` (`mapped`, `approximated`, `dropped`) with `notes`, and the import `warnings`. Call before `import_psd`. |
281
290
  | `export_psd` | Save the document as an 8-bit RGB PSD (PSB above 30000 px) with layers, groups, adjustment layers and masks. Returns `data` (base64), `size` in bytes, `psb` and `warnings` (crop or rotation not applied, filters and depth masks baked, annotations rasterized or left out, Pigment blends written as Normal). Changes nothing. |
282
291
  | `get_transform_frame` | Before a transform: what it would move (`content`, `moved`: pixels, mask, selection), its `frame` (document bounds of the content), `corners` (top-left, top-right, bottom-right, bottom-left) and `center`. `meshColumns` / `meshRows` also return an identity warp `mesh` over the frame to edit for `warp_layer`. Changes nothing. |
283
292
  | `get_smart_object` | Read a smart object: `contents` (`id` shared by linked instances, `name`, `kind` raster or document, `width` / `height`, `decoded`, `fileType`, `linkedPath`, `instances`), `placement` (`corners`, `warp` in contents px, `interpolation`, and when `affine` the `scaleX` / `scaleY` in percent of the contents, `rotate`, `skewX`, `center`, `bounds`) and `smartFilters` (`enabled`, `filters` bottom to top with ids, settings, `blend`, `opacity`; kind `psd` is a Photoshop filter kept but not drawn; the filter `mask`). Call before changing a smart object. |
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: pixerate-paint-editor
3
- description: How to make a picture in the Pixerate paint editor (natural media in the spirit of Painter and Rebelle) through its agent tools - canvas and paper (generated grain, depth, colour, families from cold pressed watercolour to canvas and gesso), layers, dry-media brushes (pencil, pastel, charcoal, airbrush, marker, ink, erasers, blender, smudge, Mixer Brush) with pressure, tilt, barrel rotation and velocity, the brush library, strokes as data that replay and vary, pigment colour mixing, previews and PNG, JPEG, WebP, PSD and JSON output. Use when asked to paint, sketch, draw, shade, block in, texture a layer with paper grain, mix paint colours, vary or repeat strokes, or when paint_stroke, set_paper, list_brushes, replay_strokes, fill_layer or mix_colors are available.
3
+ description: How to make a picture in the Pixerate paint editor (natural media in the spirit of Painter and Rebelle) through its agent tools - canvas and paper (generated grain, depth, colour, families from cold pressed watercolour to canvas and gesso), layers, dry-media brushes (pencil, pastel, charcoal, airbrush, marker, ink, erasers, blender, smudge, Mixer Brush) with pressure, tilt, barrel rotation and velocity, the brush library, strokes as data that replay and vary, mirror and kaleidoscope painting, perspective guides, tracing and reference images, colour harmonies, swatches, a mixing pad and pigment mixing, previews and PNG, JPEG, WebP, PSD and JSON output. Use when asked to paint, sketch, draw, shade, block in, texture with paper grain, mix colours, paint symmetric or in perspective, trace an image, or when paint_stroke, set_paper, replay_strokes, set_symmetry or mix_colors are available.
4
4
  ---
5
5
 
6
6
  # Paint editor
@@ -21,6 +21,10 @@ is never part of a layer. Coordinates are document pixels, (0, 0) top-left, y do
21
21
  - **Strokes are data.** Every stroke is recorded (brush, colour, raw points, seed, symmetry
22
22
  copies) and gets a `strokeId`. `replay_strokes` paints recorded strokes again, exactly or
23
23
  varied. That is the main way an agent should make many similar marks.
24
+ - **Guides** are editor state saved with the document: a symmetry guide makes every stroke paint
25
+ its mirror or kaleidoscope copies (one stroke), a perspective guide snaps strokes to lines
26
+ towards one to three vanishing points, a tracing image sits under the paint (never exported)
27
+ and can supply stroke colours, and reference images float beside the canvas to pick from.
24
28
  - **Undo**: one tool call that changes the painting is one undo step (`undo_paint`). Brush,
25
29
  colour, view, hand and the Mixer Brush load are editor state, not undo steps.
26
30
 
@@ -36,17 +40,25 @@ is never part of a layer. Coordinates are document pixels, (0, 0) top-left, y do
36
40
  `fill_layer` gives a ground colour (flat) or a tonal layer that catches the grain
37
41
  (`grain` 0.6..1, `pressure` 0.2..0.6). Paint large masses with a big soft pastel or airbrush
38
42
  in a few long `paint_stroke`s rather than many small ones.
39
- 4. **Mix colours before painting.** `mix_colors` predicts what paints mixed in given parts look
40
- like (Kubelka-Munk: blue and yellow make green, white tints rather than greys). Use the result
41
- as the stroke `color`. `set_color` makes it the default.
43
+ 4. **Plan and mix colours before painting.** `color_harmony` gives a palette around a key colour
44
+ (on the painter's red-yellow-blue wheel by default). `mix_colors` predicts what paints mixed
45
+ in given parts look like (Kubelka-Munk: blue and yellow make green, white tints rather than
46
+ greys); the mixing pad (`mixing_pad_stroke`, `pick_mixing_pad_color`) mixes by hand with a
47
+ palette knife. Keep chosen colours as swatches (`add_swatch`). Use the result as the stroke
48
+ `color`; `set_color` makes it the default.
42
49
  5. **Refine** with smaller brushes on new layers: pencil and ink for line, charcoal for value,
43
50
  blender or smudge to soften edges, the Mixer Brush to blend wet into wet.
44
- 6. **Repeat and vary instead of drawing every mark.** Paint one good stroke, then
51
+ 6. **Let the guides multiply your marks.** `set_symmetry` (mirror for faces and vases,
52
+ kaleidoscope for mandalas and ornaments) paints every copy from one stroke;
53
+ `set_perspective_guide` plus `paint_stroke` with `snapToPerspective` lays converging lines for
54
+ buildings and roads. To copy an image's composition and colours, `set_tracing_image` with
55
+ `sampleColors` and paint over it.
56
+ 7. **Repeat and vary instead of drawing every mark.** Paint one good stroke, then
45
57
  `replay_strokes` it with `dx` / `dy`, `rotate`, `scale`, `flipX`, `color`, `brushId` and
46
58
  `repeat` for hatching, grass, foliage, rows, fans or spirals, in one undo step.
47
- 7. **Check** with `render_preview` after each block of work, not after each stroke.
59
+ 8. **Check** with `render_preview` after each block of work, not after each stroke.
48
60
  `pick_color` reads exact values. Undo what made it worse.
49
- 8. **Deliver**: `export_image` (PNG, or JPEG / WebP in a browser), `export_psd` for Photoshop,
61
+ 9. **Deliver**: `export_image` (PNG, or JPEG / WebP in a browser), `export_psd` for Photoshop,
50
62
  `save_document` to keep the painting with its strokes.
51
63
 
52
64
  ## Best practices
@@ -123,17 +135,41 @@ is never part of a layer. Coordinates are document pixels, (0, 0) top-left, y do
123
135
  | `get_mixer_brush` | Read what the Mixer Brush carries: `reservoir`, `amount` left, `pickup`. |
124
136
  | `load_mixer_brush` | Fill the Mixer Brush reservoir with a colour (keeps its pickup). |
125
137
  | `clean_mixer_brush` | Empty the pickup well (and with `emptyReservoir` the paint). |
138
+ | `color_harmony` | Get a harmony (`kind`: complementary, split-complementary, analogous, triadic, tetradic, square, monochromatic) around `color` (default the paint colour), on the `ryb` painter's wheel (default; red ↔ green) or the `rgb` wheel (red ↔ cyan), `spread` degrees for analogous and split. Changes nothing. |
139
+ | `list_swatches` | Read the swatches (index, colour, name). |
140
+ | `add_swatch` | Keep a colour as a swatch (saved with the document). |
141
+ | `remove_swatch` | Remove a swatch by `index`. |
142
+ | `mixing_pad_stroke` | Paint on the 360 × 220 mixing pad (pad px): `tool` paint lays `color` with a pigment Mixer Brush, `knife` smears what is there and mixes it as paint. Scratch space, not the painting, no undo. |
143
+ | `pick_mixing_pad_color` | Read the mix on the pad at `x`, `y` (averaged over `radius`, default 3); `setColor` makes it the paint colour. Null where the pad is bare. |
144
+ | `clear_mixing_pad` | Wipe the pad. |
145
+ | `render_mixing_pad` | See the pad as a PNG. |
126
146
 
127
147
  ### Painting and strokes
128
148
 
129
149
  | Tool | Use |
130
150
  | --- | --- |
131
- | `paint_stroke` | Paint one stroke through `points` (document px; `pressure` 0..1, `t` ms, `tiltX` / `tiltY` or `altitude` / `azimuth`, `twist`) with `brushId` (default the active brush), optional per-stroke `brush` changes, `color`, `layerId`, `seed`. Returns `layerId`, `bounds`, `dabs`, `strokeId` and for the mixer engine its `mixerLoad`. Refused on locked, hidden or group layers, with the fix in the message. |
151
+ | `paint_stroke` | Paint one stroke through `points` (document px; `pressure` 0..1, `t` ms, `tiltX` / `tiltY` or `altitude` / `azimuth`, `twist`) with `brushId` (default the active brush), optional per-stroke `brush` changes, `color`, `layerId`, `seed`, `snapToPerspective`. The symmetry guide adds its copies; a sampling tracing image supplies the colour when `color` is missing. Returns `layerId`, `bounds`, `dabs`, `strokeId` and for the mixer engine its `mixerLoad`. Refused on locked, hidden or group layers, with the fix in the message. |
132
152
  | `list_strokes` | Read the recorded strokes, oldest first (default the last 100): id, layer, brush, colour, point count, seed, bounds. With `ids`, their points too. |
133
153
  | `replay_strokes` | Paint recorded `strokeIds` again: exactly, or varied by `dx` / `dy` (px), `rotate` (degrees clockwise), `scale` (brush size follows), `flipX`, `origin`, `pressureScale`, `color`, `brushId`, `layerId`, `repeat` (each copy applies the variation again). One undo step. Returns the new stroke ids, bounds and layers. |
134
154
  | `undo_paint` | Undo the last step. Returns what was undone and what is next. |
135
155
  | `redo_paint` | Redo the step just undone. |
136
156
 
157
+ ### Guides
158
+
159
+ | Tool | Use |
160
+ | --- | --- |
161
+ | `get_guides` | Read the symmetry guide (with how many copies a stroke paints), the perspective guide, the tracing image and the reference images. |
162
+ | `set_symmetry` | `mode` off, vertical, horizontal, dual, diagonal or kaleidoscope (`segments` 2..32, `mirror`), `center` (document px, default the canvas centre), `rotation`. Every stroke after it paints its copies as one stroke; recorded strokes keep their copies when replayed. |
163
+ | `set_perspective_guide` | One to three vanishing `points` (document px, may be off the canvas), `enabled`, `snap`. Pen strokes snap to the guide line through their start that best matches their direction (one-point also keeps horizontals and verticals, two-point verticals); `paint_stroke` snaps only with `snapToPerspective`. |
164
+ | `set_tracing_image` | Put a PNG (`png` base64 or data URL) under the paint, fitted to the canvas or at `rect`, at `opacity` (default 0.35), with `sampleColors` to take stroke colours from it. View only: never exported. |
165
+ | `update_tracing_image` | Change the tracing image's `opacity`, `visible`, `sampleColors` or `rect`. |
166
+ | `clear_tracing_image` | Remove the tracing image. |
167
+ | `add_reference_image` | Add a floating reference PNG (`name`, panel `x`, `y`, `displayWidth`). Returns its id and size. |
168
+ | `list_reference_images` | Read the reference images: id, name, size, placement, visibility. |
169
+ | `update_reference_image` | Move, resize, rename, show or hide a reference panel. |
170
+ | `remove_reference_image` | Remove a reference image. |
171
+ | `pick_reference_color` | Read a reference image's colour at its own pixel `x`, `y`; `setColor` makes it the paint colour. |
172
+
137
173
  ### View, input and output
138
174
 
139
175
  | Tool | Use |
@@ -158,5 +194,10 @@ is never part of a layer. Coordinates are document pixels, (0, 0) top-left, y do
158
194
  and two strokes on the same spot catch the same peaks.
159
195
  - **Big soft brushes at full flow look flat.** Lower `flow` (airbrush 0.05..0.15) and build up.
160
196
  - **JPEG and WebP need a browser**; in Node use PNG. Exports never upscale (`scale` ≤ 1).
197
+ - **Symmetry stays on until you turn it off.** Set `mode: "off"` after the symmetric part, or
198
+ every later stroke is mirrored too.
199
+ - **The tracing image is not in exports or previews of the painting alone**; paint over it on a
200
+ layer. Turn `sampleColors` off before painting your own colours, or strokes without `color`
201
+ keep taking its colours.
161
202
  - **Recorded strokes are kept in saved documents**; `save_document` with `strokes: false` when
162
203
  only the pixels matter (smaller JSON).