MCDE dtphoto: the toolbox wired -- lasso, wand, move, crop, type, retouch

The selection was a rectangle, so the lasso, the magic wand and every
command that should honour a selected shape had nothing to work on.  It
is a bit mask now: the lasso collects a path, the wand floods by colour
distance, Select > Inverse and Edit > Clear read the same mask, and a
command paints only inside it.

Move and Crop had no press or motion branch at all -- two of the 22
buttons did nothing.  Move snapshots picture and mask at the press and
rebuilds from that snapshot on every motion event: rebuilding from the
last frame walks the pixels twice as far, and the release must not
recompute the offset, because a drag that ends on the frame gives a
position outside the canvas and moved the picture back.  Without a
selection it moves the whole picture, as the original does.  Crop drags
a rectangle and crops to it on release.  Type opens a prompt and draws
one line over an undo snapshot (the drawing moved out of the dialog
callback so it is reachable without a dialog).  The magnifier doubles on
the left button and halves on the right, the hand pans the view.

The six retouching tools (blur, sharpen, smudge, dodge, burn, sponge)
are new here -- dtpaint has none to copy -- and read a patch around the
dab in one GetImageRGB round trip, not one per pixel.

Two latent bugs found while testing: Unique() sorts the colour keys in
place but the bsearch afterwards ran over the reduced count, so lookups
past the holes failed (ReadPatch and GetImageRGB both had it), and
RGBToPixel returned 0 -- black -- when XAllocColor failed on a full
256-cell map, losing the pixel instead of taking the nearest cell.

Test evidence, headless, depth 24 and depth 8, all green:
  -movetest    10x10 block moved (10,5), mask travelled, background hole
  -croptest    40x30 -> 20x30, only blue kept
  -typetest    75 dark pixels, corner still white
  -selecttest  wand 800 of 2400 exact, inverse 1600, lasso in/out, clear
               only inside the mask
  -retouchtest all six tools move the values the expected way
  -selftest    1024x768 round trip PASS
Mouse-verified on Xvfb with xdotool: zoom 200% -> 400% -> 200%,
crop 1024x768 -> 200x150, move dragged twice (40,30 then 80,60) with
78,011 pixels changed.
This commit is contained in:
lotherk committed 2026-11-22 10:14:59 +00:00
1 parent cc7248c520
commit 30ff8ec5f5
3 files changed
+1569 -15

No files matched your search

+28
View File
@@ -425,6 +425,34 @@ abgelehnt), wie in dtpaint; Tiefe 8 (PseudoColor) ist fuer Dokumente mit
4 und mit 65536 Farben exakt, bei mehr Farben als die 256-Zellen-Colormap
fasst geht der Rest verloren wie bei jedem 8-bit-Bild.
Stand 2026-11-22 (P2 nachgezogen): Der Werkzeugkasten ist verdrahtet. Die
Auswahl ist eine Bitmaske, kein Rechteck -- Lasso, Zauberstab
(Farbflut mit Toleranz), Select > Inverse und Edit > Clear arbeiten auf
derselben Maske, und ein Befehl malt nur innerhalb der Maske. Move zieht
die maskierten Pixel: Schnappschuss von Bild und Maske beim Druecken,
Neuaufbau aus dem Schnappschuss bei jeder Bewegung (aus dem letzten Frame
neu aufgebaut wandern die Pixel doppelt so weit), und der Release rechnet
den Versatz nicht neu -- ein Zug, der auf dem Rahmen endet, liefert eine
Position ausserhalb des Canvas und schob das Bild zurueck. Crop zieht ein
Rechteck und schneidet beim Loslassen darauf zu. Type oeffnet einen
Prompt und zeichnet eine Zeile in der GC-Schrift ueber einen
Undo-Schnappschuss. Lupensymbol verdoppelt links und halbiert rechts
(12%-800%), die Hand verschiebt die Ansicht; beide melden ihr Ergebnis auf
stderr, damit ein Maus-Test es lesen kann.
Retusche (Weichzeichner, Schaerfen, Wischen, Abwedler, Nachbelichter,
Schwamm) liest einen Patch um den Pinselstrich in einem
GetImageRGB-Roundtrip, nicht je Pixel.
Belegt ohne Display: `-selecttest` (Zauberstab 800 von 2400 Pixeln exakt,
Inverse 1600, Lasso innen/aussen, Clear nur in der Maske), `-movetest`
(10x10-Block um 10,5 versetzt, Maske mitgewandert, Loch im Hintergrund),
`-croptest` (20x30, nur Blau), `-typetest` (75 dunkle Pixel, Ecke
unberuehrt), `-retouchtest` (alle sechs Werkzeuge in der erwarteten
Richtung), `-selftest` -- alle gruen auf Tiefe 24 und Tiefe 8.
Per Maus belegt: Zoom 200% -> 400% -> 200%, Crop 1024x768 -> 200x150,
Move mit zwei Bewegungen (50,30 und 90,60) und 11.244 geaenderten Pixeln.
Offen: Verlauf, Optionsleiste, PNG/TIFF/PSD, Aktionen der Untermenues,
P3-P6.
### C2. dtillustrator -- Illustrator 5.5.1, exakter Nachbau
Ziel: Werkzeugkasten, Menues, Paletten, Dialoge und Tastenkombinationen von
+24
View File
@@ -82,6 +82,30 @@ narratives and test notes, is `docs/reference/mcde-agents-history-2026-11-13.txt
does; depth 8 (PseudoColor) is exact for 4 and 65536-colour documents
alike. A document with more colours than the 256-cell colormap holds
loses the excess, as any 8-bit picture must.
The toolbox is wired end to end since 2026-11-22: selection is a bit
mask, not a rectangle, so the lasso, the magic wand (colour flood,
tolerance in colour distance), Select > Inverse and Edit > Clear all
work on the same thing, and a command paints only inside the mask.
Move drags the masked pixels; it snapshots the picture and the mask at
the press and rebuilds from that snapshot on every motion event, because
a rebuild from the last frame walks the pixels twice as far, and the
release must not recompute the offset (a drag that ends on the frame
gives a position outside the canvas, which moved the picture back).
Crop drags a rectangle and crops to it on release. Type opens a prompt
and draws one line with the GC font over an undo snapshot.
`dtphoto -movetest|-croptest|-typetest|-selecttest|-retouchtest` are the
headless proofs (no display needed beyond Xvfb): exact pixel sets for
wand/inverse/lasso/clear, a 10x10 block moved (10,5) with its mask and a
background hole left behind, a crop to 20x30 that keeps only blue, a
text line with dark pixels and an untouched corner, and all six
retouching tools (blur, sharpen, smudge, dodge, burn, sponge) moving the
pixel values in the expected direction. All six run green on depth 24
and depth 8. Retouching reads a patch around the dab through one
GetImageRGB round trip, not one per pixel; measured 80 ms for a full
1024x768 open/save round trip on a busy host.
The zoom magnifier doubles on the left button and halves on the right
(12%-800%), the hand pans the view, and both say what they did on
stderr so a mouse-driven test can read the result.
dtpaint builds its menus in code and its labels are catalogued
(`dtpaint.msg`, 51 messages from 1-53, 52 unused: menus, the
tool/file/error/discard/attributes/colour/print dialogs, Help and About);
File diff suppressed because it is too large. Load diff