248 Commits
Author SHA1 Message Date
hnoerenberg 7242b84e34 docs(paint): state the CMYK channel invariant of the ink blend
The ink-channel blend only runs for a CMYK format, whose pixels carry the four
inks first, so channels 0..3 of `px` and `out` are C, M, Y and K. One line of
comment for the never-crash rule; no behaviour change.

`cargo test -p photocraft-paint --lib` -> 242 passed, 0 failed, 1 ignored.
`cargo test -p photocraft-engine-paint --lib color_replacement` -> 19 passed, 0
failed. `cargo fmt -p photocraft-paint -- --check` -> no output.
`cargo clippy -p photocraft-paint --all-targets -- -D warnings` -> `Finished`.
2026-11-25 01:44:22 +01:00
hnoerenberg 5068320297 fix(paint): blend Color replacement on the CMYK channels of the document
In a CMYK/8 document the Color mode no longer takes the pixel through the RGB
blend space. It follows the rule ISO 32000-1 11.3.5.3 gives for a non-separable
blend in a CMYK space, which is what the issue's four numbers come from: C, M and
Y complemented, blended like RGB - Color is SetLum(source, L(backdrop)) with
ClipColor pulling the result back into gamut towards grey, the step that keeps the
lightness of the BOTTOM layer - complemented back, K from the backdrop. Hue,
Saturation and Luminosity in CMYK, and CMYK/16, keep the RGB blend: the issue
leaves them unmeasured. RGB, Grayscale and Lab documents are untouched, and the
tolerance match still reads the pixels as RGB.

The foreground's inks come from the pick when it was picked as CMYK
(ReplaceSettings::color_inks, the pair a Brush stroke already carries, #4196 and
#4344), and from its RGB through the document's CMYK profile otherwise: the
profile plumbing of this branch is what turns the picked colour into the
document's channels.

Measured with the tests added by the previous commit (40 px hard tip, pure blue
foreground, Mode Color, one click each, the issue's document converted to CMYK/8;
the table is C89 M71 Y0 K1 / C42 M34 Y0 K0 / C55 M44 Y0 K0 / C91 M72 Y0 K4):

- Coated FOGRA39, the CMYK space those numbers were measured in: C89.41 M70.59 Y0
  K1.18, C41.18 M32.55 Y0 K0, C55.69 M43.53 Y0 K0.39, C91.37 M71.76 Y0.78 K5.10 -
  every ink within 1.5 percentage points.
- No profile at all, the backdrop filled with the inks the reference measured and
  the foreground picked as C93.33 M74.60 Y0 K0: C89.02 M71.37 Y0 K0.78, C42.75
  M34.12 Y0 K0, C55.69 M44.71 Y0 K0, C90.59 M72.55 Y0 K4.31 - within 0.8.
- PhotoCraft's own default working space (the built-in coated profile), which is
  not FOGRA39: C74.90 M77.25 Y0 K0, C34.51 M35.69 Y0 K0, C41.18 M42.75 Y0 K0,
  C76.86 M79.22 Y0 K0. That space renders pure blue as C96.86 M100 Y0 K0 and a
  Color blend takes its hue from the foreground, so the result's C and M follow
  that ratio rather than the table's 89 : 71, and it makes no K from these four
  colours, so the table's K1 and K4 cannot appear there either.
2026-11-25 01:41:31 +01:00
hnoerenberg 8cbc9068d1 test(engine-core): pin Color Replacement on a profiled CMYK/16 document
A CMYK/16 document that carries a CMYK profile of its own is covered by
the profile change as well, and nothing reached it: the click now stores
the inks that profile asks for (the red pixel moves from C96 M100 Y0 K0 to
C74 M61 Y0 K0, and Luminosity with it) rather than the built-in coated
ones. Pin both modes at 16 bits next to the untagged 16-bit case, which
keeps today's values.

Two comments corrected: the live-preview test compares against the coated
inks of a pixel that lies under two dabs, so it is a proximity gate and not
a pin of what an unfixed stroke stores; and the scope in replace.rs also
covers the pre-stroke reads the match is measured on, so on a document with
its own CMYK profile which pixels fall inside the tolerance can move too.
2026-11-23 16:05:04 +01:00
hnoerenberg 7018cba623 fix(paint): blend Color in a CMYK document through its own profile
Color Replacement converts each pixel to RGB, blends there and writes the
inks back. For a CMYK document those conversions used the built-in coated
CMYK whatever the document carried: unlike a Brush stroke, neither
paint.colorReplacement nor its live preview entered the document's own
CMYK profile, so a document tagged with a CMYK profile of its own was
recoloured against the wrong device colour (#11918).

The effect captures the CMYK space that is active where it is built and
enters it for every dab, because a live preview runs its dabs after the
command that built the effect has returned; the two command entries enter
doc_cmyk_space, the scope stroke_with already enters for a stroke.
2026-11-23 15:23:16 +01:00
David MannandClaude Opus 5.5 268dd52f25 Fix the stale cached states the #16197 review found (#16252)
- tools.setBrush keeps a stored tip that loaded only now instead of the unloaded one it compares equal to
- Session::move_document moves the documents generation, so the Window menu follows a reorder
- The rule facts key on every open document's revision and the scratch read-error generation
- The Layers panel thumbnails key on the scratch read-error generation
- The Pattern Fill dialog owns its swatch textures until it closes
- The style library snapshot is derived, so the Styles panel and Layer Style dialog replay

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-21 18:55:00 +01:00
David Mann e37856b8a6 Merge pull request #16197 from aiongg/doc-tracked
Document state is Tracked; command-state sources are derived values (#15709)
2026-11-21 18:37:52 +01:00
David Mann d8ede65774 Merge PR #15165: fix(paint): wrap procedural pattern seed hashing 2026-11-21 17:24:04 +01:00
aiongg 72f7f93777 Document state is Tracked (#15709) 2026-11-21 16:12:46 +00:00
aiongg a8f21a383d Brush tip is Tracked: the Brush Preset field runs only for the presets, the tip and the values it shows
photocraft-paint's BrushSettings::tip is a Tracked<TipShape>; tools.setBrush keeps its revision when the new brush's
tip equals the old one. The options bar's field takes the presets, the tip and a BrushFace (size, hardness, angle,
roundness) as props instead of the whole brush, so an Opacity or Flow write replays it. Trial:
brush_settle_trials.
2026-11-21 14:07:15 +00:00
aiongg cf84333049 Brush and presets are Tracked
The engine's ToolState.brush and ToolState.presets are Tracked, so a memoized view that shows them keys on their revisions; photocraft-paint's brush types derive PlainData.
2026-11-21 14:07:15 +00:00
Mex cc4de6e99f Merge branch 'storytold:main' into patch-33 2026-11-20 15:38:21 +01:00
David Mann 0a84102123 Merge #15783 into the merge queue batch
Preserve legacy Airbrush rates and initial Fade steps
2026-11-20 14:16:38 +01:00
David Mann 44b13eae2a Merge #12284 into the merge queue batch
Mixer Brush: a load lasts for a length of stroke, not a number of dabs (#11943)
2026-11-19 22:27:44 +01:00
David Mann f6af01fbd0 Merge pull request #12246 from hectorviov/fix/smoothing-lag
Brush smoothing: lag and pulled string as measured in the reference
2026-11-19 18:57:58 +01:00
haranishi aa52f40653 Preserve legacy Airbrush rates and initial Fade steps 2026-11-20 01:53:51 +09:00
FredApps d01b09d7e7 Initialize built-in presets once 2026-11-19 15:14:20 +01:00
FredApps 6b207c5b55 Share built-in brush presets across sessions 2026-11-19 08:41:16 +01:00
aiongg ed14e1c413 PhotoCraft on the craft UI framework (#15449)
PhotoCraft's UI moves onto the shared craft UI framework in storytold/craft-libs (next branch): shell, dock and panels, hosted dialogs, keyboard, focus, IME and pointer routing, the canvas's view commands, themes and tokens. The engine, document model, file formats, commands and automation stay. PhotoCraft pins storytold/craft-libs next.
2026-11-17 10:41:35 -05:00
90816ab768 Brush smoothing: a timed stroke stays timed on a zero-time report (#12246)
Once time had passed between two input points, a later report with the
same timestamp still took the untimed per-point pull (90 % of the way at
10 % smoothing), so the brush jumped. A timed stroke now remembers it is
timed, and a report with no time since the last one leaves the brush where
it is. Untimed input keeps its per-point pull. CodeRabbit finding on #12246.

Co-Authored-By: Hector Villarreal <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 16:37:20 -06:00
Hector Villarreal e9a204f965 Smoothing: strokes without timestamps keep their per-point pull (CI corpus tests), live handoff catch-up case (CodeRabbit nitpick)
The measured lag (#11888) is by stroke time, so it needs timestamps. A stroke without
them (a control-client or script paint.stroke, an old file) was never measured and
took one step per point with the pull 1 - amount; the new curve made that 31 % at
the default 10 %, so a two-point stroke stopped a third of the way and 58 engine
tests (brush_clear_background_tests, mixer_live_tests, brush_cmds tests ...) failed
in the corpus job. Untimed points keep 1 - amount again; timed ones use the measured
curve. Test: strokes_without_timestamps_keep_their_per_point_pull.

CodeRabbit's nitpick on retouch_cmds/tests.rs: the live hand-off test also runs a
smoothing case with Catch-up on Stroke End.
2026-11-15 16:37:20 -06:00
4476684ca3 PR #12246: Hard Round taper test paints through to the end with the measured lag
main's #8842 test smooths a 700 px stroke at 49 %; with the measured lag the brush
ends about 150 px short, so its end cap fell inside the checked span and read as
an opacity jump. The test now uses catch-up on stroke end.

Co-Authored-By: Hector Villarreal <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 16:37:19 -06:00
a3a595737d PR #12246: Smoothing docs name the 300 px string and the Pulled String exception
Co-Authored-By: Hector Villarreal <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 16:37:19 -06:00
Hector Villarreal 853b82d060 smoothing_pull's doc says it clamps the amount and gives 1.0 at 0 or NaN (eliets2 review on crates/paint/src/dynamics.rs:26) 2026-11-15 16:37:19 -06:00
Hector Villarreal bdd484a35a Brush smoothing: lag and pulled string as measured in the reference (#11888)
Exponential smoothing's pull per 16 ms step comes from a time constant
fitted to the reference's lag (tau = 314 ms x amount^0.864: a 200 px
drag in 40 moves 10 ms apart ends about 19 px short at 10 % and 76 px
at 50 %). The pulled string is 300 px at 100 % (150 px at 50 %), and in
Pulled String Mode Catch-up on Stroke End no longer jumps the brush to
the release point. Existing tests that pinned the old lag and string
length are updated.
2026-11-15 16:37:19 -06:00
David Mann 578f596528 Adapt to main: the Load supply tests unwrap apply_mixer_stroke's Result 2026-11-15 20:28:49 +01:00
David Mann 7262bb37ac Merge main into fix/mixer-load-supply 2026-11-15 20:28:30 +01:00
Mex bdc76f44d9 fix(paint): wrap procedural pattern seed hashing
Use explicit wrapping seed arithmetic in checked builds and cover boundary/high u32 seeds across all four texture styles.
2026-11-15 16:21:44 +01:00
Dylan M. Taylor 3bae275d0a Refresh Base64 codec removal and retain plugin alphabet compatibility 2026-11-15 11:54:15 +00:00
Dylan M. Taylor 040962a5b4 Merge photo-cms-port: use craft-cms and remove crates/cms (#13393) 2026-11-14 00:02:22 +00:00
David Mann 968ba560e5 Merge origin/main into PR #13124 2026-11-13 11:16:48 +01:00
vangel76 0a6655ffe6 Merge remote-tracking branch 'upstream/main' into HEAD 2026-11-13 00:05:44 +01:00
Ian ab01524630 Merge main and reconcile Clone Stamp source handling
Integrate the merged cross-document implementation while retaining picked-layer sampling, ICC and source coverage, preview strength, and offset fixes. Preserve upstream explicit preview mappings and closed-document state, and adapt regression fixtures and mode/layer lifetime expectations.
2026-11-12 13:21:56 -05:00
Dylan M. Taylor 41d4b162f2 Merge main into photo-cms-port 2026-11-12 00:57:42 +00:00
Ian 42616775b5 Avoid duplicate alpha checks in Normal retouch blending 2026-11-11 18:36:46 -05:00
Dylan M. Taylor fd943c466b Merge main into photo-cms-port; pin craft-cms to the head of storytold/craft-libs#858
main's one change to crates/cms since (#11055, the per-profile CLUT budget) is
already in craft-cms (storytold/craft-libs#815).
2026-11-11 23:18:18 +00:00
Ian d209bb863e Keep healing source coverage and clone overlays consistent 2026-11-11 18:12:44 -05:00
Dylan M. Taylor f33bdad496 paint: two stroke tests check the result the stroke now returns
apply_color_replacement and apply_mixer_stroke return a Result since #11070.
Two tests that landed on main after that PR's CI ran still dropped it, so
clippy's unused-must-use lint fails the gate on main.
2026-11-11 22:31:50 +00:00
Dylan M. Taylor abeb16c96b paint: refuse a sequential-dab stroke whose working copy is too large (#11070)
* paint: refuse a sequential-dab stroke whose working copy is too large

apply_dab_stroke read the whole rectangle enclosing a stroke's dabs into
two dense f32 copies (and a third for the mix), sized by the area
between the dabs rather than what they paint. Two distant points asked
for gigabytes on a sparse document.

Check the three planes against a 4 GiB budget (1 GiB on 32-bit) before
reading, and paint nothing past it.

* address review: apply_dab_stroke returns Result so over-budget dab strokes fail with 'stroke too large'

* fix tests: apply_dab_stroke returns a Result

* fix tests: handle the Result of the dab-stroke functions
2026-11-11 16:31:47 -05:00
vangel76andClaude Sonnet 5.5 c0af6a1742 Merge upstream/main into perf/paint-stroke-budget
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-11-11 22:25:55 +01:00
Dylan M. Taylor 2b75a0092d Use craft-cms from craft-libs; remove crates/cms
craft-cms was extracted from crates/cms (storytold/craft-libs#779), and both
copies changed afterwards. storytold/craft-libs#PRNUM ports the 41 commits made
here since the extraction, so the shared crate now has everything this copy
had, and PhotoCraft depends on it.

craft-cms returns errors where the local crate panicked on caller input:
transforms, tables and LUT constructors return Result. Call sites propagate
the error where the function already returns one, and fall back where the
arguments are fixed by construction (each with a comment saying why).
Lut3d's fields are private there; the proof and HDR display table is built
with Lut3d::from_fn.

The pin is the head of the craft-libs branch and moves to main when that
pull request merges.
2026-11-11 19:41:51 +00:00
David Mann 56004e9460 Merge pull request #12259 from hectorviov/fix/color-replacement-anti-alias-off
Color Replacement: a hard tip edge with Anti-alias off
2026-11-11 14:53:28 +01:00
Hector Villarreal 944d0b67d6 #12284: a Mixer dab deposits the supply left at its own distance (CodeRabbit, mixer.rs:350)
The load's supply is a length of stroke, but the dab used the amount left at the dab
before: depletion ran after the deposit. With a wide spacing (35 px tip at 1000 %: dabs
at 30, 380, 730) the dab 700 px into a 390 px supply still painted solid. The distance
update now runs before the dab deposits; the first dab is still at distance zero.
Test: a_dab_deposits_the_supply_left_at_its_own_distance (254 at x 730 before).
2026-11-11 07:50:25 -06:00
1b82d3397d Merge origin/main into #12259 (Anti-alias off reach test combined with main's Lab Color recolor)
Co-Authored-By: Hector Villarreal <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-11 13:33:52 +01:00
4b9678ff00 Merge origin/main into #12285 (keep both test modules)
Co-Authored-By: Hector Villarreal <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-11 13:33:52 +01:00
ead29a0f58 #12284: keep the Mixer Brush amount finite when the remaining supply underflows to zero (0/0 was NaN)
Co-Authored-By: Hector Villarreal <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-11 13:33:51 +01:00
fb1deacd03 Merge origin/main into #12284 (keep both test modules; the long Mixer test stroke gets main's catchUpOnEnd)
Co-Authored-By: Hector Villarreal <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-11 13:33:51 +01:00
Tanish Manku 0e2d24db26 Merge pull request #10010 from artman67/faster-big-brushes
Brush: big imported brushes paint about twice as fast, with the same pixels
2026-11-11 00:12:31 -07:00
ljkxandClaude Fable 5.2 cd81562c4e Merge main into feat/smudge-tool-mode
Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-11 01:33:13 +01:00
David Mann c4b4afc0a9 Merge pull request #12169 from DuBearte/fix/11886-airbrush-rate
Airbrush: about ten dabs a second while held, and a click lays two dabs
2026-11-11 00:50:39 +01:00
ljkxandClaude Fable 5.2 77609e3625 Merge main into feat/smudge-tool-mode
Co-Authored-By: Claude Fable 5.2 <[email protected]>
2026-11-11 00:15:22 +01:00