Pencil underdrawing (round 4, branch pencil)
The painters in amnesia round 3 said they couldn't draw: "A painter draws
it; I compiled it" (notes/amnesia3/easel3_near.md). This stream adds
drawing as a medium of its own. You sketch the composition on the ground in
graphite or black chalk, look at it, erase and redraw, and then paint over it,
using the drawing as your guide. Friedrich worked this way:
graphite pencils of different hardness and black chalk, sometimes in two
passes (faint, then bolder), straights ruled. In the early works the drawing
stays visible through the very thin paint
(notes/research/friedrich_materials.md §3).
What changed
crates/paint/src/graphite.rs(new): the medium.Lead::pencil("2B"),Lead::graphite(softness)andLead::chalk(). Hardness (the share of clay in the lead) sets the flake reflectance (2H pale silver gray, 4B dark gray; graphite is never black), how much one pass lays (rate), the most it can cover (cap), how far pressure lets it bite into the tooth (bite_um), the grain (crumble) and how fast the point blunts (blunt_mm, width toward 3× the sharp point). Chalk is carbon black in clay: flake reflectance 0.022, matte, broad (0.9 mm), crumbly, and it wears fast.Canvas::draw(lead, mark, worn_mm, seed)rasterizes a dense path with per-point pressure. At each pixel the point rides on the local tops of the surface height field (the weave through the ground, max over ±0.35 mm). The deposit falls off with depth below those tops asexp(-depth / bite), withbite = bite_um · p^1.2 + 3 µm, so light lines catch only the crowns of the weave and heavy lines fill in. A pixel coarser than 0.15 mm counts its depth and grain as averages (so 1000px previews aren't beaded dots).- Optics: the deposit covers a fraction
aof the pixel with flakes of reflectancer, written straight into the dry picture (px). Every later layer composites over it by Kubelka–Munk (Pigment::over), so thin paint shows it and body color hides it, with no special case. Graphite doesn't take on wet paint (pixels with wet paint are skipped). - A sparse bookkeeping layer,
Drawing(20 bytes per pixel, created only when something is drawn), recordsa,r, how readily it lifts, a fixed floor and the film thickness when it was drawn.Canvas::erase(mask, strength)is a kneaded eraser. It lifts graphite up to 90% per pass and chalk up to 72%, both scaled from 55% in the hollows to 95% at the tops, so a ghost stays. It recovers the ground under the deposit exactly by inverting the mix.fix_drawing(mask?)sets the floor. Once the film is thicker than when the line was drawn, it is sealed: the eraser leaves it alone. drawing_mask()(1 on a firm line, also under paint) anddrawing_view()(the drawing alone on white, like an infrared reflectogram; no caller yet, see Known issues).- Mark builders:
hand_line(Catmull–Rom or straight, arm sway and finger tremor, none against a ruler),sketch_marks(a searching line: n passes, each offset and bowed its own way, starting and ending early or late, lifting off now and then, the first pass lightest) andhatch_marks(short parallel strokes inside a mask, bowed by the wrist, heavy at the start and lifting off at the end).
crates/paint/src/canvas.rs: one field (drawing: Option<Box<Drawing>>,Noneby default) and its initializer.lib.rs:pub mod graphiteandLeadandMediumre-exported.crates/easel/src/draw_pencil.rs(new): the Lua bindings. It is declared fromapi.rswith#[path]and installed with one line, somain.rsis untouched. A pencil is a plain Lua table ({grade=, kind=, worn=}) with shared methods, so the wear of its point is on the Lua heap: undo, rollback and replay restore it (easel checkpasses on the study).crates/easel/src/api.rs:canvas{size=mm}sets the painting's width in mm. A pencil line is 0.3–0.9 mm. On the 1714 mm early style at 1000px it is a quarter of a pixel, so on a small canvas the drawing reads in a preview. The size also goes in the log's setup line.crates/easel/README.md: a "Drawing: pencil, chalk and eraser" section with a worked example.README.md: one bullet.
Without a drawing, nothing changes. The golden scene isn't affected, since
no code path runs unless draw is called.
The painter's API (easel)
canvas{style="friedrich_early", size=440, aspect=1.4, seed=11}
h = pencil("2H") -- 9H..H, F, HB, B..9B; pencil{grade="2B"}; chalk()
h:rule({0, 432}, {1000, 432}, {pressure=0.3}) -- against a ruler
h:sketch(pts, {pressure=0.3}) -- searching: passes=3, wander=(units, ~2 mm), smooth=true
b = pencil("2B")
b:line(pts, {pressure={0.55, 0.7, 0.5}, smooth=false}) -- a firm line; corners kept
b:hatch(poly(shadow), {angle=-1.1, pressure=0.35}) -- spacing=, length= (units)
erase(pts, {strength=0.9, width=9}) -- or erase(mask, {strength=})
fix() -- or fix(mask)
drawing_mask() -- guide for painting into the hidden drawing
b.worn b:width() b:sharpen()
Evidence
paintings/lua/pencil.lua (9 chunks; easel check: "replay matches the
live canvas exactly"):
- canvas: early grounds, 440 mm
- first pass, 2H: ruled horizon, searching sketches of the ground, a rock and a tree
- second pass, 2B: firm lines; the rock's top is drawn too high
- the wrong top is lifted with the kneaded eraser (twice) and redrawn lower with corners, a ledge and a crack, the shadow side hatched, HB twigs
- fixative; masks for the paint
- left half: thin, translucent paint (
paint={0.3, 0.3}, medium 0.6, load 0.3), then 7. blended - right half: body color (medium 0.15, load 0.9, coverage 4)
- dry; the tree painted over its hidden drawing: trunk along the drawn
coordinates, limbs into
drawing_mask():band(0.55, 1, 0.1):grow(1.2)
Images (notes/pencil/):
drawing_1000.jpg,drawing_3200_crop.jpg: the drawing alone (chunks 1–4). At 3200px: faint searching 2H lines under the firm 2B contour, the eraser's ghost of the first, too-high dome, hatching that catches the crowns of the weave.painted_1000.jpg,painted_3200_crop.jpg(window 330,400–650,580): on the left, the rock contour, ledge, crack and the ghost dome show through the thin paint ("still partly shimmer through"). On the right, the same rock's hatching is gone under body color.chart_1000.jpg(paintings/lua/pencil_chart.lua): rows 2H, HB, 2B, 4B and chalk at pressures 0.15, 0.35, 0.6 and 0.9 (three lines and a sketch each). Below: 2B hatching, 2B crosshatching, chalk hatching and a 4B block with a rectangle and a stroke erased.
Tests (cargo test -p paint graphite): grades parse; softer and firmer is
darker and chalk darkest; a light line favors the tops of the tooth; the
eraser lifts most but leaves a ghost; fixed drawing can't be lifted; a glaze
seals it; thin paint shows a line while body color hides it; no drawing
means no change; points wear, soft ones faster.
Known issues and next steps
- No
look --mode drawing.look.rsbelongs to the lookaid stream.Canvas::drawing_view()is ready. The hook is about six lines: adrawingflag inView,"drawing" | "irr" => v.drawing = trueinparse, andif v.drawing { c.drawing_view() } else ...wherelookpicks its pixels. Until then,drawing_mask()andlook --cropdo the job. - Checkpoints don't store the bookkeeping. A resumed canvas keeps the
drawn pixels, but
eraseandfixdo nothing to drawing made before the checkpoint. The easel's undo clones the canvas, so it is unaffected. - Sheen is only in the flake reflectance.
relief()doesn't give soft graphite its raking-light shine. - Wet paint doesn't pick up loose graphite. Real unfixed graphite grays
and smears into oil paint, which is why painters fix it.
fix()only stops the eraser for now. - The constants are tuned by eye against the grade chart, not measured.
The tooth depths come from this engine's height field: 30–48 µm median
below the local tops (
graphite::probe::tooth_depths, ignored test). - Hatching is even in rhythm; no zigzag hatching yet. Pencil lines have no
clip=option. - Memory: 20 bytes per pixel once something is drawn (about 15 MB at 1000px, 146 MB at 3200px, 7:5).
- Seen in passing (other streams):
hand="glaze"withmedium=0.85laid puddled, oversized strokes that ran past the mask (chunk 6, first try). Defaultpaint=hiding is effectively opaque at a lean film, so thin paint needspaint={0.3, 0.3}to let a drawing show.