Claude paints with code: a Claude Code skill for procedural illustration in 83 styles, from ink wash (水墨), watercolour and ukiyo-e to stained glass, Roman mosaic, Art Deco, shadow puppets, pastel UI, sketchbook doodles, spot illustrations, grainy picture books, dreamy hills, sunlit greenery. No image model: numpy + Pillow on a CPU, draw-on GIFs.
Python agent-skillsanimechinese-paintingclaudeclaude-codeclaude-skillscolored-pencilcreative-codingcross-stitcheditorial-illustrationgenerative-artink-wash-paintingoil-paintingpaper-collagepixel-artprocedural-generationrisographshanshuiukiyo-ewatercolor
Add poetic halloween style (77 total): a ghost in a jar on the last night of October
cloveric4886ed820dd1
diff --git a/README.md b/README.mdindex 927f937..94f183b 100644--- a/README.md+++ b/README.md@@ -1,7 +1,7 @@# Claude Drawing · Claude 绘图-**Claude paints with code — no image model.** Seventy-six styles, from ink wash and impasto oil to clay, cyanotype, stained glass, a Roman mosaic, Delft tiles, a cyberpunk street, a ray-traced ball pit, low-poly 3D, a thermal camera, an X-ray, a VHS tape, a synthwave sunset, a pastel product-film UI, an answer sheet marked in red, a lamp-lit shadow-puppet play, pen-and-wash sketch cards, retro gouache picture-book portraits, a soft-blue picture-book spread, a Jiangnan water garden in spring, a dry-brushed mid-century poster, a dusk picture-book page where the sky turns to stars, a hatched night print of lava meeting the sea, a dark note-taking app rendering its diagram, an infinite canvas of cards, a five-diagram sheet on warm Flexoki paper, a warm coloured-pencil storybook spread, a colour town of gouache houses strung with bunting and a soft-pastel vignette of a woman wearing her ginger cat as a scarf.-**不用生图模型,Claude 用代码一笔一笔作画。** 七十六种画风,从水墨、油画到黏土、蓝晒、彩色玻璃花窗、罗马马赛克、代尔夫特蓝瓷砖、赛博朋克、光线追踪的小球海、低多边形 3D、热成像、X 光片、VHS 录像带、Synthwave 落日、产品发布片式的粉彩界面、红笔批改的答题卡、油灯下的皮影戏、钢笔淡彩的速写小卡、复古水粉的绘本大头像、蓝调绘本的雨天跨页、江南园林的春水园景、干刷色块的 mid-century 海报、暮色微缩绘本里转入星空的黄昏、排线夜景里流进海里的熔岩、深色笔记应用里渲染出的流程图、卡片铺开的无限白板、Flexoki 暖纸上的五图图解、暖调彩铅叠出来的绘本跨页、挂满彩旗的水粉彩色小镇和把橘猫当围巾的色粉小像。+**Claude paints with code — no image model.** Seventy-seven styles, from ink wash and impasto oil to clay, cyanotype, stained glass, a Roman mosaic, Delft tiles, a cyberpunk street, a ray-traced ball pit, low-poly 3D, a thermal camera, an X-ray, a VHS tape, a synthwave sunset, a pastel product-film UI, an answer sheet marked in red, a lamp-lit shadow-puppet play, pen-and-wash sketch cards, retro gouache picture-book portraits, a soft-blue picture-book spread, a Jiangnan water garden in spring, a dry-brushed mid-century poster, a dusk picture-book page where the sky turns to stars, a hatched night print of lava meeting the sea, a dark note-taking app rendering its diagram, an infinite canvas of cards, a five-diagram sheet on warm Flexoki paper, a warm coloured-pencil storybook spread, a colour town of gouache houses strung with bunting, a soft-pastel vignette of a woman wearing her ginger cat as a scarf and a melancholic Halloween portrait of a porcelain-faced child carrying a glowing ghost home in a jar.+**不用生图模型,Claude 用代码一笔一笔作画。** 七十七种画风,从水墨、油画到黏土、蓝晒、彩色玻璃花窗、罗马马赛克、代尔夫特蓝瓷砖、赛博朋克、光线追踪的小球海、低多边形 3D、热成像、X 光片、VHS 录像带、Synthwave 落日、产品发布片式的粉彩界面、红笔批改的答题卡、油灯下的皮影戏、钢笔淡彩的速写小卡、复古水粉的绘本大头像、蓝调绘本的雨天跨页、江南园林的春水园景、干刷色块的 mid-century 海报、暮色微缩绘本里转入星空的黄昏、排线夜景里流进海里的熔岩、深色笔记应用里渲染出的流程图、卡片铺开的无限白板、Flexoki 暖纸上的五图图解、暖调彩铅叠出来的绘本跨页、挂满彩旗的水粉彩色小镇、把橘猫当围巾的色粉小像和捧着罐中小幽灵的诗意万圣夜。[English](#english) · [中文](#中文)@@ -56,10 +56,10 @@|  |  |  || **Obsidian UI · 笔记应用界面** | **Canvas board · 白板卡片** | **Flexoki paper · Flexoki 纸面** ||  |  |  |-| **Warm pencil storybook · 暖调彩铅绘本** | **Pastel vignette · 色粉小像** | **Ink wash · 水墨(月印万川)** |-|  |  |  |-| **Watercolour · 水彩(底纹)** | | |-|  | | |+| **Warm pencil storybook · 暖调彩铅绘本** | **Pastel vignette · 色粉小像** | **Poetic Halloween · 诗意万圣夜** |+|  |  |  |+| **Ink wash · 水墨(月印万川)** | **Watercolour · 水彩(底纹)** | |+|  |  | |<p align="center"><img src="examples/drawing_colortown_festival_steps.gif" width="45%"><br><sub><b>Colour town · 彩色小镇</b> — portrait 3:4 · 竖幅</sub></p>@@ -145,8 +145,10 @@| <img src="examples/flexoki_pour_over.jpg" width="100%"> | <img src="examples/pencilbook_tortoise_crossing.jpg" width="100%"> || **雨后的节日台阶街** · *Festival Steps After the Rain*<br><sub>Colour town · 彩色小镇</sub> | **橘猫围巾** · *The Marmalade Scarf*<br><sub>Pastel vignette · 色粉小像</sub> || <img src="examples/colortown_festival_steps.jpg" width="100%"> | <img src="examples/pastelvignette_marmalade_scarf.jpg" width="100%"> |+| **罐子里的小幽灵** · *The Ghost in the Jar*<br><sub>Poetic Halloween · 诗意万圣夜</sub> | |+| <img src="examples/poetichalloween_ghost_jar.jpg" width="100%"> | |-Every mark above is computed: paper fibres, ink washes and mist, dry-brush strokes, pigment granulation and blooms, torn-paper edges, pencil wax on paper tooth, cel-shaded clouds, risograph grain and halftones, lit impasto relief, woodblock grain and bokashi, dithered pixels, plasticine lit like a film set, sunlight through leaves on Prussian blue, twisted thread on Aida cloth, machined knobs behind a backlit dial, die-cut vinyl with a laminate gloss, streaky thermal print, graphite catching the tooth of graph paper, highlighter pooling at the start of a swipe, chalk dust settling under half-erased lessons, rain-lit neon glass mirrored in a wet street, a blue-pencil rough under boiling brush ink, an island ray-traced under one soft sun, a single unbroken gold line, candy balls with softbox glints, one outline morphing through six shapes, halftone photos cut out with scissors, frosted glass blurring the real pixels behind it, screen-printed primaries out of register, a slit sun sinking behind a neon grid played off tape, hollow fuse beads on a pegboard melting together under an iron, pits knocked through desert varnish, a red grid showing through flaking plaster, stones laid row by row along an outline, daylight through leaded glass, burnished gold that mirrors the room, left-handed hatching in iron-gall ink, black paper cut with scissors, wood type printed a hair out of register, red and black plates slipping apart, airbrush fades inside knife-cut friskets, Ben-Day dots on yellowed newsprint, one photo key pulled across hand-painted colour, characters struck through a fading ribbon, flat-shaded triangles dithered to 15 bits, spray drifting past cut card, satin stitches catching the light by their angle, ink lines printed white on Prussian blue, wax scribbles skipping the paper's pits, phosphor glowing behind curved glass, heat leaking out of a kitchen, cobalt fired into tin glaze tile by tile, ochre blown onto rock lit by a fire, 1-bit patterns in an old paint program, slip silhouettes incised to the clay, graphite that never quite reaches black, X-rays adding up through a suitcase, grey cels shot on scratched film, gouge marks in a rolled-up block, a birthday smeared onto tape, seven flat colours lifting off each other, an acorn squashing and stretching through a world drawn as it goes, ballpoint ink blobbing at every corner of a hand-drawn game, inks multiplying through tracing paper on a light box, window cards floating on a pastel field over shadows tinted by it, a vermilion stamp running dry at one end, red ink pooling where the pen slowed down, dyed donkey hide glowing on a lamp-lit screen, gouache scumbled dry over a toned board, knit stitch by stitch, dry pastel blue under a scratchy brush line, with chalk rain on top, a spring garden built leaf by leaf, its tiled roofs and willows mirrored in a jade lake, a roller and a dry brush running out across cream paper, a dusk sky going over to stars above thousands of tiny wildflowers, a night sea laid stroke by stroke under the one warm light of lava meeting the water, a hill town of gouache houses, inked line by line and slate by slate, strung with bunting and mirrored in a wet square, and a woman and her cat in soft pastel, the faces rubbed smooth, the hair and fur laid strand by strand, the coat breaking up into dry strokes on white paper. No diffusion model, no API, no stock art. It is just Python with **numpy + Pillow** on a CPU: from 0.1 s (pixel art) to about 45 s (the soft 3D ray tracer) per 1920×1080 image.+Every mark above is computed: paper fibres, ink washes and mist, dry-brush strokes, pigment granulation and blooms, torn-paper edges, pencil wax on paper tooth, cel-shaded clouds, risograph grain and halftones, lit impasto relief, woodblock grain and bokashi, dithered pixels, plasticine lit like a film set, sunlight through leaves on Prussian blue, twisted thread on Aida cloth, machined knobs behind a backlit dial, die-cut vinyl with a laminate gloss, streaky thermal print, graphite catching the tooth of graph paper, highlighter pooling at the start of a swipe, chalk dust settling under half-erased lessons, rain-lit neon glass mirrored in a wet street, a blue-pencil rough under boiling brush ink, an island ray-traced under one soft sun, a single unbroken gold line, candy balls with softbox glints, one outline morphing through six shapes, halftone photos cut out with scissors, frosted glass blurring the real pixels behind it, screen-printed primaries out of register, a slit sun sinking behind a neon grid played off tape, hollow fuse beads on a pegboard melting together under an iron, pits knocked through desert varnish, a red grid showing through flaking plaster, stones laid row by row along an outline, daylight through leaded glass, burnished gold that mirrors the room, left-handed hatching in iron-gall ink, black paper cut with scissors, wood type printed a hair out of register, red and black plates slipping apart, airbrush fades inside knife-cut friskets, Ben-Day dots on yellowed newsprint, one photo key pulled across hand-painted colour, characters struck through a fading ribbon, flat-shaded triangles dithered to 15 bits, spray drifting past cut card, satin stitches catching the light by their angle, ink lines printed white on Prussian blue, wax scribbles skipping the paper's pits, phosphor glowing behind curved glass, heat leaking out of a kitchen, cobalt fired into tin glaze tile by tile, ochre blown onto rock lit by a fire, 1-bit patterns in an old paint program, slip silhouettes incised to the clay, graphite that never quite reaches black, X-rays adding up through a suitcase, grey cels shot on scratched film, gouge marks in a rolled-up block, a birthday smeared onto tape, seven flat colours lifting off each other, an acorn squashing and stretching through a world drawn as it goes, ballpoint ink blobbing at every corner of a hand-drawn game, inks multiplying through tracing paper on a light box, window cards floating on a pastel field over shadows tinted by it, a vermilion stamp running dry at one end, red ink pooling where the pen slowed down, dyed donkey hide glowing on a lamp-lit screen, gouache scumbled dry over a toned board, knit stitch by stitch, dry pastel blue under a scratchy brush line, with chalk rain on top, a spring garden built leaf by leaf, its tiled roofs and willows mirrored in a jade lake, a roller and a dry brush running out across cream paper, a dusk sky going over to stars above thousands of tiny wildflowers, a night sea laid stroke by stroke under the one warm light of lava meeting the water, a hill town of gouache houses, inked line by line and slate by slate, strung with bunting and mirrored in a wet square, a woman and her cat in soft pastel, the faces rubbed smooth, the hair and fur laid strand by strand, the coat breaking up into dry strokes on white paper, and a porcelain child flushed red round the eyes, her burlap hat woven thread by thread, carrying a ghost whose glow warms the wool and the leaves. No diffusion model, no API, no stock art. It is just Python with **numpy + Pillow** on a CPU: from 0.1 s (pixel art) to about 45 s (the soft 3D ray tracer) per 1920×1080 image.---@@ -154,7 +156,7 @@ Every mark above is computed: paper fibres, ink washes and mist, dry-brush strok### What it is-A [Claude Code](https://claude.com/claude-code) skill and a small painting library with seventy-six styles:+A [Claude Code](https://claude.com/claude-code) skill and a small painting library with seventy-seven styles:| Style | Module | What makes it read as the real medium ||---|---|---|@@ -234,6 +236,7 @@ A [Claude Code](https://claude.com/claude-code) skill and a small painting libra| **Warm pencil storybook (暖调彩铅绘本)** | `lib/pencilbook.py` · `PencilStorybook` | a children's-storybook page in soft, layered coloured pencil on warm, toothy paper — a giant gentle creature and a small child at dusk. The sheet has an equalised tooth that is mostly a one-pixel grain; wax catches where the tooth is above one minus the pressure, a little still settles in the pits, and a fill buffer lets later layers reach deeper, so the same pits show through every layer as fine, increasingly tinted specks and only close up where the work is heavy. A stroke is a centreline integrated through an orientation field (angles mod π) with a slight wrist arc; tens of thousands are drawn at once as polylines with their own ids into a 2× supersampled integer map, and for each covered sub-pixel only numpy looks up that stroke's colour, start, direction, length, pressure and taper, recovers how far along it the pixel lies (pressed at the start, lifting off at the end), lays wax where that pressure reaches the tooth dragged along the stroke's own direction, and sums back to pixels with bincount. Strokes are seeded on a jittered grid, and the region is both where they land and, pixel by pixel, how hard the pencil presses, so a shadow is a smooth gradation rather than scattered dark dashes; `avoid` leaves the shapes that come later blank, the way an illustrator keeps the sky off the creature. Wax is semi-transparent (target = old × colour / paper, mixed toward the colour by its opacity): yellow over blue goes green, a colour over itself deepens, light pencils over dark need pressure. `form()` models a shape as a pencil artist does — light under-layer, local colour, the shadow of the same family, the deepest tone in the core, a warm glaze on the lit side and a cool one in the shade — each layer crossing by a few degrees round the form's own direction: along the iso-lines of a dome, round each scute of a shell, across the folds of a neck, down the folds of a coat. Fur is laid in locks whose strands spread at the root and converge at the tip, curling together, the flank away from the light a little darker; grass fans the other way; tree crowns are clumps of curved leaf strokes, each lit on its own. Warm light is layered orange-yellow strokes that follow the surface over a lift of the paper — never rays, never a smooth halo — and reflections are horizontal strokes sampling the mirrored picture. Storybook parts come with it (trees, cottages with lit windows, stones, scales, wildflowers, a paper lantern, a small child in a raincoat with a bob, a dot eye and a rosy cheek), and a finish of slight softness, fine grain and a faint warm vignette. No ink line, no black || **Colour town (彩色小镇)** | `lib/colortown.py` · `ColorTown` | a dense, cheerful storybook hill town in opaque gouache and a fine ink line — tall narrow houses in tomato, mustard, teal, mint, coral and cream piled up a slope under blue-grey slate mansards, a white clock tower, strings of bunting across the street at several depths, climbing roses, window boxes and a wet square that mirrors it all. Every coat of colour is a polygon: tens of thousands are filled at once, each with its own id, into a 2× supersampled integer map, and numpy looks every id up in a table of colour, alpha and texture weights and box-averages back to pixels, so edges are anti-aliased and painter's order is id order. Three fields precomputed for the whole canvas — vertical brush streaks, horizontal streaks and an isotropic scumble — plus a low mottle vary each coat by a few percent: walls are mostly scumble with a little vertical brushwork, the sky and the paving horizontal, and light colours get less of it, so a white wall stays clean. Edges are resampled and pushed sideways by a smooth wobble, so nothing is ruler-straight and the colour never quite registers with its line. The ink is a dark warm brown laid after each group's colour. Every line is its own id in a 3× map (no beads where lines cross), split into pieces of slightly different width, and the corners of boxes are separate strokes that sometimes overshoot. The ink is half-transparent, so it reads red-brown on a red wall and near-black on glass. `house()` builds a townhouse from a few numbers. The walls are plaster with bare-stone patches, string courses and a cornice, a thin glaze toward the foot and a band of shade under the eaves. The ground floor is a door, a shopfront with lettering and a striped awning, or an archway. Above it sits a grid of windows that are each a little different: cream frames, dark teal glass with a pale reflection, glazing bars, sills, slatted shutters on some and curtains on others. Window boxes overflow with leaves and flower dabs, and iron balconies hold pots. Then comes the roof: slate laid tile by tile in staggered courses, each slate its own blue-grey, clipped to the roof with the joints inked, as a mansard, hip, side gable or pointy gable, with dormers, chimneys with pots and TV aerials. `plane()` lays a flat facade onto a quad through a homography, so a whole canyon wall recedes to the vanishing point with its windows, boxes and roses. Depth is haze, scale and overlap, painted back to front; there are almost no cast shadows. Roses are irregular cups with a darker heart and inked petal arcs among paired leaves; trees are clumps of leaf dabs, each lit as a dome from the upper left; bunting sags as a parabola, with pennants hanging off it that each have a darker fold. The wet street mirrors the picture about each column's base line, rippled and smeared down more the further it gets, darkened and streaked into pale flagstones, with the joints re-inked on top; `mirror()` reflects whatever is painted after it (people, a lamp post). It comes with a clock tower with an onion dome and a louvred belfry, steps that shrink as they climb, parapets, railings, lamps, hanging signs, posters, café tables, a cat and small faceless people || **Pastel vignette (色粉小像)** | `lib/pastelvignette.py` · `PastelVignette` | a whimsical picture-book vignette in soft chalk pastel and a little gouache on pure white paper — a person and an animal companion, half-length, with no background panel and no frame: the painting simply stops and its edges break up into the white in dry strokes. The colour is soft and powdery (powder blue, cream, warm skin) with one warm accent family (ginger, tangerine); faces are rubbed smooth, with big round eyes, very large rosy cheeks and a red-tipped nose; hair and fur are hundreds of fine strands. The paper has an equalised tooth, and the same tooth is pre-dragged along 8 directions (stored as uint8), so pastel catches where the tooth rises above 1 − pressure and the pits it skips are drawn out along each stroke. Every *segment* of every stroke gets its own id in a 2× supersampled integer map, and numpy looks each covered sub-pixel up to its segment. From there it recovers the position along the stroke, for a pressure profile with rounded ends, and across it, for soft sides and bristle lanes that open up as the stroke runs dry. Pigment is laid where the pressure reaches the tooth and summed back with bincount, so tens of thousands of strokes cost about one Pillow line per segment. Pastel is nearly opaque, so pale dry strokes sit on a darker coat. `wash()` is pastel rubbed in with a finger: a smooth coat whose colour can come from a light field, with the deepest pits left a touch lighter and an edge that breaks into the tooth. `model()` washes a dark → light ramp over a soft dome light. A coat fades out through a smooth field, and its dry strokes run on past it, drying out pixel by pixel. `strands()` traces hair through a flow field and groups it into locks that share a root area, a wander, a curl and a shade; it paints dark first and lets a few fly loose. `fur()` lays tufts that are darker on the side away from the light, and `fluff()` grows short strands out of a silhouette, coloured from the paint just inside, so fur melts into what is behind it. Faces come from `eye()` (an off-white ball shaded blue-grey under the lid, a rayed iris with a pupil and two catchlights, a soft lid line flicking out at the outer corner), `blush()`, `nose()` (a side shadow and a red tip), `mouth()` and `brow()`. It also has a faint pencil line for background sketches, and leaves and sprigs |+| **Poetic Halloween (诗意万圣夜)** | `lib/poetichalloween.py` · `PoeticHalloween` | a melancholic, slightly surreal picture-book portrait for an autumn night, in opaque gouache and fine pencil hatching on a dark toned board, then printed. Faces are pale porcelain with a strong red flush on the nose, the cheeks and the lids and round the eyes, heavy half-closed sad eyes, a small unsmiling mouth and very simplified volumes. The hair is one sculpted mass — a blunt jet-black bob with a dead-straight fringe and a soft sheen. The cloth is tactile (burlap and felt hats, chunky knits, tartan), the ground is dark (night indigo, stars, dense leaves), and there is one luminous accent: little sheet-ghosts with glowing eyes and glowing fringe tips. Strokes use the same per-segment id map as the pastel vignette (wide for dry gouache, thin and long for hatching), and `colour='canvas'` lets each stroke take the colour under its centre, which repaints a computed base (a tartan, a modelled face, the sky) by hand without changing its colour. `model()` washes a dark → light ramp over a soft dome light, which gives the simplified volumes. `sheen()` lays a soft band where that light falls in a narrow range, then streaks it along the hair with a few long faint strokes, so the bob stays one mass. `eye()` is a heavy-lidded almond: the lid covers about half the iris and droops at the outer corner, with a dark lid line, a red wet rim on the lower lid and, optionally, the warm glint of a light below. `flush()` is a smooth red glaze plus a stipple of single specks that gets denser as the flush gets stronger, and `nose()` is its own small volume with a red tip. `burlap()` is a plain weave of slubby threads, each row and column with its own thickness, wandering a little and going over and under. It is lit as a height field, with dark holes, loose fibres and a frayed edge, and it can follow a curve. `knit()`, `rib()` and `tartan()` (a mirrored sett woven 2/2 twill over the light of the folds) cover the rest of the cloth. `leaf()` is a broad, double-serrated palmate leaf, foreshortened and folded along its midribs; it casts a soft shadow on the leaves behind, and that is where a hedge's depth comes from. Warm point lights fall off steeply, and `illuminate()` lights what is already painted as 1 − (1 − C)·exp(−L·receptivity·(base + albedo·C)), so wool and porcelain warm up a lot, leaves near a ghost turn olive-orange and black hair barely changes. `ghost()` is a translucent dome-and-bell of silver strands that falls from the crown like hair, with glowing eyes and a bead of light at the end of every lock. Bloom, a fine print grain and a coarser printed tooth that shows in the darks are added in `render()` |Ask Claude to *"draw it yourself"*, *"paint this with code"*, or *"claude绘图"*, and name a style if you like. Claude then:@@ -427,6 +430,14 @@ Every style has a complete example: `python3 examples/<name>.py out.png --stages- a coat that ends in a torn edge or a band of speckles reads as torn paper or frost, and dry strokes dragged straight down are drips — fade the rubbed colour smoothly and let a few dry strokes run on past it along the drape;- separate lashes are a comb, and white all round the iris is a stare — use a thick lid line with a flick and let the lid cover the top of the iris;- eyes low in a round face make a child — for an adult, put the eye line at the middle of the head and narrow the jaw.+- **Poetic Halloween**: keep the picture dark and quiet, and give it exactly one light — the ghosts' warm glow, falling off steeply so it warms only what is near. Keep the face pale and simple and put the drama in the red round the eyes, the heavy lids and the red nose. Keep the hair one mass and the texture in the cloth. Watch for accidental reads:+ - a ghost's light that reaches across the whole hedge turns the night into an olive-and-orange afternoon — use a steep falloff and a radius of about the ghost's width, and take the receptivity from a blurred hedge mask (a hard edge leaves a bright band along its top);+ - two blotches of coarse red specks under the eyes are a rash — make the flush mostly a smooth glaze in a band round and under the eyes and over the bridge, with fine single-pixel specks, and only a light speckled flush on the cheeks;+ - a red dot is not a nose — model a small volume down the face with a mauve shadow side and let it redden toward the tip;+ - a tall pointed hat reads as an elf's, and a soft tube for a drooping tip reads as a horn or a teapot handle — a low, slouchy cloche with a frayed brim reads as burlap; whole rust-coloured threads in the weave read as seams;+ - a hair curtain darkened all round its edge is a headphone, and a plain black fringe is a visor — light the whole bob as one mass, darken only the edge against the cheek and give the fringe its own band of sheen;+ - cupped mittens read as a crab, and mittens that hide the jar hide the point — hold the jar low from the sides, with the thumbs in front;+ - flat-shaded leaves all seen face-on are clip art — broaden the lobes, foreshorten each leaf and let it cast a soft shadow.### Roadmap@@ -438,7 +449,7 @@ Every style has a complete example: `python3 examples/<name>.py out.png --stages### 这是什么-一个 [Claude Code](https://claude.com/claude-code) skill,加上一个小巧的绘图库,内置七十六种画风:+一个 [Claude Code](https://claude.com/claude-code) skill,加上一个小巧的绘图库,内置七十七种画风:| 画风 | 模块 | 为什么看起来像真的 ||---|---|---|@@ -518,6 +529,7 @@ Every style has a complete example: `python3 examples/<name>.py out.png --stages| **暖调彩铅绘本** | `lib/pencilbook.py` · `PencilStorybook` | 暖白、有齿纹的纸上一层层叠涂的彩色铅笔童书页:黄昏里一只大而温柔的生物和一个小小的孩子。纸纹直方图均衡过、以 1 px 细颗粒为主;蜡挂在纸纹高于 1 − 压力的地方,纸坑里也留一点,蜡层缓冲让后面的笔越叠越能压进纸坑——所以同一批纸坑一层层都透出细白点(越来越带色),只有压得重、叠得多的地方才合上。一笔是在方向场里积分出来的中心线(方向按 mod π 处理),带一点手腕的弧度;几万笔一次画完:每一笔当折线按序号画进 2 倍超采样的整数 id 图,numpy 只对被盖住的子像素查回这一笔的颜色、起点、方向、长度、压力和收笔,算出像素在笔上的位置(落笔重、收笔挑),蜡只落在压力够得着、沿这一笔方向拖开的纸纹上,再用 bincount 汇回像素。落笔位置用抖动网格,区域既是落笔概率也是逐像素的压力,所以暗部是平滑过渡而不是散落的深色短线;`avoid` 把后面要画的东西先留白,像画家铺天空时把主体空出来。蜡是半透明的(目标 = 旧 × 颜色 / 纸色,再按 opacity 往颜色靠):黄盖在蓝上变绿,同色越叠越深,浅色盖深色要压光。`form()` 照彩铅画家的方式塑形——浅色底层、固有色、同色系的暗部、核心最深处,再在受光一侧罩暖色、阴影里罩冷色——每层绕着形体自己的方向错开几度:沿着穹顶的等值线、绕着龟壳每块盾片、横过脖子的褶、顺着雨衣的衣褶。毛一绺一绺地画:根部散开、尖端聚拢、一起微弯,背光一侧暗一点;草反过来往上散开;树冠是一团团分别打光的短弯叶片笔触。暖光是顺着表面的一层层橙黄笔触加一层纸面提亮——不放射、也不是平滑光晕;倒影是取水线以上镜像颜色的横排线。附带绘本部件(树、亮灯的小房子、石头、鳞片、野花、纸灯笼、穿雨衣的波波头小孩,点点眼和腮红),收尾是轻微柔化、细颗粒和很淡的暖色暗角。没有墨线,没有黑色 || **彩色小镇** | `lib/colortown.py` · `ColorTown` | 不透明水粉平涂加细细的深棕墨线画的童话山城:番茄红、芥末黄、青绿、薄荷、珊瑚、奶白的窄高房子一排压一排堆上山坡,深蓝灰的石板曼莎屋顶,一座白色钟楼,好几层三角彩旗斜穿街道,爬藤玫瑰、窗台花箱,前景的湿广场把这一切倒映下来。每一块颜色都是一个多边形:几万块一次画完,Pillow 把每块按序号填进 2 倍超采样的整数 id 图,numpy 对每个 id 查一张颜色、不透明度、纹理权重表,再 box 平均回像素,所以边是抗锯齿的,画的先后就是序号的先后。整张画布预先算好三张纹理场(竖向笔刷条纹、横向笔刷条纹、各向同性的擦笔)加一层低频斑驳,每块颜色只差百分之几:墙以擦笔为主、带一点竖向笔刷,天空和铺地偏横向,浅色的纹理少一些,白墙才干净。边缘重采样后沿法线推一点平滑的抖动,没有尺子画的直线,颜色和描线也不完全对齐。墨线是深暖棕,每组颜色画完再画这一组的线:每条线在 3 倍 id 图里有自己的序号(交叉处不叠出墨珠),分成几段、粗细略有变化,方框四边分开画、转角偶尔出头;墨半透明,在红墙上是深红棕,在玻璃上近乎黑。`house()` 用几个数搭出一栋联排房子。墙是带裸石斑块的灰泥,有腰线、檐口,墙脚一层薄罩染,檐下一道淡阴影。底层是门、带字招牌和条纹遮阳篷的店面,或者拱门。楼上的窗格子每扇都略有不同:奶油色窗框,深青绿玻璃上一道浅色反光,窗棂、窗台,部分窗户有带横条的百叶窗,部分挂窗帘。窗台花箱的花叶溢出来,铁艺阳台后面摆着花盆。屋顶的石板一片片错缝铺上去,每片蓝灰各不相同,裁进屋顶、描出缝;有曼莎、四坡、侧山墙、尖山墙,带老虎窗、带赤陶帽的烟囱和电视天线。`plane()` 用透视单应把一块平摊的立面贴到四边形上,整面峡谷墙连窗、花箱、玫瑰一起往消失点收。远近靠雾化、尺度和从后往前的遮挡,几乎没有投影。玫瑰是成对小叶里的不规则杯形,花心深一点、描几道花瓣弧线;树冠是一团团叶片,每团按左上来光当穹顶打光;彩旗绳按抛物线下垂,三角旗挂在绳上,每面有一道深一点的折痕。湿街按每一列的墙脚线把画面镜像下来,加涟漪,离墙脚越远竖向拖得越长,压暗后拖成竖条混进浅色石板,再淡淡地重描石板缝;`mirror()` 把之后画的东西(人、路灯)也倒映下来。附带洋葱顶、木百叶钟楼开口的钟楼,越往上越小的台阶、石墙、铁栏杆、路灯、吊挂店招、海报、咖啡桌、猫和不画脸的小人 || **色粉小像** | `lib/pastelvignette.py` · `PastelVignette` | 白纸上的绘本角色小像,软色粉加一点水粉:一个人和他的小动物,半身,不画背景色块、不加边框,画到边上就停,颜色干笔散进白纸。颜色柔和、粉粉的(粉蓝、奶油、暖肤色),只有一组暖橙饱和;脸揉得平滑,大圆眼、一大圈腮红、红鼻尖;头发和毛是成百上千根细丝。纸纹直方图均衡过,另外预先算好沿 8 个方向拖开的纸纹(存成 uint8):色粉挂在纸纹高于 1 − 压力的地方,漏掉的纸坑顺着笔拉成短道。每一笔的每一段在 2 倍超采样的整数 id 图里有自己的序号,numpy 对被盖住的子像素查回这一段,算出沿笔位置(两头收圆的压力曲线)和横向位置(两侧软边、越干越开的鬃毛条纹),压力够得着纸纹才上色,bincount 汇回像素,几万笔只要每段一次 Pillow 画线。色粉近乎不透明,浅色干笔能压在深色上。`wash()` 是手指揉开的色粉:平滑的一层,颜色可以按受光场取,最深的纸坑留一点浅,边缘按纸纹断开;`model()` 按软穹顶光把暗 → 亮的色阶揉上去。大衣用一张平滑的渐隐场收掉,干笔在它下面再走一段、逐像素变干。`strands()` 沿流向场画发丝,按绺分组(同一绺共用起点、偏移、弯曲和明暗),暗先亮后,几根飞出轮廓;`fur()` 是背光一侧暗的毛簇;`fluff()` 从轮廓里侧往外长短丝,颜色取它里面的颜料,毛茸茸的边融进后面的东西。五官:`eye()`(米白眼球、眼皮下灰蓝的影子、带放射纹的虹膜、瞳孔、两点白高光、外眼角挑出的软眼线)、`blush()`、`nose()`(鼻梁软影加红鼻尖)、`mouth()`、`brow()`。附带背景草稿用的淡铅笔线、叶子和枝条 |+| **诗意万圣夜** | `lib/poetichalloween.py` · `PoeticHalloween` | 秋夜 / 万圣节的忧郁、带一点超现实的绘本肖像,暗色画板上的不透明水粉加细彩铅排线,再印出来:瓷白的脸,鼻子、脸颊、眼皮和眼睛四周泛着很重的红晕,半闭的厚眼皮,不笑的小嘴,体积极简;头发是一整块雕塑般的实体——刀切齐刘海的乌黑波波头,一道柔和的光泽;衣物是摸得着的织物(粗麻 / 毛毡帽子、粗针织、格子呢);底子是靛蓝夜空、星星和浓密的叶丛;只有一处发光的点睛:眼睛和衣摆尖发着暖光的床单小幽灵。笔触和色粉小像同一套按段编号的 id 图(宽的是水粉干笔,细长的是排线),`colour='canvas'` 让每一笔取它中心下面的颜色,把算出来的底子(格子呢、塑形过的脸、夜空)用手再画一遍、颜色不变。`model()` 按软穹顶光揉色阶,就是那种极简的体积;`sheen()` 只在受光落在一条窄带里的地方铺一层柔和的光泽,再顺着头发拉几笔又长又淡的笔触,波波头仍是一整块。`eye()` 是重眼皮的杏仁眼:上眼皮盖住约一半虹膜、往外眼角垂,深色眼线,下眼睑一道湿红,还可以映出下面那盏光的一点暖色;`flush()` 是平滑的一层红加一层单像素的细斑点,越红越密;`nose()` 自成一个小体积,红鼻尖。`burlap()` 是粗麻平纹:每行每列线各自粗细、有疙瘩、略游走、一上一下交织,当高度场打光,线间是黑孔,有松出的纤维和毛边,能顺着弧线织;`knit()`、`rib()`、`tartan()`(镜像 sett、2/2 斜纹、乘衣褶的受光)管其余的织物。`leaf()` 是宽裂片、重锯齿的掌状叶,随机压扁、沿中脉对折,往后面的叶子投一块软影子,树丛的层次就从这里来。暖色点光源衰减很陡,`illuminate()` 按 1 −(1 − C)·exp(−L·接受度·(base + albedo·C)) 照亮画好的东西:毛线和瓷白的脸变暖很多,小幽灵旁边的叶子变成橄榄橙,黑头发几乎不变。`ghost()` 是银色细丝组成的半透明圆顶钟形,像头发一样从头顶披下,发光的眼睛,每一绺末端一颗光珠。光晕、细的印刷颗粒和暗部更显的粗印刷纸纹在 `render()` 里加 |对 Claude 说「claude绘图」「你自己画」「用代码画」,也可以指定画风。它会:1. **先定构图**:层次、焦点、留白,而且画面要图解内容本身;@@ -623,6 +635,7 @@ python3 examples/flexoki_pour_over.py out.jpg --stages stages/ # Flexoki 纸python3 examples/pencilbook_tortoise_crossing.py out.jpg --stages stages/ # 暖调彩铅绘本:大龟过河python3 examples/colortown_festival_steps.py out.jpg --stages stages/ # 彩色小镇:雨后的节日台阶街python3 examples/pastelvignette_marmalade_scarf.py out.jpg --stages stages/ # 色粉小像:橘猫围巾+python3 examples/poetichalloween_ghost_jar.py out.jpg --stages stages/ # 诗意万圣夜:罐子里的小幽灵```### 作画要点(Claude 交图前逐条自查)@@ -765,6 +778,14 @@ python3 examples/pastelvignette_marmalade_scarf.py out.jpg --stages stages/ #- 大衣收在一条撕纸边或一圈白点上,就是撕纸或结霜,干笔直直往下拖是流下来的颜料——揉色平滑地淡掉,再让几笔干笔顺着衣摆多走一段;- 一根根的睫毛是一把梳子,眼白一圈包着虹膜是瞪眼——用一道粗的眼线在外眼角挑出去,上眼皮盖住虹膜上沿;- 圆脸里眼睛偏下就是小孩——画大人要把眼线放在头的正中间,下巴收窄。+- **诗意万圣夜**:画面要暗、要静,只给一处光——小幽灵的暖光,衰减要陡,只暖身边的东西。脸苍白、简单,戏都在眼睛一圈的红、厚眼皮和红鼻头上;头发是一整块,质感留给衣物。小心看错:+ - 小幽灵的光照满整片树丛,夜晚就成了橄榄绿加橙色的下午——衰减要陡,半径约一个身宽,接受度用模糊过的树丛遮罩(硬边会在树丛上沿留一条亮带);+ - 眼睛下面两块粗的红斑点是疹子——红晕大部分是平滑的一层,绕着眼睛(下半圈更浓)、跨过鼻梁,斑点要单像素的细,脸颊上只铺一层很淡的斑点红;+ - 一个红点不是鼻子——顺着脸往下塑一个小体积,背光一侧紫灰,越往鼻尖越红;+ - 高高的尖顶帽像精灵帽,拿一截软管当耷拉的帽尖像犀牛角、像茶壶把——低圆顶、帽檐带毛边的软塌钟形帽才像粗麻;织纹里整根的锈色线像缝线;+ - 一圈都描了暗边的那片头发像耳机,纯黑的刘海像护目镜——整块头发按同一个受光,暗边只留在挨着脸的内侧,刘海单独一条光泽;+ - 捧在一起的手套像螃蟹,挡住罐子的手套挡住了重点——从两边扶着罐子下半截,拇指搭在前面;+ - 正对着看、平涂的叶子是剪贴画——裂片加宽,每片压扁一点,再往后面投一块软影子。### 计划diff --git a/SKILL.md b/SKILL.mdindex d9e056e..c8e63b4 100644--- a/SKILL.md+++ b/SKILL.md@@ -1,6 +1,6 @@---name: claude绘图-description: Claude 绘图 / Claude Drawing —— 不借助任何生图模型,由 Claude 用代码一笔一笔「画」出图片(程序化绘画)。内置七十六种画风:中国水墨、水彩、剪纸拼贴、韩国彩铅、日本动漫、编辑风手绘(Riso)、油画厚涂(梵高式流向笔触+颜料浮雕打光)、浮世绘木版画(晕色、木纹、墨线主版、青海波)、像素风(低分辨率+Bayer 抖动+像素字体)、黏土定格(高度图捏出的彩泥+影棚打光)、蓝晒(普鲁士蓝日光晒图,植物剪影透光)、十字绣(Aida 布十字绣+回针绣+缎面绣+法式结)、复古仪器面板(60 年代收音机/仪器正面:柚木、拉丝铝、旋钮、刻度窗、指示灯)、贴纸拼贴·小票(模切乙烯贴纸、热敏小票、和纸胶带、吊牌、橡皮章)、实验笔记本·贴纸(线圈方格本、铅笔图表、荧光笔、红笔圈、便利贴)、黑板板书(墨绿石板、粉笔颗粒、板擦残影、示意图与公式)、赛博朋克(雨夜霓虹街道、玻璃管霓虹招牌、全息广告、湿路面倒影)、卡通手绘(蓝铅笔稿、毛笔线、错位平涂、赛璐璐阴影、逐帧抖线)、等轴 2.5D(正等轴微缩模型、一个太阳照出三面明暗、悬浮数据卡)、单线画(一根不断开的线一笔画完、唯一点睛色)、柔光 3D(光线追踪的糖果色小球海和鼓鼓的软字、景深)、形变动画(一条轮廓依次变形、洋葱皮残影、缓动曲线)、报刊拼贴(牛皮纸、手撕旧报纸、网点老照片、勒索信拼贴字)、弥散玻璃(弥散渐变、磨砂玻璃卡片界面)、包豪斯几何(三原色几何、丝网印刷海报)、复古 Synthwave(切口落日、霓虹网格、镀铬字、录像带质感)、拼豆(钉板上的熔珠小管、熨烫熔合)、岩画(沙漠漆上凿出的凹坑图形、新旧凿痕、剥落)、古埃及墓室壁画(灰泥墙、红格起稿、分栏叙事、象形文字、剥落)、罗马马赛克(石子与玻璃沿轮廓一排排铺、灰缝、燕尾铭牌)、彩色玻璃花窗(哥特尖拱窗、通体着色玻璃、grisaille 彩绘与银染、铅条、透光)、泥金手抄本(羊皮纸、鹅毛笔哥特体、朱红标题、打磨金箔首字母)、达·芬奇手稿(铁胆墨水、左手排线、红粉笔、镜像手写、机械分解图)、剪影(黑纸剪出的侧影小像、薄金粉、椭圆金框)、凸版印刷海报(木活字、红黑双色错版、木刻插图)、苏联构成主义(红黑两版、斜条与楔形、西里尔大字、网点照片拼贴)、装饰艺术 Art Deco(1930 年代喷枪流线型海报、交替射线、阶梯高楼、金色 Deco 字)、黄金时代漫画(毛笔墨线、Ben-Day 网点、四色错版、新闻纸)、波普丝网(多格撞色平涂 + 错位的照相黑版)、ASCII 字符画(行式打印机、绿条连续纸、叠打)、低多边形(1999 年代 3D:平面着色、仿射贴图、逐顶点雾、15 位色抖动)、喷漆模板涂鸦(混凝土墙上多层卡纸模板喷绘、雾化与滴痕)、刺绣徽章(牛仔布上的机绣徽章:填充绣、缎面绣、锁边)、蓝图工程图(描图墨线晒成蓝底白线)、儿童蜡笔画(小孩在糙纸上的蜡笔涂抹)、绿屏终端 CRT(荧光字符画、扫描线、余辉)、热成像(先画温度场再上伪彩色)、代尔夫特蓝瓷砖(锡釉砖上的钴蓝手绘)、洞穴壁画(火光下的赭石、吹喷手印)、1-bit 早期画图软件(黑白整屏、8×8 图案填充)、古希腊黑绘陶瓶(黑釉剪影、刻线、饰带展开图)、铅笔素描(石墨排线、擦笔、边缘只剩线稿)、X 光片(安检透视、轮廓发亮、伪彩)、1930 年代黑白橡皮管动画(白手套、饼切眼、老胶片)、黑白麻胶版画(刻刀减法、手拓发花、套色错版)、VHS 家庭录像(钨丝灯偏色、色度渗色、REC)、扁平矢量(分层几何色块、七色、层间投影)、绘本角色动画(小角色挤压拉伸的真动画)、圆珠笔涂鸦(蓝红圆珠笔线稿、墨团、彩铅、页边涂鸦)、描图纸叠层(灯箱上的黑线底图 + 一张张单色描图纸叠片:正片叠底、套准十字、定位钉、绘图胶带)、粉彩界面 · Pastel UI(产品发布片式的界面画面:纯色粉彩底与大光斑、macOS 窗口卡片、胶囊与粗黑标题色条、状态标签与 ✓ / ✗ 徽章、放大镜、从卡片边探头的扁平小图标)、阅卷批改 · Exam Grading(绿毛毡桌上被红笔批改的答题卡:定位黑块、考号涂卡、得分格与阅卷栏、长尾夹夹住的标准答案卡、油墨不均的朱红印章、立体红笔、波浪线 / 圈 / 引线 / 批注 / 叉 / 圈起来的分数)、皮影戏 · Shadow Puppetry(油灯照亮的幕布上,雕空、透明染色的驴皮关节人偶:镂空纹样、阳刻空脸、雉翎盔头、线结与操纵杆、离幕时虚化的双影;雕花戏台、红漆金字牌匾、红灯笼)、钢笔淡彩 · Pen & Wash(速写小卡上的针管笔线稿 + 松散淡彩:线条抖、出头、不闭合,颜色错位出线、留白缝、干边与颗粒,不铺满的背景色块;大头、圆眼镜、点点眼、红鼻子的呆萌小人;卡片拍在木桌上,旁边放着针管笔和水笔)、复古水粉 · Retro Gouache(复古绘本风的水粉大头像:不透明水粉从暗到亮一层层盖上去,单色背景用干笔皴擦;大红鼻子、腮红、圆眼和大耳朵用几阶色值塑出来;看得见针脚的毛衣和毛线帽,一根根的头发和胡子,毛毡;最后是印刷书页的纸纹)、蓝调绘本 · Blue Picture Book(软蓝色调的现代绘本跨页:几乎只用粉蓝、矢车菊蓝、深青蓝三阶蓝加黑墨和纸白,只点一点珊瑚红、粉色腮红和芥末黄;毛笔 / 墨铅笔线干、抖、断,粗细不匀,线不闭合,暗部用快速来回的乱线排出来;颜色是干蜡笔、粉彩、干水粉,错位出线,纸纹的白点透出来;白粉笔痕压在蓝上,甩点和细尘;背景蓝块毛边、不到纸边;大圆脑袋、带高光的点点眼、点彩腮红和雀斑、火柴腿穿靴子的小人,乱线毛边的白色毛绒动物;最后印在书上:中缝和页码)、江南园林 · Jiangnan Garden(细笔园林春景,数字水粉插画:成千上万片叶形小笔触按一个太阳堆出树冠,暗芯、亮边、一簇簇的高光;白色和淡粉的繁花是一簇簇圆点花瓣,枝条从缝里露出来;垂柳是一绺一绺发丝般的细枝挂满小叶;黛瓦飞檐是真的瓦垄:筒瓦板瓦一行行、檐口瓦当滴水、翘起的翼角和卷起的脊头;粉墙月洞门、冰裂纹漏窗、翡翠绿槅扇和挂落、红灯笼、匾额;九曲石桥、石阶、小木船;碧绿湖面倒映岸上的一切,更柔、更暗,加涟漪和细竖纹;睡莲、白鹭;从前景花枝到雾里青山层层退远,墙上桥上落着叶影;最后一方小红印)、干刷色块 · Dry-Brush Blocks(mid-century 海报 / 水粉拼贴式的编辑插画:米白纸上几大块干笔或滚筒刷出的色块,颜色严格限定在森林绿、鼠尾草绿、青蓝、藏蓝、近黑和朱红,外加一点天蓝、淡青瓷和米色;每块颜色在自己的笔刷坐标系里刷:一道道平行的笔,起笔饱满、收笔干枯,两侧几乎是直边,两端梳成长短不一的毛齿,块里有顺笔的鬃毛纹、皴擦斑和露出来的纸色;背后的大色板用滚筒:近乎平涂、成簇的细点、干的两侧和几道细刮痕;色块像丝网套印或撕纸拼贴一样叠起来,撕口带一圈浅色纤维边;人物拆成几个大块面:亮暗两半朝不同方向刷的外套、几块肤色平面拼的头、粗黑框眼镜、干笔皴擦的白胡子;瓶子是竖刷的深色剪影加一道高光和小块标签;一旁一个小朱红方块;不勾线、不做渐变;最后像胶印:轻微柔化、纸纹、暗部零星白点、纸上细尘)、暮色微缩绘本 · Twilight Storybook(温柔、怀旧的黄昏绘本单页,满是微缩细节:大片粉彩黄昏天空,从顶上的薰衣草紫经玫瑰、蜜桃到地平线的暖金,柔和的平底云带、细细的光线和一轮低垂的淡日;一侧天空已经入夜:星空、带暗带的银河、弯月、流星,昼夜交界经过淡紫和靛蓝,不发灰;下面是一层层粉彩条纹的起伏山丘,拼布似的田、细细的垄、小圆树;前景是几万朵小野花铺成的坡,坡顶是色点,越往下越大:雏菊、矢车菊、虞美人、波斯菊、金盏花、毛茛、羽扇豆、勿忘我,夜的一侧整片变成月光蓝;很小、扁平、可爱的原创角色;上面叠一层科学图版的语言:圆形的「detail a」放大图,细墨线、排线、尺寸标注、标签和比例尺,几行灰色的小写英文手写字;最后是细颗粒、光晕、暗角和底边一道撕纸边)、排线夜景 · Hatched Nocturne(彩铅 / 色粉排线式的小幅夜景版画:天空、云、山和海全由密密的短笔触叠成,每片区域的笔触顺着同一股「风」走——天空斜着流、蒸汽绕着云团卷、山坡顺着坡向、海面横着长拖,每一笔色相和明度都差一点,笔毛分道、拖干的笔尾、纸纹里漏出的细缝,没有一处平滑渐变;深靛蓝、藏青、冷灰蓝的夜色里只有一个暖色光源,光是一层层加上去的发光笔触:核心黄白、外圈橙红、再外是被照亮的笔触,被照亮的蒸汽按「光 × 受光」上色,所以是红橙而不是粉;发光的细丝(会蜿蜒、分股、末端亮珠)、火星、星点;海面上被横向笔触打碎的倒影和光柱;几十像素高的小人靠一点亮色(围巾)点出来;最后装裱成小版画:米白纸边、压印的版痕、左下铅笔小标题、右下更小的说明,用细的普通字体)、笔记应用界面 · Obsidian UI(讲解片里的深色笔记应用窗口:近黑页面上一团淡紫光晕,窗口里有标签栏、细长图标栏、带缩进线的文件列表、粗黑 H1 下一道紫色短条、属性块和 #标签、紫色的内部链接和行内代码、带语法色的 mermaid 代码块——点「阅读」后渲染成扁平深色的流程图,一个节点亮紫——紫色左边的引用标注,右栏关系图谱里被链接的笔记亮成紫色光点;全画只有一个紫色强调色,不画官方 logo)、白板卡片 · Canvas Board(深色笔记应用的白板视图:深色页面上一扇应用窗口——红黄绿三点和「.canvas」标签页的标签栏、左边一列线性图标——里面是一块随镜头平移缩放的灰点阵无限白板;分组框和浮在框上方的组名,深色圆角卡片带 2 px 的卡片色边(红、橙、黄、绿、青、紫)和一层很淡的同色底,卡片之间是从边的中点沿法线弯出去的曲线连线,末端实心箭头、中间一块白板底色的标签;卡片里是 Markdown:标题、正文、紫色高亮、等宽行内代码、勾选清单(勾上时紫色方框弹出、对勾画出、文字变灰加删除线)、紫色竖条的引用、紫色标签胶囊、颜色编号胶囊;图片卡片上方写文件名,里面可以用手绘笔触画草图(每笔画两遍、略弯、出头,手写体批注);右上角一列缩放按钮;全画只有一个紫色强调色加卡片色;所有东西都记在白板坐标里、每次按镜头重画,任意缩放都锐利,镜头能平移缩放、卡片能掉落、连线能一点点画出来)、Flexoki 纸面 · Flexoki Paper(文档站式的图解页:暖白纸 #FFFCF0 上的墨黑字和一串暖灰,几张不描边、不投影的浅灰圆角卡片,粗黑中文标题、灰色英文类型名、等宽编号;卡片里的图照轻量图表渲染器的样子画——比底色差一级的框和 2 px 灰边(直角、圆角、胶囊、菱形、圆柱、圆)、墨线末端一个小的实心三角箭头、普通半粗体标签垫一块底色,虚线生命线和回复、带纸色缝的饼图、细网格上的柱状图、表头着色的对比表;Flexoki 的橙、红、蓝、绿、紫、青只放在有意义的地方,橙色聚焦框、黑底胶囊、字距收紧的大数字;能做成图一边一边画出来、数字滚动的动图)、暖调彩铅绘本 · Warm Pencil Storybook(暖白、有齿纹的纸上一层层叠涂的彩色铅笔绘本页:天空、山坡、草、水、一只大而温柔的生物和一个小小的孩子,全由顺着形体走向的细铅笔线叠成——天空横向长排线,山坡顺着坡势,龟壳绕着每块盾片的生长纹,脖子横过褶皱,雨衣顺着衣褶,苔藓和头发一簇簇顺毛;每块先铺一层浅色底,再上固有色、背光处叠同色系的深色,受光处罩一层暖色、阴影里罩一层冷色,每层角度错开一点、笔触交叉;蜡只挂在纸齿的峰上,同一批纸坑一层层都透出细白点,压得重、叠得多的地方才慢慢合上;后画的东西先留白再铺背景,颜色不互相混;毛是一绺一绺的:根部散开、尖端聚拢、顺着毛向,每绺受光一侧亮、背光一侧暗;没有墨线、没有黑色,只有很淡的同色轮廓;黄昏的暖光:灯笼和窗灯是一层层橙黄的发光叠涂(不是一团光晕,也不是放射线),低低的太阳给受光一侧一道暖边;水里的倒影也是一笔笔横排线;附带树、小房子、石头、鳞片、野花、纸灯笼和穿雨衣提灯笼的小孩等绘本部件)、彩色小镇 · Colour Town(不透明水粉平涂加细细的深棕墨线画的童话山城街景:高高窄窄的房子漆成番茄红、芥末黄、青绿、薄荷、珊瑚、奶白,一排压一排堆上山坡,近大远小、前后遮挡;深蓝灰的石板曼莎屋顶是一片片瓦错缝铺出来的,带老虎窗、烟囱和赤陶烟囱帽、电视天线;白色钟楼、淡蓝的天和奶白的云;三角彩旗串在好几层深度上斜穿街道,远处的小、近处的大,每面旗有一道深一点的折痕;红色爬藤玫瑰、溢出来的窗台花箱、铁艺阳台、石头台阶和扶手、路灯、吊挂的店招、拱门和彩色木门、写着字的店面和条纹遮阳篷;前景是湿亮的街面,把整条街倒映成一道道竖向的笔触;每块颜色都是带一点笔刷纹理的不透明平涂,边缘像手画的那样微微抖,和描线不完全对齐;墨线分成几段、粗细略有变化,方框的转角偶尔出头;墨是半透明的,压在红墙上是深红棕,压在玻璃上近乎黑;窗户排得整齐,但每扇都略有不同;一整面墙可以用透视单应贴成往消失点收的峡谷墙;几乎没有投影;附带钟楼、台阶、矮墙、栏杆、树、花盆、彩旗、路灯、店招、海报、咖啡桌、猫和概括的小人等部件)、色粉小像 · Pastel Vignette(白纸上的绘本角色小像,软色粉加一点水粉:一个人和他的小动物,半身、略偏一边,四周大片留白,不画背景色块、不加边框,画面在边上用干笔散开、融进白纸;颜色柔和、粉粉的——浅粉蓝的衣服上看得见顺着衣褶的干笔、奶油色的毛衣、暖肤色——只有一组暖橙饱和(橘猫、绒球、蝴蝶结这类);脸是揉开的平滑色粉:大圆眼、深色虹膜和两点白高光、一大圈腮红、红鼻尖、小嘴;头发和毛是成百上千根细丝,一绺一绺,有几根飞出轮廓,毛的轮廓蓬松地融进后面的东西;几乎不描线,只有眼皮、鼻翼、脸的背光侧几道细的软线;背后至多一枝叶子和一层很淡的铅笔小镇;附带圆眼、眉毛、腮红、鼻子、嘴、发丝、毛簇、蓬松轮廓、叶子和枝条等部件)。用户说「claude绘图」「用代码画」「你自己画」「不用生图模型画」「程序化绘画」,或点名以上任一画风(含黏土、彩泥、定格动画、蓝晒、晒图、十字绣、刺绣、复古面板、老式收音机、贴纸、小票、收据、手帐拼贴、实验笔记本、方格本、荧光笔、便利贴、黑板、板书、粉笔、赛博朋克、霓虹、雨夜街道、卡通、手绘卡通、逐帧手绘、抖线、等轴、2.5D、微缩模型、单线画、一笔画、线条动画、柔光 3D、3D 渲染、C4D 风、软糖字、小球海、形变、变形动画、报刊拼贴、剪报、达达、勒索信字、网点印刷、弥散渐变、玻璃拟态、毛玻璃、包豪斯、几何构成、丝网印刷、Synthwave、蒸汽波、合成器浪潮、80 年代复古、拼豆、拼拼豆、熔珠、熨豆、豆豆画、钉板、烫豆、岩画、岩刻、凿刻、石刻、沙漠漆、史前壁刻、大角羊、古埃及、埃及壁画、墓室壁画、法老时代、象形文字、尼罗河、底比斯、罗马马赛克、马赛克镶嵌、镶嵌画、石子拼画、地砖画、古罗马地板、彩色玻璃、彩绘玻璃、花窗、玻璃花窗、教堂花窗、哥特花窗、铅条玻璃、泥金手抄本、手抄本、彩饰手抄本、中世纪手稿、羊皮纸、哥特体、花体首字母、泥金、贴金、星盘、达芬奇、达·芬奇、达芬奇手稿、手稿风、文艺复兴手稿、发明手稿、镜像字、镜像书写、扑翼机、红粉笔、钢笔排线、机械草图、分解图、剪影、剪影肖像、侧影、侧面像、黑纸剪影、剪影小像、椭圆金框、乔治时代肖像、摄政时期肖像、凸版印刷、活版印刷、木活字、铅字海报、马戏团海报、复古海报、老海报、19 世纪海报、双色套印、错版、套色错位、木刻插图、构成主义、苏联海报、苏联构成主义、俄国先锋派、罗德琴科风、红黑海报、照片蒙太奇、照片拼贴海报、西里尔字、装饰艺术、装饰风、流线型、流线型海报、1930 年代海报、旅行海报、铁路海报、火车海报、喷枪画、喷笔画、阶梯高楼、射线背景、盖茨比风、黄金时代漫画、老漫画、复古漫画、美漫封面、漫画封面、Ben-Day 网点、本戴点、网点上色、四色印刷、四色错版、新闻纸、对白框、拟声字、1940 年代漫画、波普、波普艺术、波普丝网、沃霍尔风、丝网版画头像、撞色头像、多格重复头像、六宫格撞色头像、ASCII、字符画、字符艺术、文字画、行式打印机、绿条纸、连续打印纸、针孔打印纸、老电脑打印、叠打、低多边形、低面数、低模、多边形风、千禧年 3D、90 年代 3D、复古 3D 游戏、老游戏截图、PS1 风、N64 风、平面着色、线框、游戏 HUD、飞行游戏、穿环、喷漆、模板涂鸦、镂空模板、喷漆模板、模板喷绘、街头涂鸦、街头艺术、墙绘、滴漆、班克西风格、刺绣徽章、徽章、布章、臂章、刺绣贴、绣标、锁边、牛仔外套徽章、户外徽章、营地徽章、弧形条章、蓝图、工程图、施工图、蜡笔画、儿童画、绿屏终端、CRT、显像管、热成像、热像仪、温度图、代尔夫特、荷兰蓝瓷砖、洞穴壁画、史前壁画、赭石、1-bit、黑白画图软件、MacPaint 风、黑绘、古希腊陶瓶、希腊瓶画、铅笔素描、素描、铅笔画、X 光、X 光片、安检图像、橡皮管动画、黑白卡通、老动画、麻胶版画、黑白版画、藏书票、VHS、家庭录像、录像带、扁平插画、扁平风、矢量插画、绘本动画、角色动画、挤压拉伸、圆珠笔、圆珠笔涂鸦、原子笔、页边涂鸦、课本涂鸦、手画棋盘、描图纸、硫酸纸、叠片、叠层、分色片、灯箱、拷贝台、透光台、套准、定位钉、粉彩界面、粉彩 UI、Dot 风、Dot 那种风格、产品发布会界面、发布会质感、窗口卡片、macOS 窗口、界面卡片、讲解片界面页、小图标探头、阅卷、阅卷批改、批改、判卷、改卷、改作业、答题卡、试卷、考卷、测验卷、红笔批改、红笔打分、打分数、盖章批改、朱红印章、标准答案卡、长尾夹、讲解片评测 / 打分页、皮影、皮影戏、影子戏、驴皮影、灯影戏、皮影人偶、雕花戏台、戏台牌匾、亮相、钢笔淡彩、淡彩、淡彩速写、钢笔淡彩小人、针管笔、勾线笔、针管笔加水彩、线稿上色、速写卡片、速写本小人、水彩小卡、城市速写、街头速写、水笔、自来水笔、复古水粉、水粉、水粉画、不透明水粉、哑光丙烯、复古绘本、绘本插画、绘本大头像、童书插画、复古童书、大头像、大鼻子人物、针织毛衣、麻花毛衣、毛线帽、毛毡帽、卷发、胡子、蓝调绘本、蓝色绘本、软蓝绘本、蓝调童书、软蓝童书插画、蓝色童书插画、蓝色系绘本、限色绘本、蓝白绘本、现代绘本跨页、手绘绘本跨页、绘本跨页、绘本内页、干笔墨线、墨铅笔线、粉彩蜡笔质感绘本、白色毛绒动物、毛绒白熊、点彩腮红、江南园林、园林春景、春水园林、中式园林插画、古典园林插画、国风园林插画、苏式园林、细笔园林、园林风景插画、水榭、临水茶榭、亭台楼阁、粉墙黛瓦、黛瓦白墙、飞檐翘角、翼角起翘、月洞门、漏窗、冰裂纹窗、槅扇、挂落、九曲桥、曲桥、垂柳园林、碧水倒影、园林倒影、睡莲池、数字水粉风景、细腻厚涂风景、干刷色块、干笔色块、干刷、干刷插画、干笔插画、滚筒刷、滚筒色块、色块插画、大色块插画、毛边色块、刷痕色块、粗刷笔触、mid-century、世纪中期插画、中世纪现代插画、复古编辑插画、复古海报插画、水粉拼贴、撕纸色块、限色海报、暮色微缩绘本、暮色绘本、黄昏绘本、微缩绘本、黄昏转夜、昼夜交界、日夜交界、半边黄昏半边星空、粉彩黄昏、粉紫晚霞、黄昏星空、银河插画、野花坡、野花草坡、花海插画、萤火虫、放风筝插画、拼布山丘、条纹田野、小圆树、细节放大图、局部放大图、技术细节小窗、科学图版风插画、手写英文小字、晚安绘本、治愈系绘本插画、排线夜景、排线风夜景、彩铅夜景、色粉夜景、粉彩排线、短笔触夜景、笔触夜空、方向笔触、夜景版画、小版画、限量版画风、版画装裱、版痕、纸边标题、铅笔题字、夜景插画、夜空插画、深蓝夜景、靛蓝夜空、冷暖对比夜景、唯一暖光、夜里的火光、发光的云、被照亮的云、红色精灵闪电、精灵闪电、火山夜景、熔岩入海、熔岩、岩浆、火山喷发插画、海上风暴、海面倒影、光柱倒影、火星飞溅、星点、看海的人、礁石上的人、远处的小人、小人比例尺、雪夜篝火、渔火、笔记应用界面、笔记软件界面、笔记 App 界面、Obsidian 风、Obsidian 界面、Obsidian 风格、黑曜石笔记、深色笔记界面、暗色主题界面、Markdown 笔记、Markdown 编辑器、双链笔记、内部链接、关系图谱、知识图谱界面、图谱视图、局部图谱、反向链接、文件列表、侧边栏、标签页、属性栏、行内代码、代码块、mermaid、mermaid 流程图、代码块渲染成图、源码 / 阅读切换、阅读视图、引用标注、callout、读书笔记界面、知识库界面、第二大脑、讲解片里的笔记应用、应用窗口演示、白板卡片、无限白板、白板视图、画布视图、Canvas 视图、Obsidian Canvas、Obsidian 白板、笔记应用白板、卡片白板、卡片和连线、节点和连线、带箭头的连线、弯曲连线、连线标签、分组框、点阵背景、点阵白板、深色白板、深色界面卡片、彩色边卡片、勾选清单卡片、待办卡片、引用卡片、图片卡片、草图卡片、手绘平面图、缩放按钮、镜头平移、镜头缩放、卡片掉落动画、连线画出来、搬家计划、旅行计划白板、活动计划白板、头脑风暴白板、项目拆解白板、计划白板、Flexoki、Flexoki 纸面、Flexoki 配色、Flexoki 风、暖白纸、米白纸面、墨黑字、文档站风格、文档页图解、技术文档配图、图解页、一页图解、讲解片图表页、几张图讲清楚、流程图、画流程图、时序图、序列图、饼图、柱状图、条形图、对比表、参数对比、图表合集、图表墙、Mermaid 风、Mermaid 图、图表渲染器、灰底圆角框、小三角箭头、橙色聚焦框、数字滚动、计时器大数字、配方图解、步骤图解、手冲咖啡图解、菜谱图解、工作流程图解、暖调彩铅绘本、暖调彩铅、彩铅绘本、彩铅童书、彩铅童书插画、彩色铅笔绘本、彩色铅笔童书、软彩铅、彩铅叠涂、层层叠涂的彩铅、顺着形体排线、纸齿白点、纸纹透白、怀旧童书、翻绘本的感觉、温暖怀旧的绘本、暖色绘本页、巨物与小孩、大动物和小孩、巨大温柔的生物、温柔的巨兽、大乌龟、巨龟、老乌龟、背着花园的乌龟、龟背上的小花园、大龟过河、过河、小溪、踏脚石、提灯笼的小孩、黄色雨衣、纸灯笼、亮灯的窗、亮灯的小房子、黄昏小镇、成簇的毛、顺毛、毛一绺一绺、苔藓、金黄的树、彩色小镇、彩色房子、彩色街景、童话小镇、童话街景、治愈小镇、理想的生活环境、欧洲小镇、山城小镇、钟楼小镇、彩虹小镇、彩旗、三角彩旗、彩旗串、彩旗街、节日街道、节日早晨、钟楼、白色钟楼、洋葱顶、石板屋顶、曼莎屋顶、老虎窗、烟囱帽、电视天线、风向标、爬藤玫瑰、窗台花箱、铁艺阳台、台阶街、石头台阶、拱门下的台阶、湿街倒影、雨后街道、雨后的广场、水粉街景、水粉加描线、水粉平涂加细线、细节多到看不完、小红书彩色小镇、色粉小像、色粉画、软色粉、色粉笔触、色粉质感、色粉加水粉、粉彩笔触、粉彩质感、绘本角色、绘本人物、绘本小像、角色小像、人物小像、半身像、人和宠物、人和猫、人和狗、主人和宠物、抱着猫、抱着狗、橘猫、大橘、毛茸茸的猫、毛茸茸的狗、狐狸、猫围巾、把猫当围巾、白底插画、留白插画、不画背景、边缘散开、干笔散开、画到边上就散了、大眼睛、大圆眼、大腮红、红鼻头、红鼻尖、发丝、一根根头发、头发丝、飞丝、毛绒绒、蓬松的毛、温柔的小像、治愈系角色、Midjourney 色粉风),或 "draw it yourself", "paint with code", "procedural painting", "watercolor / collage / colored pencil / anime / editorial / impasto oil / ukiyo-e / pixel art / clay / claymation / cyanotype / sun print / cross-stitch / embroidery / retro instrument panel / vintage radio / sticker collage / receipt / lab notebook / graph paper / chalkboard / blackboard / cyberpunk / neon city / cartoon / hand-drawn animation / isometric / 2.5D / continuous line / one-line drawing / soft 3D / 3D render / puffy letters / ball pit / shape morph / morphing / newspaper collage / Dada / ransom note / halftone / glassmorphism / aurora gradient / Bauhaus / geometric poster / screen print / synthwave / retrowave / outrun / perler beads / hama beads / artkal / fuse beads / melty beads / pegboard beads / petroglyph / rock art / rock carving / desert varnish / Egyptian tomb painting / ancient Egypt / hieroglyphs / Theban tomb / Roman mosaic / floor mosaic / tesserae / opus vermiculatum / Pompeii mosaic / stained glass / leaded glass / church window / Gothic window / grisaille / illuminated manuscript / medieval manuscript / book of hours / gold leaf / illuminated initial / blackletter / vellum / astrolabe / da Vinci notebook / Leonardo codex / Renaissance sketchbook / mirror writing / iron-gall ink / red chalk / sanguine / ornithopter / exploded view / inventor's sketch / silhouette / silhouette portrait / cut-paper profile / shade portrait / Georgian portrait / Regency portrait / oval gilt frame / letterpress / wood type / playbill / circus poster / Victorian poster / two-colour misregistration / woodcut poster / constructivism / constructivist poster / Soviet avant-garde / Russian avant-garde / Rodchenko style / photomontage poster / art deco / streamline moderne / 1930s travel poster / railway poster / airbrush poster / sunburst rays / Gatsby style / golden age comic / vintage comic book / comic cover / Ben-Day dots / four-color printing / newsprint / speech balloon / pulp cover / pop art / Warhol-style / pop silkscreen / silkscreen portrait / repeated pop portrait grid / ASCII art / text art / typewriter art / line printer / greenbar / fanfold paper / tractor feed / overstrike / printer plot / low poly / low-poly / retro 3D / 90s 3D game / PS1 style / N64 style / software rasterizer / flat shading / affine texture mapping / vertex fog / game HUD / stencil / stencil graffiti / spray paint stencil / street art / drips and overspray / Banksy-style stencil / embroidered patch / embroidery patch / iron-on patch / sew-on patch / merit badge / camp badge / merrow border / rocker patch / denim jacket patches / blueprint / technical drawing / crayon / kid's drawing / CRT terminal / green screen / thermal camera / thermal imaging / Delft tiles / Delft blue / cave painting / ochre / Lascaux-style / 1-bit / MacPaint-style / black-figure / Greek vase / pencil drawing / graphite / X-ray / baggage scanner / rubber hose / 1930s cartoon / linocut / lino print / VHS / home video / flat vector / flat illustration / storybook animation / squash and stretch / ballpoint / biro / ballpoint doodle / margin doodles / hand-drawn board game / overlay sheets / tracing-paper overlays / light box / colour separations / registration marks / acetate overlay / pastel UI / Dot-style product film / launch-film interface / macOS window cards / exam grading / grading an answer sheet / red-pen marking / graded test paper / rubber-stamped answer sheet / shadow puppet / shadow puppetry / Chinese shadow play / leather shadow puppets / backlit puppet screen / pen and wash / pen & wash / line and wash / ink and watercolour / ink and watercolor / fineliner sketch / fineliner and watercolour / sketchbook characters / sketch cards / urban sketching / water brush / gouache / retro gouache / gouache portrait / gouache illustration / opaque gouache / matte acrylic / picture-book portrait / vintage picture book / retro children's book illustration / mid-century children's book / big-nosed character portrait / cable-knit sweater / knitted bobble hat / blue picture book / soft blue picture book / soft-blue children's book illustration / modern picture book / limited-palette picture book / picture-book spread / scratchy ink line / dry-brush ink line / ink pencil line / crayon and pastel texture / chalky white marks / blue and coral palette / fluffy white bear / Jiangnan garden / Chinese garden / classical Chinese garden illustration / Chinese water garden / spring garden illustration / lush painterly garden / waterside pavilion / moon gate / lattice windows / zigzag bridge / weeping willow garden / upturned eaves / grey-tiled roof / blossom trees and reflections / lily pond with egrets / digital gouache landscape / dry-brush blocks / dry brush illustration / dry-brushed colour blocks / roller texture / brush-textured shapes / mid-century illustration / mid-century modern poster / mid-century editorial illustration / gouache collage / torn-paper collage poster / limited palette poster / scumbled texture / vintage book cover illustration / twilight storybook / dusk picture book / dusk to night sky / day and night split sky / pastel sunset sky / Milky Way illustration / wildflower meadow / wildflower hill / patchwork hills / tiny round trees / fireflies / paper kite / magnified detail inset / detail callout circle / scientific plate overlay / handwritten lowercase captions / cozy miniature illustration / bedtime story illustration / hatched nocturne / hatched night scene / pastel hatching night / coloured-pencil nocturne / directional strokes / short brush strokes sky / night print with margins / small art print / plate mark / pencilled title and caption / indigo night with one warm light / glowing cloud lit from below / red sprites / lava entering the sea / volcano at night / glowing threads and sparks / broken reflection on the sea / tiny figures for scale / Obsidian UI / Obsidian-style note app / dark note-taking app / dark-theme Markdown editor / note app window / file explorer sidebar / wiki links / backlinks / graph view / local graph / knowledge graph UI / properties and tags / inline code / mermaid code block / mermaid flowchart rendered / source vs reading view / callout block / reading notes app / second brain UI / knowledge base screen / canvas board / infinite whiteboard / dotted board / note-app canvas view / Obsidian-style canvas / cards and connectors / curved arrows between cards / edge labels / group frames / coloured card borders / task-list card / quote card / image card with a sketch / hand-drawn floor plan / zoom controls / camera pan and zoom / cards dropping in / moving plan board / Flexoki / Flexoki paper / Flexoki palette / warm paper and ink / docs-site diagrams / explainer sheet / diagram sheet / Mermaid-style diagrams / lightweight diagram renderer / flowchart / sequence diagram / pie chart / bar chart / comparison table / diagram wall / grey-bordered boxes / small triangular arrowheads / orange focus ring / rolling numbers / recipe explainer / warm pencil storybook / coloured-pencil storybook / colored pencil picture book / soft pencil textures / layered coloured pencil / pencil strokes following the form / paper tooth specks / nostalgic children's storybook / giant gentle creature and a small child / giant tortoise / tortoise with a garden on its back / stepping stones / child with a lantern / yellow raincoat / paper lantern / lit windows at dusk / tufted fur in locks / Midjourney sref 3220081856 look without an image model / colour town / colorful European town / storybook street / fairy-tale town / candy-coloured houses / hill town / bunting / pennant flags / festival street / clock tower / onion dome / slate mansard roofs / dormers / chimney pots / TV aerials / climbing roses / window boxes / wrought-iron balconies / stepped lane / wet street reflection / gouache and ink cityscape / pastel vignette / soft pastel character / chalk pastel portrait / pastel textures and painterly brushstrokes / whimsical character design / picture-book character on white / person with a pet / girl and her cat / ginger cat / cat scarf / big round eyes / rosy cheeks / red-tipped nose / wispy hair strands / fluffy fur / feathered edges / vignette on white paper / Midjourney sref 455581803 look without an image model" 时使用;也用于需要逐步画出(draw-on)动画的插画。单独说「剪纸」指剪纸拼贴、「刺绣」指十字绣、「丝网印刷 / screen print」指包豪斯几何;「打马赛克」是打码,不是马赛克画风;单说「蓝图」指蓝图工程图,「蓝晒 / 晒图」仍指蓝晒;「铅笔 / 素描」指铅笔素描,「彩铅」指韩国彩铅;「像素」仍指像素风,「1-bit / 黑白画图软件」指 1-bit 早期画图软件;「霓虹」仍指赛博朋克;「喷漆 / 街头涂鸦」仍指喷漆模板涂鸦,「圆珠笔 / 随手涂鸦 / 页边涂鸦」指圆珠笔涂鸦;「描图纸 / 硫酸纸 / 叠片 / 灯箱」指描图纸叠层(蓝图工程图那张描图布是晒成蓝图的,不是叠片);「Dot 风 / 粉彩界面 / 窗口卡片 / 发布会界面」指粉彩界面(纯色底 + 白色实心窗口卡片),要磨砂玻璃和弥散渐变仍用弥散玻璃;「阅卷 / 批改 / 答题卡 / 判卷 / 红笔打分」指阅卷批改,实验记录里的红笔圈和便利贴仍用实验笔记本,带「已付」橡皮章的小票拼贴仍用贴纸拼贴 · 小票;「皮影 / 皮影戏 / 影子戏」指皮影戏(透光的彩色驴皮人偶),黑纸剪出的侧影小像仍用剪影,彩纸剪贴仍用剪纸拼贴。「钢笔淡彩 / 淡彩速写 / 针管笔加水彩 / 线稿上色的速写小卡」指钢笔淡彩;单说「水彩」仍指水彩(风景、花卉的大片晕染),蓝铅笔稿 + 毛笔线 + 赛璐璐阴影的拟人小物仍用卡通手绘,「素描 / 铅笔」仍指铅笔素描。「水粉 / 复古水粉 / 绘本大头像 / 复古童书插画」指复古水粉(不透明水粉画的特写大头像);梵高式厚涂的风景、名画感仍用油画厚涂,扁平矢量、会挤压拉伸的小角色动画(「绘本动画」)仍用绘本角色动画,针管笔线稿加淡彩的速写小卡仍用钢笔淡彩,撞色多格的头像仍用波普丝网。「蓝调绘本 / 软蓝绘本 / 蓝色童书插画 / 绘本跨页」指蓝调绘本(软蓝限色的现代绘本跨页:干笔墨线 + 干蜡笔粉彩上色 + 白粉笔痕);单说「绘本」仍指绘本角色动画,「水粉 / 绘本大头像」仍指复古水粉,「编辑风 / Riso」仍指编辑风手绘,针管笔线稿加淡彩的速写小卡仍用钢笔淡彩,小孩自己画的蜡笔画仍用儿童蜡笔画。「江南园林 / 园林春景 / 中式园林插画 / 粉墙黛瓦 / 飞檐 / 月洞门 / 九曲桥」指江南园林(细笔数字水粉的园林春景:叶形小笔触堆出的繁茂树冠、繁花、垂柳、黛瓦飞檐、碧水倒影、层层远山);单说「水墨 / 山水」仍指水墨,单说「水彩」仍指水彩,动漫背景 / 赛璐璐天空仍指日本动漫,浮世绘仍是浮世绘;梵高式厚涂的风景仍用油画厚涂,皮影人偶的一场戏仍用皮影戏。「干刷色块 / 干笔色块 / 滚筒色块 / mid-century 海报插画」指干刷色块(米白纸上几大块干笔或滚筒刷出的限色色块,人物拆成几个大块面,背后一块纯色板、一旁一个小红方块);单说「水粉 / 绘本大头像」仍指复古水粉,「剪纸 / 彩纸拼贴」仍指剪纸拼贴,「丝网印刷 / screen print」仍指包豪斯几何,「Riso / 编辑风」仍指编辑风手绘,没有笔触的平滑几何色块仍用扁平矢量。「暮色微缩绘本 / 暮色绘本 / 黄昏转夜 / 昼夜交界 / 野花坡 / 细节放大图」指暮色微缩绘本(粉彩黄昏转入银河夜空、拼布山丘、几万朵小野花、很小的原创角色,加圆形放大图和手写小字);单说「绘本」仍指绘本角色动画,「蓝调绘本 / 软蓝绘本」仍指蓝调绘本,赛璐璐天空和夏日少年感仍用日本动漫,大片晕染的风景仍用水彩,整页的机械分解手稿仍用达·芬奇手稿,剖面和施工图仍用蓝图工程图。「排线夜景 / 彩铅或色粉夜景 / 短笔触夜空 / 夜景小版画 / 熔岩入海 / 精灵闪电 / 被照亮的云」指排线夜景(满画面顺着风向的短笔触、深蓝夜色里只有一个暖光、发光的丝和火星、碎的倒影、很小的人,装成带纸边和铅笔字的小版画);梵高式的厚涂漩涡和颜料浮雕仍用油画厚涂,明亮可爱的彩铅甜品仍用韩国彩铅,黑白石墨排线仍用铅笔素描,粉彩黄昏转入银河星空、满坡小野花仍用暮色微缩绘本,霓虹雨夜街道仍用赛博朋克。「Obsidian 风 / 笔记应用界面 / 深色笔记软件 / 双链笔记 / 关系图谱 / mermaid 代码块渲染成图」指笔记应用界面(深色主题的笔记应用窗口:文件列表、Markdown 正文、代码块切到阅读视图渲染成流程图、亮紫光点的关系图谱,只有一个紫色强调色);明亮的粉彩底和白色窗口卡片仍用粉彩界面,点阵无限白板上的卡片和弯曲连线用白板卡片,暖白纸面上的浅灰卡片图表用 Flexoki 纸面,磨砂玻璃和弥散渐变仍用弥散玻璃,绿屏荧光字符的老终端仍用绿屏终端 CRT,霓虹全息的未来界面仍用赛博朋克。「白板卡片 / 无限白板 / Canvas 视图 / 卡片和连线 / 点阵白板 / 分组框 / 带箭头的弯曲连线」指白板卡片(深色应用窗口里随镜头平移缩放的点阵白板:分组框、彩色边卡片、带箭头和标签的弯曲连线、清单 / 引用 / 草图卡片、右上角缩放按钮);笔记正文页、文件列表和关系图谱仍用笔记应用界面,暖白纸上的流程图、时序图和图表仍用 Flexoki 纸面,明亮的粉彩产品界面和检查结果仍用粉彩界面,一层层叠起来的图解仍用描图纸叠层。「Flexoki / Flexoki 纸面 / 暖白纸上的图解页 / Mermaid 那样的流程图、时序图、饼图、柱状图、对比表 / 讲解片里的图表页」指 Flexoki 纸面(暖白纸、墨黑字、不描边的浅灰圆角卡片,卡片里的图照轻量图表渲染器画:灰边框、墨线小三角箭头、普通标签,强调色只点在有意义的地方);手写粉笔的示意图仍用黑板板书,铅笔图表、荧光笔和便利贴仍用实验笔记本,彩色粉彩底、macOS 窗口和 ✓ / ✗ 徽章的产品界面仍用粉彩界面,深色笔记应用窗口仍用笔记应用界面,点阵无限白板上的卡片和连线仍用白板卡片,系统的微缩模型仍用等轴 2.5D,剖面和施工图仍用蓝图工程图。「暖调彩铅绘本 / 彩铅绘本 / 彩铅童书插画 / 巨物与小孩 / 大龟过河 / 纸齿白点 / 层层叠涂」指暖调彩铅绘本(暖白纸上满画面顺形体的彩铅叠涂、纸齿透出细白点、毛发成簇顺毛,大而温柔的生物和小小的孩子,黄昏暖光和橙黄的灯,没有墨线和黑色);单说「彩铅」仍指韩国彩铅(明亮可爱的甜品小物、粉嫩高光),黑白石墨仍用铅笔素描,软蓝限色、刮擦墨线加蜡笔颗粒的绘本跨页仍用蓝调绘本,粉彩黄昏转入星空、满坡小野花仍用暮色微缩绘本,不透明水粉的特写大头像仍用复古水粉,深蓝夜色里只有一个暖光的排线小版画仍用排线夜景;单说「绘本」仍指绘本角色动画。「彩色小镇 / 彩色房子 / 童话小镇 / 童话街景 / 彩旗街 / 钟楼小镇 / 水粉加描线的街景 / 有被这彩色小镇治愈到」指彩色小镇(水粉平涂加细墨线,密密的彩色房子堆上山坡,石板曼莎屋顶、白色钟楼、好几层三角彩旗、爬藤玫瑰和窗台花、湿街倒影);中式园林和古镇仍用江南园林,锡釉蓝砖上的运河小镇仍用代尔夫特蓝瓷砖,黑白刻版的雪村仍用黑白麻胶版画,彩纸剪出来的热气球小镇仍用剪纸拼贴,系统的微缩模型和小岛仍用等轴 2.5D,针管笔速写加淡彩的小卡仍用钢笔淡彩,水粉画的人物大头像仍用复古水粉,彩铅叠出来的黄昏小镇和巨物仍用暖调彩铅绘本,没有描线、没有笔触的几何色块仍用扁平矢量。「色粉小像 / 色粉画 / 绘本角色小像 / 人和宠物 / 猫围巾 / 白底不画背景、边上干笔散开的角色 / 大眼睛大腮红红鼻尖」指色粉小像(白纸上的半身角色小像,软色粉加一点水粉,大圆眼、大腮红、红鼻尖、一根根的发丝和蓬松的毛,柔和的粉蓝和奶油色里只有一组暖橙,边缘散进白纸);背后刷一块单色、看得见毛衣针脚的复古童书大头像仍用复古水粉,满画面彩铅叠涂、带天空和场景的黄昏绘本页仍用暖调彩铅绘本,软蓝限色、乱线墨线的绘本跨页仍用蓝调绘本,针管笔线稿加淡彩的速写小卡仍用钢笔淡彩,明亮可爱的彩铅甜品小物仍用韩国彩铅;「色粉夜景」仍指排线夜景,「粉彩界面」仍指产品界面。+description: Claude 绘图 / Claude Drawing —— 不借助任何生图模型,由 Claude 用代码一笔一笔「画」出图片(程序化绘画)。内置七十七种画风:中国水墨、水彩、剪纸拼贴、韩国彩铅、日本动漫、编辑风手绘(Riso)、油画厚涂(梵高式流向笔触+颜料浮雕打光)、浮世绘木版画(晕色、木纹、墨线主版、青海波)、像素风(低分辨率+Bayer 抖动+像素字体)、黏土定格(高度图捏出的彩泥+影棚打光)、蓝晒(普鲁士蓝日光晒图,植物剪影透光)、十字绣(Aida 布十字绣+回针绣+缎面绣+法式结)、复古仪器面板(60 年代收音机/仪器正面:柚木、拉丝铝、旋钮、刻度窗、指示灯)、贴纸拼贴·小票(模切乙烯贴纸、热敏小票、和纸胶带、吊牌、橡皮章)、实验笔记本·贴纸(线圈方格本、铅笔图表、荧光笔、红笔圈、便利贴)、黑板板书(墨绿石板、粉笔颗粒、板擦残影、示意图与公式)、赛博朋克(雨夜霓虹街道、玻璃管霓虹招牌、全息广告、湿路面倒影)、卡通手绘(蓝铅笔稿、毛笔线、错位平涂、赛璐璐阴影、逐帧抖线)、等轴 2.5D(正等轴微缩模型、一个太阳照出三面明暗、悬浮数据卡)、单线画(一根不断开的线一笔画完、唯一点睛色)、柔光 3D(光线追踪的糖果色小球海和鼓鼓的软字、景深)、形变动画(一条轮廓依次变形、洋葱皮残影、缓动曲线)、报刊拼贴(牛皮纸、手撕旧报纸、网点老照片、勒索信拼贴字)、弥散玻璃(弥散渐变、磨砂玻璃卡片界面)、包豪斯几何(三原色几何、丝网印刷海报)、复古 Synthwave(切口落日、霓虹网格、镀铬字、录像带质感)、拼豆(钉板上的熔珠小管、熨烫熔合)、岩画(沙漠漆上凿出的凹坑图形、新旧凿痕、剥落)、古埃及墓室壁画(灰泥墙、红格起稿、分栏叙事、象形文字、剥落)、罗马马赛克(石子与玻璃沿轮廓一排排铺、灰缝、燕尾铭牌)、彩色玻璃花窗(哥特尖拱窗、通体着色玻璃、grisaille 彩绘与银染、铅条、透光)、泥金手抄本(羊皮纸、鹅毛笔哥特体、朱红标题、打磨金箔首字母)、达·芬奇手稿(铁胆墨水、左手排线、红粉笔、镜像手写、机械分解图)、剪影(黑纸剪出的侧影小像、薄金粉、椭圆金框)、凸版印刷海报(木活字、红黑双色错版、木刻插图)、苏联构成主义(红黑两版、斜条与楔形、西里尔大字、网点照片拼贴)、装饰艺术 Art Deco(1930 年代喷枪流线型海报、交替射线、阶梯高楼、金色 Deco 字)、黄金时代漫画(毛笔墨线、Ben-Day 网点、四色错版、新闻纸)、波普丝网(多格撞色平涂 + 错位的照相黑版)、ASCII 字符画(行式打印机、绿条连续纸、叠打)、低多边形(1999 年代 3D:平面着色、仿射贴图、逐顶点雾、15 位色抖动)、喷漆模板涂鸦(混凝土墙上多层卡纸模板喷绘、雾化与滴痕)、刺绣徽章(牛仔布上的机绣徽章:填充绣、缎面绣、锁边)、蓝图工程图(描图墨线晒成蓝底白线)、儿童蜡笔画(小孩在糙纸上的蜡笔涂抹)、绿屏终端 CRT(荧光字符画、扫描线、余辉)、热成像(先画温度场再上伪彩色)、代尔夫特蓝瓷砖(锡釉砖上的钴蓝手绘)、洞穴壁画(火光下的赭石、吹喷手印)、1-bit 早期画图软件(黑白整屏、8×8 图案填充)、古希腊黑绘陶瓶(黑釉剪影、刻线、饰带展开图)、铅笔素描(石墨排线、擦笔、边缘只剩线稿)、X 光片(安检透视、轮廓发亮、伪彩)、1930 年代黑白橡皮管动画(白手套、饼切眼、老胶片)、黑白麻胶版画(刻刀减法、手拓发花、套色错版)、VHS 家庭录像(钨丝灯偏色、色度渗色、REC)、扁平矢量(分层几何色块、七色、层间投影)、绘本角色动画(小角色挤压拉伸的真动画)、圆珠笔涂鸦(蓝红圆珠笔线稿、墨团、彩铅、页边涂鸦)、描图纸叠层(灯箱上的黑线底图 + 一张张单色描图纸叠片:正片叠底、套准十字、定位钉、绘图胶带)、粉彩界面 · Pastel UI(产品发布片式的界面画面:纯色粉彩底与大光斑、macOS 窗口卡片、胶囊与粗黑标题色条、状态标签与 ✓ / ✗ 徽章、放大镜、从卡片边探头的扁平小图标)、阅卷批改 · Exam Grading(绿毛毡桌上被红笔批改的答题卡:定位黑块、考号涂卡、得分格与阅卷栏、长尾夹夹住的标准答案卡、油墨不均的朱红印章、立体红笔、波浪线 / 圈 / 引线 / 批注 / 叉 / 圈起来的分数)、皮影戏 · Shadow Puppetry(油灯照亮的幕布上,雕空、透明染色的驴皮关节人偶:镂空纹样、阳刻空脸、雉翎盔头、线结与操纵杆、离幕时虚化的双影;雕花戏台、红漆金字牌匾、红灯笼)、钢笔淡彩 · Pen & Wash(速写小卡上的针管笔线稿 + 松散淡彩:线条抖、出头、不闭合,颜色错位出线、留白缝、干边与颗粒,不铺满的背景色块;大头、圆眼镜、点点眼、红鼻子的呆萌小人;卡片拍在木桌上,旁边放着针管笔和水笔)、复古水粉 · Retro Gouache(复古绘本风的水粉大头像:不透明水粉从暗到亮一层层盖上去,单色背景用干笔皴擦;大红鼻子、腮红、圆眼和大耳朵用几阶色值塑出来;看得见针脚的毛衣和毛线帽,一根根的头发和胡子,毛毡;最后是印刷书页的纸纹)、蓝调绘本 · Blue Picture Book(软蓝色调的现代绘本跨页:几乎只用粉蓝、矢车菊蓝、深青蓝三阶蓝加黑墨和纸白,只点一点珊瑚红、粉色腮红和芥末黄;毛笔 / 墨铅笔线干、抖、断,粗细不匀,线不闭合,暗部用快速来回的乱线排出来;颜色是干蜡笔、粉彩、干水粉,错位出线,纸纹的白点透出来;白粉笔痕压在蓝上,甩点和细尘;背景蓝块毛边、不到纸边;大圆脑袋、带高光的点点眼、点彩腮红和雀斑、火柴腿穿靴子的小人,乱线毛边的白色毛绒动物;最后印在书上:中缝和页码)、江南园林 · Jiangnan Garden(细笔园林春景,数字水粉插画:成千上万片叶形小笔触按一个太阳堆出树冠,暗芯、亮边、一簇簇的高光;白色和淡粉的繁花是一簇簇圆点花瓣,枝条从缝里露出来;垂柳是一绺一绺发丝般的细枝挂满小叶;黛瓦飞檐是真的瓦垄:筒瓦板瓦一行行、檐口瓦当滴水、翘起的翼角和卷起的脊头;粉墙月洞门、冰裂纹漏窗、翡翠绿槅扇和挂落、红灯笼、匾额;九曲石桥、石阶、小木船;碧绿湖面倒映岸上的一切,更柔、更暗,加涟漪和细竖纹;睡莲、白鹭;从前景花枝到雾里青山层层退远,墙上桥上落着叶影;最后一方小红印)、干刷色块 · Dry-Brush Blocks(mid-century 海报 / 水粉拼贴式的编辑插画:米白纸上几大块干笔或滚筒刷出的色块,颜色严格限定在森林绿、鼠尾草绿、青蓝、藏蓝、近黑和朱红,外加一点天蓝、淡青瓷和米色;每块颜色在自己的笔刷坐标系里刷:一道道平行的笔,起笔饱满、收笔干枯,两侧几乎是直边,两端梳成长短不一的毛齿,块里有顺笔的鬃毛纹、皴擦斑和露出来的纸色;背后的大色板用滚筒:近乎平涂、成簇的细点、干的两侧和几道细刮痕;色块像丝网套印或撕纸拼贴一样叠起来,撕口带一圈浅色纤维边;人物拆成几个大块面:亮暗两半朝不同方向刷的外套、几块肤色平面拼的头、粗黑框眼镜、干笔皴擦的白胡子;瓶子是竖刷的深色剪影加一道高光和小块标签;一旁一个小朱红方块;不勾线、不做渐变;最后像胶印:轻微柔化、纸纹、暗部零星白点、纸上细尘)、暮色微缩绘本 · Twilight Storybook(温柔、怀旧的黄昏绘本单页,满是微缩细节:大片粉彩黄昏天空,从顶上的薰衣草紫经玫瑰、蜜桃到地平线的暖金,柔和的平底云带、细细的光线和一轮低垂的淡日;一侧天空已经入夜:星空、带暗带的银河、弯月、流星,昼夜交界经过淡紫和靛蓝,不发灰;下面是一层层粉彩条纹的起伏山丘,拼布似的田、细细的垄、小圆树;前景是几万朵小野花铺成的坡,坡顶是色点,越往下越大:雏菊、矢车菊、虞美人、波斯菊、金盏花、毛茛、羽扇豆、勿忘我,夜的一侧整片变成月光蓝;很小、扁平、可爱的原创角色;上面叠一层科学图版的语言:圆形的「detail a」放大图,细墨线、排线、尺寸标注、标签和比例尺,几行灰色的小写英文手写字;最后是细颗粒、光晕、暗角和底边一道撕纸边)、排线夜景 · Hatched Nocturne(彩铅 / 色粉排线式的小幅夜景版画:天空、云、山和海全由密密的短笔触叠成,每片区域的笔触顺着同一股「风」走——天空斜着流、蒸汽绕着云团卷、山坡顺着坡向、海面横着长拖,每一笔色相和明度都差一点,笔毛分道、拖干的笔尾、纸纹里漏出的细缝,没有一处平滑渐变;深靛蓝、藏青、冷灰蓝的夜色里只有一个暖色光源,光是一层层加上去的发光笔触:核心黄白、外圈橙红、再外是被照亮的笔触,被照亮的蒸汽按「光 × 受光」上色,所以是红橙而不是粉;发光的细丝(会蜿蜒、分股、末端亮珠)、火星、星点;海面上被横向笔触打碎的倒影和光柱;几十像素高的小人靠一点亮色(围巾)点出来;最后装裱成小版画:米白纸边、压印的版痕、左下铅笔小标题、右下更小的说明,用细的普通字体)、笔记应用界面 · Obsidian UI(讲解片里的深色笔记应用窗口:近黑页面上一团淡紫光晕,窗口里有标签栏、细长图标栏、带缩进线的文件列表、粗黑 H1 下一道紫色短条、属性块和 #标签、紫色的内部链接和行内代码、带语法色的 mermaid 代码块——点「阅读」后渲染成扁平深色的流程图,一个节点亮紫——紫色左边的引用标注,右栏关系图谱里被链接的笔记亮成紫色光点;全画只有一个紫色强调色,不画官方 logo)、白板卡片 · Canvas Board(深色笔记应用的白板视图:深色页面上一扇应用窗口——红黄绿三点和「.canvas」标签页的标签栏、左边一列线性图标——里面是一块随镜头平移缩放的灰点阵无限白板;分组框和浮在框上方的组名,深色圆角卡片带 2 px 的卡片色边(红、橙、黄、绿、青、紫)和一层很淡的同色底,卡片之间是从边的中点沿法线弯出去的曲线连线,末端实心箭头、中间一块白板底色的标签;卡片里是 Markdown:标题、正文、紫色高亮、等宽行内代码、勾选清单(勾上时紫色方框弹出、对勾画出、文字变灰加删除线)、紫色竖条的引用、紫色标签胶囊、颜色编号胶囊;图片卡片上方写文件名,里面可以用手绘笔触画草图(每笔画两遍、略弯、出头,手写体批注);右上角一列缩放按钮;全画只有一个紫色强调色加卡片色;所有东西都记在白板坐标里、每次按镜头重画,任意缩放都锐利,镜头能平移缩放、卡片能掉落、连线能一点点画出来)、Flexoki 纸面 · Flexoki Paper(文档站式的图解页:暖白纸 #FFFCF0 上的墨黑字和一串暖灰,几张不描边、不投影的浅灰圆角卡片,粗黑中文标题、灰色英文类型名、等宽编号;卡片里的图照轻量图表渲染器的样子画——比底色差一级的框和 2 px 灰边(直角、圆角、胶囊、菱形、圆柱、圆)、墨线末端一个小的实心三角箭头、普通半粗体标签垫一块底色,虚线生命线和回复、带纸色缝的饼图、细网格上的柱状图、表头着色的对比表;Flexoki 的橙、红、蓝、绿、紫、青只放在有意义的地方,橙色聚焦框、黑底胶囊、字距收紧的大数字;能做成图一边一边画出来、数字滚动的动图)、暖调彩铅绘本 · Warm Pencil Storybook(暖白、有齿纹的纸上一层层叠涂的彩色铅笔绘本页:天空、山坡、草、水、一只大而温柔的生物和一个小小的孩子,全由顺着形体走向的细铅笔线叠成——天空横向长排线,山坡顺着坡势,龟壳绕着每块盾片的生长纹,脖子横过褶皱,雨衣顺着衣褶,苔藓和头发一簇簇顺毛;每块先铺一层浅色底,再上固有色、背光处叠同色系的深色,受光处罩一层暖色、阴影里罩一层冷色,每层角度错开一点、笔触交叉;蜡只挂在纸齿的峰上,同一批纸坑一层层都透出细白点,压得重、叠得多的地方才慢慢合上;后画的东西先留白再铺背景,颜色不互相混;毛是一绺一绺的:根部散开、尖端聚拢、顺着毛向,每绺受光一侧亮、背光一侧暗;没有墨线、没有黑色,只有很淡的同色轮廓;黄昏的暖光:灯笼和窗灯是一层层橙黄的发光叠涂(不是一团光晕,也不是放射线),低低的太阳给受光一侧一道暖边;水里的倒影也是一笔笔横排线;附带树、小房子、石头、鳞片、野花、纸灯笼和穿雨衣提灯笼的小孩等绘本部件)、彩色小镇 · Colour Town(不透明水粉平涂加细细的深棕墨线画的童话山城街景:高高窄窄的房子漆成番茄红、芥末黄、青绿、薄荷、珊瑚、奶白,一排压一排堆上山坡,近大远小、前后遮挡;深蓝灰的石板曼莎屋顶是一片片瓦错缝铺出来的,带老虎窗、烟囱和赤陶烟囱帽、电视天线;白色钟楼、淡蓝的天和奶白的云;三角彩旗串在好几层深度上斜穿街道,远处的小、近处的大,每面旗有一道深一点的折痕;红色爬藤玫瑰、溢出来的窗台花箱、铁艺阳台、石头台阶和扶手、路灯、吊挂的店招、拱门和彩色木门、写着字的店面和条纹遮阳篷;前景是湿亮的街面,把整条街倒映成一道道竖向的笔触;每块颜色都是带一点笔刷纹理的不透明平涂,边缘像手画的那样微微抖,和描线不完全对齐;墨线分成几段、粗细略有变化,方框的转角偶尔出头;墨是半透明的,压在红墙上是深红棕,压在玻璃上近乎黑;窗户排得整齐,但每扇都略有不同;一整面墙可以用透视单应贴成往消失点收的峡谷墙;几乎没有投影;附带钟楼、台阶、矮墙、栏杆、树、花盆、彩旗、路灯、店招、海报、咖啡桌、猫和概括的小人等部件)、色粉小像 · Pastel Vignette(白纸上的绘本角色小像,软色粉加一点水粉:一个人和他的小动物,半身、略偏一边,四周大片留白,不画背景色块、不加边框,画面在边上用干笔散开、融进白纸;颜色柔和、粉粉的——浅粉蓝的衣服上看得见顺着衣褶的干笔、奶油色的毛衣、暖肤色——只有一组暖橙饱和(橘猫、绒球、蝴蝶结这类);脸是揉开的平滑色粉:大圆眼、深色虹膜和两点白高光、一大圈腮红、红鼻尖、小嘴;头发和毛是成百上千根细丝,一绺一绺,有几根飞出轮廓,毛的轮廓蓬松地融进后面的东西;几乎不描线,只有眼皮、鼻翼、脸的背光侧几道细的软线;背后至多一枝叶子和一层很淡的铅笔小镇;附带圆眼、眉毛、腮红、鼻子、嘴、发丝、毛簇、蓬松轮廓、叶子和枝条等部件)、诗意万圣夜 · Poetic Halloween(忧郁、带一点超现实的秋夜 / 万圣节绘本肖像,暗色画板上的不透明水粉加细彩铅排线,再印出来:瓷白的脸,鼻子、脸颊、眼皮和眼睛四周泛着很重的红晕(平滑的一层红加单像素的细红斑点),下眼睑一道湿红,厚眼皮半闭、往外眼角垂,小嘴不笑,体积极简;头发是一整块雕塑般的实体——刀切一样平的齐刘海、乌黑(或银白)的波波头,几乎看不见发丝,只有一道柔和的光泽;衣物是摸得着的织物:粗麻 / 毛毡帽子(一上一下交织的粗线、线间的黑孔、毛边)、粗针织围巾和手套、斜纹织出来的格子呢外套;底子暗而沉——靛蓝夜空和星星、浓密的深色叶丛;每幅只有一处发光的点睛:眼睛和衣摆尖发着暖光的床单小幽灵,暖光照亮身边的叶子、毛线和脸的下侧;满画面一层细的印刷颗粒;附带重眼皮眼、红晕、长鼻子、小嘴、光泽带、粗麻、针织、罗纹、格子呢、毛边、掌状叶和叶丛、暖光照明和光晕、小幽灵、星星等部件)。用户说「claude绘图」「用代码画」「你自己画」「不用生图模型画」「程序化绘画」,或点名以上任一画风(含黏土、彩泥、定格动画、蓝晒、晒图、十字绣、刺绣、复古面板、老式收音机、贴纸、小票、收据、手帐拼贴、实验笔记本、方格本、荧光笔、便利贴、黑板、板书、粉笔、赛博朋克、霓虹、雨夜街道、卡通、手绘卡通、逐帧手绘、抖线、等轴、2.5D、微缩模型、单线画、一笔画、线条动画、柔光 3D、3D 渲染、C4D 风、软糖字、小球海、形变、变形动画、报刊拼贴、剪报、达达、勒索信字、网点印刷、弥散渐变、玻璃拟态、毛玻璃、包豪斯、几何构成、丝网印刷、Synthwave、蒸汽波、合成器浪潮、80 年代复古、拼豆、拼拼豆、熔珠、熨豆、豆豆画、钉板、烫豆、岩画、岩刻、凿刻、石刻、沙漠漆、史前壁刻、大角羊、古埃及、埃及壁画、墓室壁画、法老时代、象形文字、尼罗河、底比斯、罗马马赛克、马赛克镶嵌、镶嵌画、石子拼画、地砖画、古罗马地板、彩色玻璃、彩绘玻璃、花窗、玻璃花窗、教堂花窗、哥特花窗、铅条玻璃、泥金手抄本、手抄本、彩饰手抄本、中世纪手稿、羊皮纸、哥特体、花体首字母、泥金、贴金、星盘、达芬奇、达·芬奇、达芬奇手稿、手稿风、文艺复兴手稿、发明手稿、镜像字、镜像书写、扑翼机、红粉笔、钢笔排线、机械草图、分解图、剪影、剪影肖像、侧影、侧面像、黑纸剪影、剪影小像、椭圆金框、乔治时代肖像、摄政时期肖像、凸版印刷、活版印刷、木活字、铅字海报、马戏团海报、复古海报、老海报、19 世纪海报、双色套印、错版、套色错位、木刻插图、构成主义、苏联海报、苏联构成主义、俄国先锋派、罗德琴科风、红黑海报、照片蒙太奇、照片拼贴海报、西里尔字、装饰艺术、装饰风、流线型、流线型海报、1930 年代海报、旅行海报、铁路海报、火车海报、喷枪画、喷笔画、阶梯高楼、射线背景、盖茨比风、黄金时代漫画、老漫画、复古漫画、美漫封面、漫画封面、Ben-Day 网点、本戴点、网点上色、四色印刷、四色错版、新闻纸、对白框、拟声字、1940 年代漫画、波普、波普艺术、波普丝网、沃霍尔风、丝网版画头像、撞色头像、多格重复头像、六宫格撞色头像、ASCII、字符画、字符艺术、文字画、行式打印机、绿条纸、连续打印纸、针孔打印纸、老电脑打印、叠打、低多边形、低面数、低模、多边形风、千禧年 3D、90 年代 3D、复古 3D 游戏、老游戏截图、PS1 风、N64 风、平面着色、线框、游戏 HUD、飞行游戏、穿环、喷漆、模板涂鸦、镂空模板、喷漆模板、模板喷绘、街头涂鸦、街头艺术、墙绘、滴漆、班克西风格、刺绣徽章、徽章、布章、臂章、刺绣贴、绣标、锁边、牛仔外套徽章、户外徽章、营地徽章、弧形条章、蓝图、工程图、施工图、蜡笔画、儿童画、绿屏终端、CRT、显像管、热成像、热像仪、温度图、代尔夫特、荷兰蓝瓷砖、洞穴壁画、史前壁画、赭石、1-bit、黑白画图软件、MacPaint 风、黑绘、古希腊陶瓶、希腊瓶画、铅笔素描、素描、铅笔画、X 光、X 光片、安检图像、橡皮管动画、黑白卡通、老动画、麻胶版画、黑白版画、藏书票、VHS、家庭录像、录像带、扁平插画、扁平风、矢量插画、绘本动画、角色动画、挤压拉伸、圆珠笔、圆珠笔涂鸦、原子笔、页边涂鸦、课本涂鸦、手画棋盘、描图纸、硫酸纸、叠片、叠层、分色片、灯箱、拷贝台、透光台、套准、定位钉、粉彩界面、粉彩 UI、Dot 风、Dot 那种风格、产品发布会界面、发布会质感、窗口卡片、macOS 窗口、界面卡片、讲解片界面页、小图标探头、阅卷、阅卷批改、批改、判卷、改卷、改作业、答题卡、试卷、考卷、测验卷、红笔批改、红笔打分、打分数、盖章批改、朱红印章、标准答案卡、长尾夹、讲解片评测 / 打分页、皮影、皮影戏、影子戏、驴皮影、灯影戏、皮影人偶、雕花戏台、戏台牌匾、亮相、钢笔淡彩、淡彩、淡彩速写、钢笔淡彩小人、针管笔、勾线笔、针管笔加水彩、线稿上色、速写卡片、速写本小人、水彩小卡、城市速写、街头速写、水笔、自来水笔、复古水粉、水粉、水粉画、不透明水粉、哑光丙烯、复古绘本、绘本插画、绘本大头像、童书插画、复古童书、大头像、大鼻子人物、针织毛衣、麻花毛衣、毛线帽、毛毡帽、卷发、胡子、蓝调绘本、蓝色绘本、软蓝绘本、蓝调童书、软蓝童书插画、蓝色童书插画、蓝色系绘本、限色绘本、蓝白绘本、现代绘本跨页、手绘绘本跨页、绘本跨页、绘本内页、干笔墨线、墨铅笔线、粉彩蜡笔质感绘本、白色毛绒动物、毛绒白熊、点彩腮红、江南园林、园林春景、春水园林、中式园林插画、古典园林插画、国风园林插画、苏式园林、细笔园林、园林风景插画、水榭、临水茶榭、亭台楼阁、粉墙黛瓦、黛瓦白墙、飞檐翘角、翼角起翘、月洞门、漏窗、冰裂纹窗、槅扇、挂落、九曲桥、曲桥、垂柳园林、碧水倒影、园林倒影、睡莲池、数字水粉风景、细腻厚涂风景、干刷色块、干笔色块、干刷、干刷插画、干笔插画、滚筒刷、滚筒色块、色块插画、大色块插画、毛边色块、刷痕色块、粗刷笔触、mid-century、世纪中期插画、中世纪现代插画、复古编辑插画、复古海报插画、水粉拼贴、撕纸色块、限色海报、暮色微缩绘本、暮色绘本、黄昏绘本、微缩绘本、黄昏转夜、昼夜交界、日夜交界、半边黄昏半边星空、粉彩黄昏、粉紫晚霞、黄昏星空、银河插画、野花坡、野花草坡、花海插画、萤火虫、放风筝插画、拼布山丘、条纹田野、小圆树、细节放大图、局部放大图、技术细节小窗、科学图版风插画、手写英文小字、晚安绘本、治愈系绘本插画、排线夜景、排线风夜景、彩铅夜景、色粉夜景、粉彩排线、短笔触夜景、笔触夜空、方向笔触、夜景版画、小版画、限量版画风、版画装裱、版痕、纸边标题、铅笔题字、夜景插画、夜空插画、深蓝夜景、靛蓝夜空、冷暖对比夜景、唯一暖光、夜里的火光、发光的云、被照亮的云、红色精灵闪电、精灵闪电、火山夜景、熔岩入海、熔岩、岩浆、火山喷发插画、海上风暴、海面倒影、光柱倒影、火星飞溅、星点、看海的人、礁石上的人、远处的小人、小人比例尺、雪夜篝火、渔火、笔记应用界面、笔记软件界面、笔记 App 界面、Obsidian 风、Obsidian 界面、Obsidian 风格、黑曜石笔记、深色笔记界面、暗色主题界面、Markdown 笔记、Markdown 编辑器、双链笔记、内部链接、关系图谱、知识图谱界面、图谱视图、局部图谱、反向链接、文件列表、侧边栏、标签页、属性栏、行内代码、代码块、mermaid、mermaid 流程图、代码块渲染成图、源码 / 阅读切换、阅读视图、引用标注、callout、读书笔记界面、知识库界面、第二大脑、讲解片里的笔记应用、应用窗口演示、白板卡片、无限白板、白板视图、画布视图、Canvas 视图、Obsidian Canvas、Obsidian 白板、笔记应用白板、卡片白板、卡片和连线、节点和连线、带箭头的连线、弯曲连线、连线标签、分组框、点阵背景、点阵白板、深色白板、深色界面卡片、彩色边卡片、勾选清单卡片、待办卡片、引用卡片、图片卡片、草图卡片、手绘平面图、缩放按钮、镜头平移、镜头缩放、卡片掉落动画、连线画出来、搬家计划、旅行计划白板、活动计划白板、头脑风暴白板、项目拆解白板、计划白板、Flexoki、Flexoki 纸面、Flexoki 配色、Flexoki 风、暖白纸、米白纸面、墨黑字、文档站风格、文档页图解、技术文档配图、图解页、一页图解、讲解片图表页、几张图讲清楚、流程图、画流程图、时序图、序列图、饼图、柱状图、条形图、对比表、参数对比、图表合集、图表墙、Mermaid 风、Mermaid 图、图表渲染器、灰底圆角框、小三角箭头、橙色聚焦框、数字滚动、计时器大数字、配方图解、步骤图解、手冲咖啡图解、菜谱图解、工作流程图解、暖调彩铅绘本、暖调彩铅、彩铅绘本、彩铅童书、彩铅童书插画、彩色铅笔绘本、彩色铅笔童书、软彩铅、彩铅叠涂、层层叠涂的彩铅、顺着形体排线、纸齿白点、纸纹透白、怀旧童书、翻绘本的感觉、温暖怀旧的绘本、暖色绘本页、巨物与小孩、大动物和小孩、巨大温柔的生物、温柔的巨兽、大乌龟、巨龟、老乌龟、背着花园的乌龟、龟背上的小花园、大龟过河、过河、小溪、踏脚石、提灯笼的小孩、黄色雨衣、纸灯笼、亮灯的窗、亮灯的小房子、黄昏小镇、成簇的毛、顺毛、毛一绺一绺、苔藓、金黄的树、彩色小镇、彩色房子、彩色街景、童话小镇、童话街景、治愈小镇、理想的生活环境、欧洲小镇、山城小镇、钟楼小镇、彩虹小镇、彩旗、三角彩旗、彩旗串、彩旗街、节日街道、节日早晨、钟楼、白色钟楼、洋葱顶、石板屋顶、曼莎屋顶、老虎窗、烟囱帽、电视天线、风向标、爬藤玫瑰、窗台花箱、铁艺阳台、台阶街、石头台阶、拱门下的台阶、湿街倒影、雨后街道、雨后的广场、水粉街景、水粉加描线、水粉平涂加细线、细节多到看不完、小红书彩色小镇、色粉小像、色粉画、软色粉、色粉笔触、色粉质感、色粉加水粉、粉彩笔触、粉彩质感、绘本角色、绘本人物、绘本小像、角色小像、人物小像、半身像、人和宠物、人和猫、人和狗、主人和宠物、抱着猫、抱着狗、橘猫、大橘、毛茸茸的猫、毛茸茸的狗、狐狸、猫围巾、把猫当围巾、白底插画、留白插画、不画背景、边缘散开、干笔散开、画到边上就散了、大眼睛、大圆眼、大腮红、红鼻头、红鼻尖、发丝、一根根头发、头发丝、飞丝、毛绒绒、蓬松的毛、温柔的小像、治愈系角色、Midjourney 色粉风、诗意万圣夜、诗意万圣节、万圣节、万圣夜、万圣节插画、万圣节绘本、万圣节头像、秋夜、秋夜插画、忧郁绘本、忧郁风、超现实绘本、诡异又温柔、瓷白的脸、瓷娃娃脸、瓷偶、脸上的红晕、红眼眶、红眼圈、红鼻头、厚眼皮、半闭的眼睛、悲伤的眼睛、不笑的小嘴、波波头、黑色波波头、银白波波头、齐刘海、刀切刘海、粗麻、麻布、麻袋布、粗麻帽子、毛毡帽、粗针织围巾、毛线手套、格子呢、格纹外套、苏格兰格子、小幽灵、床单幽灵、发光的小幽灵、发光的眼睛、罐子里的幽灵、深色叶丛、星空肖像、Midjourney 万圣风),或 "draw it yourself", "paint with code", "procedural painting", "watercolor / collage / colored pencil / anime / editorial / impasto oil / ukiyo-e / pixel art / clay / claymation / cyanotype / sun print / cross-stitch / embroidery / retro instrument panel / vintage radio / sticker collage / receipt / lab notebook / graph paper / chalkboard / blackboard / cyberpunk / neon city / cartoon / hand-drawn animation / isometric / 2.5D / continuous line / one-line drawing / soft 3D / 3D render / puffy letters / ball pit / shape morph / morphing / newspaper collage / Dada / ransom note / halftone / glassmorphism / aurora gradient / Bauhaus / geometric poster / screen print / synthwave / retrowave / outrun / perler beads / hama beads / artkal / fuse beads / melty beads / pegboard beads / petroglyph / rock art / rock carving / desert varnish / Egyptian tomb painting / ancient Egypt / hieroglyphs / Theban tomb / Roman mosaic / floor mosaic / tesserae / opus vermiculatum / Pompeii mosaic / stained glass / leaded glass / church window / Gothic window / grisaille / illuminated manuscript / medieval manuscript / book of hours / gold leaf / illuminated initial / blackletter / vellum / astrolabe / da Vinci notebook / Leonardo codex / Renaissance sketchbook / mirror writing / iron-gall ink / red chalk / sanguine / ornithopter / exploded view / inventor's sketch / silhouette / silhouette portrait / cut-paper profile / shade portrait / Georgian portrait / Regency portrait / oval gilt frame / letterpress / wood type / playbill / circus poster / Victorian poster / two-colour misregistration / woodcut poster / constructivism / constructivist poster / Soviet avant-garde / Russian avant-garde / Rodchenko style / photomontage poster / art deco / streamline moderne / 1930s travel poster / railway poster / airbrush poster / sunburst rays / Gatsby style / golden age comic / vintage comic book / comic cover / Ben-Day dots / four-color printing / newsprint / speech balloon / pulp cover / pop art / Warhol-style / pop silkscreen / silkscreen portrait / repeated pop portrait grid / ASCII art / text art / typewriter art / line printer / greenbar / fanfold paper / tractor feed / overstrike / printer plot / low poly / low-poly / retro 3D / 90s 3D game / PS1 style / N64 style / software rasterizer / flat shading / affine texture mapping / vertex fog / game HUD / stencil / stencil graffiti / spray paint stencil / street art / drips and overspray / Banksy-style stencil / embroidered patch / embroidery patch / iron-on patch / sew-on patch / merit badge / camp badge / merrow border / rocker patch / denim jacket patches / blueprint / technical drawing / crayon / kid's drawing / CRT terminal / green screen / thermal camera / thermal imaging / Delft tiles / Delft blue / cave painting / ochre / Lascaux-style / 1-bit / MacPaint-style / black-figure / Greek vase / pencil drawing / graphite / X-ray / baggage scanner / rubber hose / 1930s cartoon / linocut / lino print / VHS / home video / flat vector / flat illustration / storybook animation / squash and stretch / ballpoint / biro / ballpoint doodle / margin doodles / hand-drawn board game / overlay sheets / tracing-paper overlays / light box / colour separations / registration marks / acetate overlay / pastel UI / Dot-style product film / launch-film interface / macOS window cards / exam grading / grading an answer sheet / red-pen marking / graded test paper / rubber-stamped answer sheet / shadow puppet / shadow puppetry / Chinese shadow play / leather shadow puppets / backlit puppet screen / pen and wash / pen & wash / line and wash / ink and watercolour / ink and watercolor / fineliner sketch / fineliner and watercolour / sketchbook characters / sketch cards / urban sketching / water brush / gouache / retro gouache / gouache portrait / gouache illustration / opaque gouache / matte acrylic / picture-book portrait / vintage picture book / retro children's book illustration / mid-century children's book / big-nosed character portrait / cable-knit sweater / knitted bobble hat / blue picture book / soft blue picture book / soft-blue children's book illustration / modern picture book / limited-palette picture book / picture-book spread / scratchy ink line / dry-brush ink line / ink pencil line / crayon and pastel texture / chalky white marks / blue and coral palette / fluffy white bear / Jiangnan garden / Chinese garden / classical Chinese garden illustration / Chinese water garden / spring garden illustration / lush painterly garden / waterside pavilion / moon gate / lattice windows / zigzag bridge / weeping willow garden / upturned eaves / grey-tiled roof / blossom trees and reflections / lily pond with egrets / digital gouache landscape / dry-brush blocks / dry brush illustration / dry-brushed colour blocks / roller texture / brush-textured shapes / mid-century illustration / mid-century modern poster / mid-century editorial illustration / gouache collage / torn-paper collage poster / limited palette poster / scumbled texture / vintage book cover illustration / twilight storybook / dusk picture book / dusk to night sky / day and night split sky / pastel sunset sky / Milky Way illustration / wildflower meadow / wildflower hill / patchwork hills / tiny round trees / fireflies / paper kite / magnified detail inset / detail callout circle / scientific plate overlay / handwritten lowercase captions / cozy miniature illustration / bedtime story illustration / hatched nocturne / hatched night scene / pastel hatching night / coloured-pencil nocturne / directional strokes / short brush strokes sky / night print with margins / small art print / plate mark / pencilled title and caption / indigo night with one warm light / glowing cloud lit from below / red sprites / lava entering the sea / volcano at night / glowing threads and sparks / broken reflection on the sea / tiny figures for scale / Obsidian UI / Obsidian-style note app / dark note-taking app / dark-theme Markdown editor / note app window / file explorer sidebar / wiki links / backlinks / graph view / local graph / knowledge graph UI / properties and tags / inline code / mermaid code block / mermaid flowchart rendered / source vs reading view / callout block / reading notes app / second brain UI / knowledge base screen / canvas board / infinite whiteboard / dotted board / note-app canvas view / Obsidian-style canvas / cards and connectors / curved arrows between cards / edge labels / group frames / coloured card borders / task-list card / quote card / image card with a sketch / hand-drawn floor plan / zoom controls / camera pan and zoom / cards dropping in / moving plan board / Flexoki / Flexoki paper / Flexoki palette / warm paper and ink / docs-site diagrams / explainer sheet / diagram sheet / Mermaid-style diagrams / lightweight diagram renderer / flowchart / sequence diagram / pie chart / bar chart / comparison table / diagram wall / grey-bordered boxes / small triangular arrowheads / orange focus ring / rolling numbers / recipe explainer / warm pencil storybook / coloured-pencil storybook / colored pencil picture book / soft pencil textures / layered coloured pencil / pencil strokes following the form / paper tooth specks / nostalgic children's storybook / giant gentle creature and a small child / giant tortoise / tortoise with a garden on its back / stepping stones / child with a lantern / yellow raincoat / paper lantern / lit windows at dusk / tufted fur in locks / Midjourney sref 3220081856 look without an image model / colour town / colorful European town / storybook street / fairy-tale town / candy-coloured houses / hill town / bunting / pennant flags / festival street / clock tower / onion dome / slate mansard roofs / dormers / chimney pots / TV aerials / climbing roses / window boxes / wrought-iron balconies / stepped lane / wet street reflection / gouache and ink cityscape / pastel vignette / soft pastel character / chalk pastel portrait / pastel textures and painterly brushstrokes / whimsical character design / picture-book character on white / person with a pet / girl and her cat / ginger cat / cat scarf / big round eyes / rosy cheeks / red-tipped nose / wispy hair strands / fluffy fur / feathered edges / vignette on white paper / Midjourney sref 455581803 look without an image model / poetic halloween / halloween portrait / autumn night portrait / melancholic picture book / surreal storybook portrait / porcelain face / red flush round the eyes / red-rimmed eyes / red nose / heavy-lidded sad eyes / blunt black bob / straight fringe / silver bob / burlap hat / felt hat / chunky knit scarf / knitted mittens / tartan coat / plaid coat / sheet ghost / little glowing ghosts / ghost in a jar / glowing eyes / dark foliage / starry night sky / Midjourney sref 3822619412 look without an image model" 时使用;也用于需要逐步画出(draw-on)动画的插画。单独说「剪纸」指剪纸拼贴、「刺绣」指十字绣、「丝网印刷 / screen print」指包豪斯几何;「打马赛克」是打码,不是马赛克画风;单说「蓝图」指蓝图工程图,「蓝晒 / 晒图」仍指蓝晒;「铅笔 / 素描」指铅笔素描,「彩铅」指韩国彩铅;「像素」仍指像素风,「1-bit / 黑白画图软件」指 1-bit 早期画图软件;「霓虹」仍指赛博朋克;「喷漆 / 街头涂鸦」仍指喷漆模板涂鸦,「圆珠笔 / 随手涂鸦 / 页边涂鸦」指圆珠笔涂鸦;「描图纸 / 硫酸纸 / 叠片 / 灯箱」指描图纸叠层(蓝图工程图那张描图布是晒成蓝图的,不是叠片);「Dot 风 / 粉彩界面 / 窗口卡片 / 发布会界面」指粉彩界面(纯色底 + 白色实心窗口卡片),要磨砂玻璃和弥散渐变仍用弥散玻璃;「阅卷 / 批改 / 答题卡 / 判卷 / 红笔打分」指阅卷批改,实验记录里的红笔圈和便利贴仍用实验笔记本,带「已付」橡皮章的小票拼贴仍用贴纸拼贴 · 小票;「皮影 / 皮影戏 / 影子戏」指皮影戏(透光的彩色驴皮人偶),黑纸剪出的侧影小像仍用剪影,彩纸剪贴仍用剪纸拼贴。「钢笔淡彩 / 淡彩速写 / 针管笔加水彩 / 线稿上色的速写小卡」指钢笔淡彩;单说「水彩」仍指水彩(风景、花卉的大片晕染),蓝铅笔稿 + 毛笔线 + 赛璐璐阴影的拟人小物仍用卡通手绘,「素描 / 铅笔」仍指铅笔素描。「水粉 / 复古水粉 / 绘本大头像 / 复古童书插画」指复古水粉(不透明水粉画的特写大头像);梵高式厚涂的风景、名画感仍用油画厚涂,扁平矢量、会挤压拉伸的小角色动画(「绘本动画」)仍用绘本角色动画,针管笔线稿加淡彩的速写小卡仍用钢笔淡彩,撞色多格的头像仍用波普丝网。「蓝调绘本 / 软蓝绘本 / 蓝色童书插画 / 绘本跨页」指蓝调绘本(软蓝限色的现代绘本跨页:干笔墨线 + 干蜡笔粉彩上色 + 白粉笔痕);单说「绘本」仍指绘本角色动画,「水粉 / 绘本大头像」仍指复古水粉,「编辑风 / Riso」仍指编辑风手绘,针管笔线稿加淡彩的速写小卡仍用钢笔淡彩,小孩自己画的蜡笔画仍用儿童蜡笔画。「江南园林 / 园林春景 / 中式园林插画 / 粉墙黛瓦 / 飞檐 / 月洞门 / 九曲桥」指江南园林(细笔数字水粉的园林春景:叶形小笔触堆出的繁茂树冠、繁花、垂柳、黛瓦飞檐、碧水倒影、层层远山);单说「水墨 / 山水」仍指水墨,单说「水彩」仍指水彩,动漫背景 / 赛璐璐天空仍指日本动漫,浮世绘仍是浮世绘;梵高式厚涂的风景仍用油画厚涂,皮影人偶的一场戏仍用皮影戏。「干刷色块 / 干笔色块 / 滚筒色块 / mid-century 海报插画」指干刷色块(米白纸上几大块干笔或滚筒刷出的限色色块,人物拆成几个大块面,背后一块纯色板、一旁一个小红方块);单说「水粉 / 绘本大头像」仍指复古水粉,「剪纸 / 彩纸拼贴」仍指剪纸拼贴,「丝网印刷 / screen print」仍指包豪斯几何,「Riso / 编辑风」仍指编辑风手绘,没有笔触的平滑几何色块仍用扁平矢量。「暮色微缩绘本 / 暮色绘本 / 黄昏转夜 / 昼夜交界 / 野花坡 / 细节放大图」指暮色微缩绘本(粉彩黄昏转入银河夜空、拼布山丘、几万朵小野花、很小的原创角色,加圆形放大图和手写小字);单说「绘本」仍指绘本角色动画,「蓝调绘本 / 软蓝绘本」仍指蓝调绘本,赛璐璐天空和夏日少年感仍用日本动漫,大片晕染的风景仍用水彩,整页的机械分解手稿仍用达·芬奇手稿,剖面和施工图仍用蓝图工程图。「排线夜景 / 彩铅或色粉夜景 / 短笔触夜空 / 夜景小版画 / 熔岩入海 / 精灵闪电 / 被照亮的云」指排线夜景(满画面顺着风向的短笔触、深蓝夜色里只有一个暖光、发光的丝和火星、碎的倒影、很小的人,装成带纸边和铅笔字的小版画);梵高式的厚涂漩涡和颜料浮雕仍用油画厚涂,明亮可爱的彩铅甜品仍用韩国彩铅,黑白石墨排线仍用铅笔素描,粉彩黄昏转入银河星空、满坡小野花仍用暮色微缩绘本,霓虹雨夜街道仍用赛博朋克。「Obsidian 风 / 笔记应用界面 / 深色笔记软件 / 双链笔记 / 关系图谱 / mermaid 代码块渲染成图」指笔记应用界面(深色主题的笔记应用窗口:文件列表、Markdown 正文、代码块切到阅读视图渲染成流程图、亮紫光点的关系图谱,只有一个紫色强调色);明亮的粉彩底和白色窗口卡片仍用粉彩界面,点阵无限白板上的卡片和弯曲连线用白板卡片,暖白纸面上的浅灰卡片图表用 Flexoki 纸面,磨砂玻璃和弥散渐变仍用弥散玻璃,绿屏荧光字符的老终端仍用绿屏终端 CRT,霓虹全息的未来界面仍用赛博朋克。「白板卡片 / 无限白板 / Canvas 视图 / 卡片和连线 / 点阵白板 / 分组框 / 带箭头的弯曲连线」指白板卡片(深色应用窗口里随镜头平移缩放的点阵白板:分组框、彩色边卡片、带箭头和标签的弯曲连线、清单 / 引用 / 草图卡片、右上角缩放按钮);笔记正文页、文件列表和关系图谱仍用笔记应用界面,暖白纸上的流程图、时序图和图表仍用 Flexoki 纸面,明亮的粉彩产品界面和检查结果仍用粉彩界面,一层层叠起来的图解仍用描图纸叠层。「Flexoki / Flexoki 纸面 / 暖白纸上的图解页 / Mermaid 那样的流程图、时序图、饼图、柱状图、对比表 / 讲解片里的图表页」指 Flexoki 纸面(暖白纸、墨黑字、不描边的浅灰圆角卡片,卡片里的图照轻量图表渲染器画:灰边框、墨线小三角箭头、普通标签,强调色只点在有意义的地方);手写粉笔的示意图仍用黑板板书,铅笔图表、荧光笔和便利贴仍用实验笔记本,彩色粉彩底、macOS 窗口和 ✓ / ✗ 徽章的产品界面仍用粉彩界面,深色笔记应用窗口仍用笔记应用界面,点阵无限白板上的卡片和连线仍用白板卡片,系统的微缩模型仍用等轴 2.5D,剖面和施工图仍用蓝图工程图。「暖调彩铅绘本 / 彩铅绘本 / 彩铅童书插画 / 巨物与小孩 / 大龟过河 / 纸齿白点 / 层层叠涂」指暖调彩铅绘本(暖白纸上满画面顺形体的彩铅叠涂、纸齿透出细白点、毛发成簇顺毛,大而温柔的生物和小小的孩子,黄昏暖光和橙黄的灯,没有墨线和黑色);单说「彩铅」仍指韩国彩铅(明亮可爱的甜品小物、粉嫩高光),黑白石墨仍用铅笔素描,软蓝限色、刮擦墨线加蜡笔颗粒的绘本跨页仍用蓝调绘本,粉彩黄昏转入星空、满坡小野花仍用暮色微缩绘本,不透明水粉的特写大头像仍用复古水粉,深蓝夜色里只有一个暖光的排线小版画仍用排线夜景;单说「绘本」仍指绘本角色动画。「彩色小镇 / 彩色房子 / 童话小镇 / 童话街景 / 彩旗街 / 钟楼小镇 / 水粉加描线的街景 / 有被这彩色小镇治愈到」指彩色小镇(水粉平涂加细墨线,密密的彩色房子堆上山坡,石板曼莎屋顶、白色钟楼、好几层三角彩旗、爬藤玫瑰和窗台花、湿街倒影);中式园林和古镇仍用江南园林,锡釉蓝砖上的运河小镇仍用代尔夫特蓝瓷砖,黑白刻版的雪村仍用黑白麻胶版画,彩纸剪出来的热气球小镇仍用剪纸拼贴,系统的微缩模型和小岛仍用等轴 2.5D,针管笔速写加淡彩的小卡仍用钢笔淡彩,水粉画的人物大头像仍用复古水粉,彩铅叠出来的黄昏小镇和巨物仍用暖调彩铅绘本,没有描线、没有笔触的几何色块仍用扁平矢量。「色粉小像 / 色粉画 / 绘本角色小像 / 人和宠物 / 猫围巾 / 白底不画背景、边上干笔散开的角色 / 大眼睛大腮红红鼻尖」指色粉小像(白纸上的半身角色小像,软色粉加一点水粉,大圆眼、大腮红、红鼻尖、一根根的发丝和蓬松的毛,柔和的粉蓝和奶油色里只有一组暖橙,边缘散进白纸);背后刷一块单色、看得见毛衣针脚的复古童书大头像仍用复古水粉,满画面彩铅叠涂、带天空和场景的黄昏绘本页仍用暖调彩铅绘本,软蓝限色、乱线墨线的绘本跨页仍用蓝调绘本,针管笔线稿加淡彩的速写小卡仍用钢笔淡彩,明亮可爱的彩铅甜品小物仍用韩国彩铅;「色粉夜景」仍指排线夜景,「粉彩界面」仍指产品界面。「诗意万圣夜 / 万圣节绘本 / 忧郁的瓷白脸 / 红眼眶红鼻头 / 黑色齐刘海波波头 / 粗麻帽子 / 发光的小幽灵」指诗意万圣夜(暗色画板上忧郁、超现实的秋夜绘本肖像:瓷白的脸泛红晕、半闭的厚眼皮、一整块的波波头、粗麻 / 针织 / 格子呢织物,靛蓝星空或深色叶丛里只有一处发光的点睛);白纸上不画背景、色调粉粉的角色小像仍用色粉小像,背后刷一块单色、大鼻子红脸蛋的复古童书大头像仍用复古水粉,满画面短排线、只有一个暖光的夜景小版画仍用排线夜景,粉彩黄昏转入星空的微缩风景仍用暮色微缩绘本,满画面彩铅叠涂的温暖黄昏童书页仍用暖调彩铅绘本。---# Claude 绘图@@ -90,6 +90,7 @@ description: Claude 绘图 / Claude Drawing —— 不借助任何生图模型| 暖调彩铅绘本 · Warm Pencil Storybook | `lib/pencilbook.py` · `PencilStorybook` | `examples/pencilbook_tortoise_crossing.py` 大龟过河 · The Tortoise Crossing(一页暖调彩铅绘本:黄昏,一只很老、很大的乌龟慢慢蹚过一条浅浅的小溪,背上长着一座小花园——一圈连成片的苔藓垫,垂下一绺绺长苔藓,里面几丛草和野花、一棵秋天金黄的小树、一根弯木杆上挂着一盏纸灯笼;它低下头,用一双老而温和的眼睛看着身旁踏脚石上的小孩:黄色雨衣、帽子放下、短短的波波头、红靴子,也提着一盏灯笼,仰头看它;龟壳一块块盾片都是低低的穹顶,绕着生长纹排线,沟是断续的深褐线,受光的左侧被落下的太阳镶一道暖边,右边背光面叠一层冷紫;脖子横着几道松弛的褶,腿上一片片小鳞,前腿往前迈、后腿往后蹬,肚子底下的水压在阴影里;背后是从软蓝到蜜桃、奶油黄的天空和留白的云,太阳刚落到远山后面,山坡上几栋小房子亮了灯;水里是一笔笔横排线画出的倒影:天、窗灯、龟腿和小孩;近岸两丛开小花的灌木框住画面;所有面都是顺形体的细彩铅线一层层叠出来的,纸齿透出细白点,没有墨线和黑色;照绘本画家的顺序画:空纸、天空(先把龟、树和灯杆留白)、远山和小镇、溪流、龟的浅色底层、塑形、背上的花园、踏脚石和小孩、倒影和涟漪,最后是灯光和近岸;`--stages` 出 9 个阶段加成品) | 约 40 秒 || 彩色小镇 · Colour Town | `lib/colortown.py` · `ColorTown` | `examples/colortown_festival_steps.py` 雨后的节日台阶街 · Festival Steps After the Rain(1500×2000 的竖幅童话街景,不透明水粉平涂加细细的深棕墨线:节日的早晨,刚下过一阵雨,一条石头台阶从湿漉漉的小广场爬上山,从一栋薄荷绿房子底下的拱门里穿过去,接着往上走;番茄红、芥末黄、青绿、薄荷、珊瑚、奶白、天蓝的房子一排压一排堆上山坡,越往上越小、越淡,有尖尖的山墙、窄窄的塔楼式房子和几片赤陶瓦,深蓝灰的石板曼莎屋顶一片片错缝铺出来,带老虎窗、烟囱和赤陶烟囱帽、电视天线;山顶左边一座白色钟楼,铜绿洋葱顶、三扇木百叶钟楼开口、指着九点零几分的钟面、顶上一面红旗;淡蓝的天,奶白的云,几只小鸟;左边是一面往消失点收的峡谷墙(浅粉、白、浅黄三栋,整面墙按透视单应贴上去),右边是一栋离我们很近的白房子,有几扇浅蓝百叶窗、铁艺阳台、窗台花箱,底层是青绿色的咖啡馆,条纹遮阳篷,外面摆两张小咖啡桌;三角彩旗挂在四个深度上:远处山上两串很小的,上排房子前一串,广场上两串,最近四串大的斜穿过整个画面,每面旗有一道深一点的折痕,绳子从钟面下面过;红玫瑰和粉玫瑰爬满墙角,窗台花箱里花叶溢出来,还有花店 FLEURS 门口一排花桶、面包店 PAIN、吊挂的咖啡杯和钥匙店招、壁灯、墙脚的海报和盆栽、台阶两侧的石墙和铁栏杆、台阶上一只猫、两棵圆圆的绿树;广场是湿的,把房子、彩旗和人倒映成一道道竖向的笔触,石板缝淡淡地透出来;几个很小、不画脸的人:打红伞的、牵红气球的孩子、一对并肩走的、提一篮花的;照插画师的顺序画:空纸 → 天空和云 → 远处的小镇和钟楼 → 上面两排房子和树 → 拱门房子、台阶和广场边的房子 → 两侧的峡谷墙 → 玫瑰、花盆和店招 → 近处的彩旗 → 湿广场和倒影 → 行人、路灯和咖啡桌;`--stages` 出 9 个阶段加成品) | 约 7 秒 || 色粉小像 · Pastel Vignette | `lib/pastelvignette.py` · `PastelVignette` | `examples/pastelvignette_marmalade_scarf.py` 橘猫围巾 · The Marmalade Scarf(1920×1080 的白底角色小像,软色粉加一点水粉:冷天的早上,一个年轻女人把她的大橘猫当围巾围在脖子上——猫头和两只前爪从她一边肩上垂下来,一只后爪和带深色环纹的尾巴从另一边垂在大衣前面;她朝猫歪着头、斜眼看它、抿着嘴笑,猫用一双圆圆的琥珀色眼睛抬头看她;蓝黑色的长波浪发,侧分的刘海斜过额头,大圆眼、深棕虹膜和白高光,两大圈腮红,红鼻尖,小嘴;浅粉蓝的大衣看得见顺着衣褶和袖子的干笔,大衣下摆在白纸上干笔散开,里面是奶油色的罗纹毛衣;猫毛先铺一层宽的软笔触,再一簇簇细毛、受光处的浅色毛尖、额头几道深色虎纹,轮廓蓬松地融进后面的头发和大衣,奶白的嘴套和爪子、粉色的耳朵里、白胡子;背后左边一枝桉树叶(夹几片赭黄的),右边一层很淡的铅笔小镇(几栋房子和一座圆顶塔),其余都是白纸;照色粉插画师的顺序画:空纸 → 铅笔起稿 → 桉树枝和铅笔小镇 → 平涂大块 → 塑形(揉开的脸、大衣的干笔)→ 猫毛 → 一绺绺的头发 → 五官 → 干笔高光和飞出来的几根头发;`--stages` 出 8 个阶段加成品) | 约 9 秒 |+| 诗意万圣夜 · Poetic Halloween | `lib/poetichalloween.py` · `PoeticHalloween` | `examples/poetichalloween_ghost_jar.py` 罐子里的小幽灵 · The Ghost in the Jar(1920×1080 的秋夜绘本肖像,暗色画板上的水粉加细排线:十月的最后一夜,一个苍白的孩子站在深色的树丛里,戴一顶软塌的粗麻钟形帽(帽檐垂着松开的麻线,一圈麻绳打了个小蝴蝶结),乌黑的齐耳波波头、刀切一样平的齐刘海,整块头发上一道柔和的光泽;瓷白的脸,眼睛一圈、鼻梁和脸颊泛着红晕(平滑的红加细密的红斑点),厚眼皮半闭、往外眼角垂,低头看着手里的罐子,虹膜里映着一点暖光,红鼻尖,不笑的小嘴;深红的粗针织围巾围到下巴,一头垂在胸前,深色格子呢外套(藏青、墨绿加细的锈红和赭黄线,斜纹织出来,格子随衣褶起伏),两颗牛角扣;一双深红针织手套从两边扶着一个玻璃罐,罐口蒙着粗麻布、用麻绳扎住,罐子里一个床单小幽灵发着光,暖光照亮手套、玻璃边和她的下巴;树丛里和星空中还有五个小幽灵(银色细丝的身子,琥珀色发光的眼睛,衣摆每个尖一颗光珠),身边的叶子被照成橄榄色和橙色,其余的叶子几乎是黑绿的,每片都往后面投一块影子;靛蓝夜空里有细的斜笔触和星星;照在暗色画板上作画的顺序画:画板 → 粉笔起稿 → 夜空和星星 → 深色叶丛 → 平涂大块 → 极简的体积 → 织物 → 五官 → 小幽灵和它们的暖光 → 前景叶子和最后几笔;`--stages` 出 9 个阶段加成品) | 约 10 秒 |各画风共用 `lib/core.py` 里的底层工具:噪声、模糊、样条曲线、多边形遮罩、有机轮廓 `blob_pts`、毛笔 `bristle_stroke`、中文字体查找;新四种还用到补零平移 `shift`、文字遮罩 `text_mask`、西文字体查找 `latin_font`/`load_font`,以及高度图打光 `height_normals`、`height_shadow`(沿光线步进的投影)、`ambient_occlusion`。@@ -169,7 +170,8 @@ description: Claude 绘图 / Claude Drawing —— 不借助任何生图模型- 讲解片、文档、教程里的「图表页」:步骤和流程、时间线上的往来、占比、对比,要像文档站或技术博客里的图——暖白纸、墨黑字、浅灰圆角卡片,图像 Mermaid 渲染出来那样干净(灰边框、墨线小三角箭头、普通标签),一页放几张图讲清一件事(一份配方、一个工作流程、一次部署、一组产品数字),还能做成「图一边一边画出来、数字滚动」的动图 → Flexoki 纸面(要手写粉笔的示意图用黑板板书;要铅笔图表和便利贴的实验记录用实验笔记本;要彩色粉彩底和 macOS 窗口的产品界面用粉彩界面;要深色笔记应用窗口用笔记应用界面;要点阵白板上的卡片和连线用白板卡片;要系统的微缩模型用等轴 2.5D);- 温暖、怀旧、像翻开一本童书的一页:一只大而温柔的生物陪着一个小小的孩子(巨龟、大熊、温柔的怪兽陪孩子过河、等车、看日落),午后和黄昏的暖光、亮灯的窗和灯笼、草地、小溪和小镇,要满画面看得见彩色铅笔的笔触和纸齿,讲解片里「温柔的陪伴 / 慢慢来 / 一起走一段」的页,童书封面和插页 → 暖调彩铅绘本(要明亮可爱的彩铅甜品小物用韩国彩铅;要软蓝限色、乱线墨线的绘本跨页用蓝调绘本;要粉彩黄昏转入星空、满坡野花用暮色微缩绘本;要黑白石墨写生用铅笔素描;要不透明水粉的特写大头像用复古水粉);- 治愈、明亮、「细节多到看不完」的童话街景:一座彩色的欧洲小镇、节日的街道、雨后的广场、钟楼和台阶,满街彩旗、玫瑰、花箱和阳台,要一眼就是「手画的水粉插画加细细的描线」,竖幅海报、小红书封面、旅行 / 城市 / 节日 / 「理想的生活」的配图,讲解片里「一个地方 / 一个社区 / 很多人一起生活」的页 → 彩色小镇(要中式园林、古镇和春水用江南园林;要锡釉蓝砖上的运河小镇用代尔夫特蓝瓷砖;要彩纸剪出来的小镇用剪纸拼贴;要系统的微缩模型用等轴 2.5D;要针管笔速写加淡彩的小卡用钢笔淡彩;要没有描线的几何色块用扁平矢量;要彩铅叠涂的黄昏小镇用暖调彩铅绘本);-- 一两个讨喜的角色的小像:一个人和他的小动物(猫、狗、狐狸)、温柔的一刻(抱着、依偎、对视)、人设卡和头像,要一眼就是「绘本里的色粉加一点水粉」——白纸上不画背景,画到边上就干笔散开,大圆眼、大腮红、红鼻尖,一根根的发丝和蓬松的毛,柔和的粉彩色里只有一种暖橙,讲解片里「这个人 / 这只宠物 / 陪伴」的页,小红书头像和封面 → 色粉小像(要复古童书味、背后刷一块单色、看得见毛衣针脚的大头像用复古水粉;要满画面彩铅叠涂、有天空有场景的黄昏绘本页用暖调彩铅绘本;要软蓝限色、乱线墨线的绘本跨页用蓝调绘本;要针管笔线稿加淡彩的速写小卡用钢笔淡彩;要明亮可爱的彩铅甜品小物用韩国彩铅)。+- 一两个讨喜的角色的小像:一个人和他的小动物(猫、狗、狐狸)、温柔的一刻(抱着、依偎、对视)、人设卡和头像,要一眼就是「绘本里的色粉加一点水粉」——白纸上不画背景,画到边上就干笔散开,大圆眼、大腮红、红鼻尖,一根根的发丝和蓬松的毛,柔和的粉彩色里只有一种暖橙,讲解片里「这个人 / 这只宠物 / 陪伴」的页,小红书头像和封面 → 色粉小像(要复古童书味、背后刷一块单色、看得见毛衣针脚的大头像用复古水粉;要满画面彩铅叠涂、有天空有场景的黄昏绘本页用暖调彩铅绘本;要软蓝限色、乱线墨线的绘本跨页用蓝调绘本;要针管笔线稿加淡彩的速写小卡用钢笔淡彩;要明亮可爱的彩铅甜品小物用韩国彩铅);+- 秋天和万圣节的夜晚、忧郁又有点超现实的一刻:一个苍白的孩子或年轻人独自站在夜里,手里捧着一点光或一个发光的小东西,身边有几个发光的小幽灵,要一眼就是「诗意的万圣节绘本」——瓷白的脸上一圈红晕、半闭的厚眼皮、刀切的黑色波波头,摸得着的粗麻帽子、粗针织围巾、格子呢外套,暗沉的靛蓝夜空和深色叶丛里只有一处暖光,讲解片里「孤独 / 守护 / 秋天 / 夜晚」的页,万圣节海报、头像和小红书封面 → 诗意万圣夜(要白纸上不画背景、粉粉的温柔角色小像用色粉小像;要背后刷一块单色、看得见毛衣针脚的复古童书大头像用复古水粉;要深蓝夜色里只有一个暖光、满画面短排线的小版画用排线夜景;要粉彩黄昏转入星空、满坡小野花的微缩风景用暮色微缩绘本;要满画面彩铅叠涂、温暖治愈的黄昏童书页用暖调彩铅绘本)。每种画风一幅范例作为质量基准(范例都不用禅意主题);水墨另加一幅「月印万川」(留白托月、水面倒影)。@@ -1323,6 +1325,32 @@ from core import spline, curve, blob_pts, fbm1d, blur, polygon_mask- 颜色用 `PAINTS` 里的名字(paper white chalk pencil pencil_light graphite;skin skin_light skin_pale skin_shade skin_deep blush nose lip lip_dark lid brow crease;eye_white eye_shade iris iris_light pupil amber amber_light olive_eye;hair_black hair_dark hair hair_blue hair_grey hair_light;powder_deep powder_shade powder powder_light powder_pale cream cream_shade cream_deep ivory;ginger_deep ginger_dark ginger orange tangerine apricot peach butter mustard fur_cream fur_white ear_pink;eucalyptus_deep eucalyptus eucalyptus_light sage olive ochre stem mist umber)或 '#rrggbb';色阶用 `RAMPS` 里的名字(skin neck powder cream ginger hair eucalyptus ochre mist,都是暗 → 亮)或自己给一串颜色。- 范例的场景脚本先把所有形状的遮罩算好(`plan()`),再按从前往后的遮挡算出每块「看得见的部分」(刘海 > 猫 > 脸 > 脖子 > 猫身后的那绺头发 > 毛衣 > 大衣 > 后面的头发),每一层只往自己看得见的部分上画;留着的 37 张画布大小的遮罩和受光场存成 float16。+**诗意万圣夜 `PoeticHalloween`**:+- 思路:照插画师在暗色画板上的顺序画一张忧郁的秋夜绘本肖像(画板 → 粉笔起稿 → 夜空和星星 → 深色叶丛 → 平涂大块 → 极简的体积(瓷白的脸、一整块的波波头和光泽)→ 织物(粗麻、格子呢、针织)→ 五官(红晕、眼睛、鼻子、嘴)→ 小幽灵和它们的暖光 → 前景叶子和最后几笔);满画面暗,只让一处发光。+ - 画板:暗色画板,直方图均衡过的纸纹 `T`(0–1 均匀分布),所以「颜料挂在纸纹高于 1 − 压力的地方」直接就是覆盖率;预先算好沿 8 个方向拖开的纸纹(存成 uint8),干笔按自己的方向取。另有一张单像素的细点子纹 `ST`(uint8),专给红晕的斑点用;印刷颗粒和较粗的印刷纸纹在 `ground()` 里先算好(那时内存还低),`render()` 只取用。+ - 笔触:和色粉小像同一套按段编号的 id 图光栅化(Pillow 把每一笔的每一段按序号画进 2 倍超采样的整数 id 图,numpy 查回这一段,算出沿笔的压力曲线、两侧软边和越干越开的鬃毛条纹,压力够得着纸纹才上色,bincount 汇回像素):宽的是不透明水粉的干笔,细而长就是彩铅排线。`colour='canvas'` 让每一笔取它中心下面画布的颜色——在算出来的底子(格子呢、塑形过的脸、夜空)上「用手再画一遍」,颜色不变、多了笔触。混色用以白为参照的乘:目标 =(1 − opacity)× 旧 × 颜色 + opacity × 颜色,暗底上也成立。一批太大就按 y 分成小带(每带 `band_px` 个子像素,省内存)。+ - 体积:`wash()` 平滑的一层不透明色(颜色可以按场取色阶;按行分带算,整张铺色也不建整张的 RGB 临时数组),最深的纸坑留一点浅,边缘按纸纹断开;`model()` 用软穹顶光把暗 → 亮的色阶揉上去——参考图那种极简的体积就是这样来的。`soften()` 只在形状附近做模糊。+ - 头发:波波头是一整块:先按整块头发(刘海、远侧那片、后面的)同一张受光揉色阶(近黑 → 板岩蓝);`sheen()` 只在受光落在一条窄带(lo, peak, hi)里的地方铺一层柔和的光泽,再顺着发流画几笔又细又长、很淡的笔触,光泽沿头发拉开、整块不碎成发丝;`strands()` 只用很低的对比度画一点发丝;刀切的刘海就是遮罩的直边,加几根细发梢。+ - 脸:`eye()` 重眼皮的忧郁眼睛:杏仁形的米白眼球,上眼皮盖住约一半虹膜、往外眼角垂(`droop`),眼皮是一块揉成粉红的鼓起的皮肤,深色眼线,下眼睑一道湿红的边(`rim`),上面一道淡的双眼皮,一点白色高光;`reflect` 再在虹膜下半点一点暖色(她低头看的那盏光映在眼里)。`flush()` 是红晕:平滑的一层红加一层单像素的细斑点,红晕越浓斑点越密;`spot()`、`ring()` 给它软的场(脸颊、眼睛一圈、下半圈更浓)。`nose()` 长而简化的鼻子自成一个小体积:按光塑形,背光一侧一块柔和的紫灰,鼻尖往下投一小块影子,越往下越红、红鼻尖,一点鼻孔,鼻梁一道淡的亮线;`mouth()` 闭着、不笑的小嘴,嘴角往下。+ - 织物:`burlap()` 粗麻的平纹:每一行、每一列线各自粗细,沿线有疙瘩,行列略有游走,一上一下地交织,当高度场打光后乘到原来的颜色上,线之间是黑的孔,表面有松出来的纤维、轮廓上有毛边;`coords=(U, V)` 让织纹顺着形状走(`along(path, mask)` 给出顺着管子弯的坐标,帽檐就沿着它的弧线织)。`knit()` 粗针织的 V 形针脚(`path` 让针脚列顺着围巾走),`rib()` 罗纹。`tartan()` 格子呢:半个 sett 镜像成对称的循环,2/2 斜纹决定每一格露经线还是纬线、每根线略圆,再乘上衣褶的受光,`coords` 让格子随衣褶起伏。`fuzz()` 从轮廓里侧往外长纤维,颜色取它里面几 px 的颜料。+ - 叶丛:`leaf()` 掌状、重锯齿的叶子(醋栗 / 枫叶那样宽的裂片、浅的缺刻),随机压扁(侧着看),每片裂片沿中脉对折、一边亮,越往叶尖越亮,有斑驳和浅色叶脉,先往右下投一块软影子——树丛的前后层次就是这样来的;`foliage()` 从后往前撒几百片,越远越小越暗;`lit` 让叶子按光照图被照亮(小幽灵旁边的叶子变暖)。+ - 光:`light()` 登记暖色点光源(衰减 1 /(1 +(d / r)²)²,很陡,小幽灵只照亮身边);`illuminate()` 按光照图照亮已经画好的东西:C ← 1 −(1 − C)· exp(−L × 接受度 ×(base + albedo × C)),所以浅色的毛线和瓷白的脸变暖很多,暗的叶子在小幽灵旁边变成橄榄橙,黑头发几乎不变;接受度是一张场(叶子全接、天空一点、脸只有朝下的部分)。`emit()` 写进发光缓冲,`render()` 把它分三档模糊后叠成光晕。+ - 小幽灵:`ghost()` 半透明的圆顶钟形床单,由几百根银色细丝组成,像头发一样从头顶往外、往下披到一圈一绺绺的衣摆;一对发光的眼睛(奶白芯、琥珀色圈、光晕),每一绺末端一颗拉长的暖光珠,衣摆被暖光照亮,整块床单有一层很淡的光晕。+ - 收尾:`finish()` 只记参数、在 render 里加(每张阶段快照都和成品一致,要在画第一笔之前调用):轻微柔化、发光的光晕、细的印刷颗粒加一层在暗部更显的粗纸纹、黑色微微提亮;按行分带算。+- 构造:`PoeticHalloween(W, H, seed, keep_stages=True, stages_dir=None)`(总像素不超过 4096²),先 `finish()` 再 `ground(tone, tooth)`。坐标是整张画布的像素;给方向场传一个数就是角度(度,0 向右、90 向下),方向场数组是弧度,也可以直接传 f(x, y) → 度(只在用到的点上求值);`LIGHT` 是默认光(左上、略朝前)。+- 遮罩:`poly(pts, smooth)`、`ellipse(cx, cy, rx, ry, rot)`、`blob(cx, cy, rx, ry, rough)`、`tube(path, w0, w1)`(`w0` 可以是一串沿路径的宽度)、`rect(x0, y0, x1, y1)`、`below(xs, ys, invert)` 返回画布大小的浮点遮罩;`spot(cx, cy, rx, ry, rot, solid)`、`ring(cx, cy, rx, ry, width, rot, below)` 软的场;`soften(mask, sigma)` 只在形状附近模糊。+- 方向场:`flow(角度, 扰动, 尺度)`、`field(f(x, y) → 度)`、`radial(cx, cy, offset)`、`contour(mask, sigma, offset, fallback)`、`blend(f1, f2, w)`、`rotate()`;`value(top, bottom, y0, y1)` 竖向的 0–1 场;`shading(mask, light, sigma, wrap)` 软穹顶的受光。+- 笔触:`strokes(region, field, colour, length, width, density, pressure, opacity, alpha, streak, soft, taper, passes, clip, avoid, fade)`(`colour='canvas'` 取画布上的颜色);`lines(paths, …)`;`sketch(path, colour, width, alpha)` 暗底上很淡的粉笔起稿线(几笔叠成、有的断开)。+- 色层:`wash(mask, colour, alpha, grain, edge, dry, clip, opacity)`;`model(mask, colours, light, lit, sigma, wrap, gamma, lo, hi)` 返回受光场;`glaze(mask, colour, alpha, mode, soft)`(multiply / screen / normal);`dab(x, y, r, colour, alpha, soft, ry, rot)` 一小点(高光、发光的眼睛);`line(path, width, colour, alpha, taper, dry, clip)` 平滑的细圆笔线(眼线、湿红的下眼睑、叶脉、麻绳)。+- 头发:`strands(region, flow, colours 暗→亮, n, length, width, curl, jitter, shade, spread, alpha, clip, roots, lock)`;`sheen(mask, flow, lit, band, colour, alpha, strokes)`。+- 五官:`eye(cx, cy, rx, ry, iris, iris_light, iris_r, look, lid, lower, droop, fold, rim, crease, reflect, rot, side, clip)`(`side` 是外眼角朝哪边,`look` 取 -1..1,dy > 0 往下看);`flush(field, colour, strength, speckle, clip)`;`nose(path, width, tip_r, side, shade, tip, tip_strength, clip)`;`mouth(x, y, w, droop, colour, rot)`。+- 织物:`burlap(mask, angle, period, coords, thread, slub, holes, rust, fibres, fuzz)`;`knit(mask, stitch, angle, path, origin, curve)`;`rib(mask, path, period)`;`tartan(mask, sett, scale, angle, coords, lit, lo, hi)`;`fuzz(mask, length, n, width, out, field, lift)`;`along(path, mask)` → (S, T)。+- 叶丛:`leaf(x, y, size, angle, colours, value, fold, lit, veins, lobes, squash, shadow)`;`foliage(region, n, size, colours, value, angle, fold, lit, veins, squash, shadow)`。+- 光和小幽灵:`light(x, y, r, colour, power, squash, fall)`、`lightmap()`、`illuminate(receptivity, gain, base, albedo)`、`emit(x, y, r, power, ry)`;`ghost(cx, top, w, h, look, tips, strands, glow, lean, eye_r, body_alpha, sheet, clip)`;`stars(region, n, size, bright, warm)`。+- 收尾:`finish(soft, grain, tooth, bloom, lift, warmth)`;`render()`、`composite()`、`stage(name)`、`save(path, stages_dir)`;`save('x.jpg')` 默认 quality 88、4:4:4 色度。+- 颜色用 `PAINTS` 里的名字(board chalk chalk_warm;night_deep night indigo dusk haze star warmstar;porcelain porcelain_light porcelain_shade porcelain_deep flush flush_light flush_deep rim lip lip_dark lid_line crease;eye_white eye_shade iris iris_light pupil;jet hair_black hair_dark hair hair_sheen hair_shine silver silver_light;burlap_dark burlap burlap_light burlap_hi burlap_rust oxblood_deep oxblood_dark oxblood oxblood_light oxblood_pale navy bottle tar rust ochre mustard;leaf_black leaf_deep leaf leaf_olive leaf_moss leaf_maroon leaf_rust leaf_orange;ghost_dark ghost ghost_light ghost_white glow glow_core glow_ring ember)或 '#rrggbb';色阶用 `RAMPS` 里的名字(night porcelain hair silver burlap oxblood leaf leaf_olive leaf_maroon leaf_rust ghost glow,都是暗 → 亮)或自己给一串颜色。+- 范例的场景脚本先把所有形状的遮罩算好(`plan()`),再按从前往后的遮挡算出每块「看得见的部分」(手套和袖口 > 罐子和盖布 > 袖子 > 围巾 > 外套;帽子 > 刘海 > 远侧那片头发 > 脸 > 后面的头发),每一层只往自己看得见的部分上画;留着的画布大小的遮罩一赋值就转成 float16。+**顺序**:都是先远后近、先大后小,文字最后叠加。水墨的雾要画在它该吞没的东西之后;水彩的叶梗要先画,并且只画在叶子外面。## 三、毛病清单(都真实出现过)@@ -2568,6 +2596,24 @@ from core import spline, curve, blob_pts, fbm1d, blur, polygon_mask| 第二枝桉树枝和主枝交叉成一个 X;叶子排成一架梯子 | 去掉第二枝;叶子沿枝条的位置随机错开 ±0.3 个间距,角度的随机偏差 8° → 14°,大小 56–108 px || 峰值内存 0.92 GB | 光栅化的子像素数组从 int64 / float64 改成 int32 / float32,一批笔的包围盒超过 250 万个子像素就按 y 分带;8 个方向的纸纹存成 uint8(66 MB → 17 MB);`contour()` 只在形状附近算;场景里留着的 37 张画布大小的遮罩和受光场一赋值就转成 float16:0.74–0.77 GB;和改之前的成品比,p99 差 0 级,只有猫头附近 1141 个像素差 10 级以上,看不出来 |+**诗意万圣夜**++| 问题 | 改法 |+|---|---|+| 小幽灵的光把整片树丛照成亮绿和亮橙,夜晚成了下午,「只有一处发光」也没了;树丛上沿多出一条半透明的亮带 | 点光源的衰减从 1/(1+(d/r)²)^1.2 改成 ^2,小幽灵的光半径从 2.2 倍身宽降到 1.15 倍,`illuminate()` 的 base 0.3 → 0.15;接受度用模糊过的树丛遮罩,不用硬边 |+| 叶子是一颗颗海星:裂片又细又尖、都正对着看,每片沿中脉一半亮一半暗,树丛平得像剪贴画 | 裂片加宽、缺刻变浅(到半径的 0.42–0.56),加重锯齿;每片随机压扁到 0.55–1 倍(侧着看),对折的明暗差 0.22 → 0.16;每片先往右下投一块软影子(偏移约 0.1 个叶长、模糊 0.06 个叶长),叶丛才有前后 |+| 红晕像一片疹子:眼睛下面两块粗的红斑点 | 斑点改用单像素的细点子纹 `ST`,平滑的一层红占大头;红晕的场改成一条绕着眼睛(下半圈更浓)、跨过鼻梁的带子,脸颊上另铺一层很淡、几乎只有斑点的红 |+| 鼻子只是一个红点 | `nose()` 把鼻子当成一个小体积:沿鼻梁的管子加圆鼻尖,按光塑形,背光一侧一块紫灰(0.55),鼻尖往下投影,越往下越红 |+| 脸是一张平的白面具 | 塑形的穹顶光尺度 44 → 84,光从更左边来、色阶最低取到 0;四周一圈软的紫灰、眼窝一点灰、近侧脸颊下面一点影子、两颊一层很淡的暖粉;脸的下半截缩短、下巴变圆 |+| 脖子是一块白色的长方块 | 围巾围到下巴,脖子藏起来 |+| 帽子三次都不对:尖顶巫师帽像精灵帽;顶上加一截软管当耷拉的帽尖,像犀牛角、像茶壶把 | 改成一顶软塌的粗麻钟形帽:低圆顶、往下翻的短帽檐(织纹沿帽檐的弧线走)、帽檐边垂下松开的麻线、一圈麻绳打个小蝴蝶结 |+| 粗麻上一根根贯穿的锈色线像缝线、像格子 | `burlap(rust=…)` 默认 0 |+| 远侧那片头发像一只耳机;刘海是一条黑色的护目镜 | 整块头发按同一张受光揉色阶;那片头发的暗边只留在挨着脸的内侧(乘一张脸附近的遮罩);刘海上半部单独一条光泽带,再加一层对比度低的细发丝 |+| 捧在一起的手套像一只螃蟹、两个面包;换成玻璃罐后,手套把罐子整个挡住 | 手套小一点、从两边扶着罐子下半截,拇指搭在前面;罐子加大到宽 148、高 204 px |+| 围巾和手套的红比小幽灵的光还抢眼 | 毛线色阶的上限 0.85 → 0.68–0.7,围巾的受光接受度 0.8 → 0.45 |+| 袖子在下角多出一圈发白的轮廓 | 袖子顶上那道亮只留在前臂(乘两块前臂附近的软斑) |+| 峰值内存 1.07 GB | 整张的 `wash()` 按行分带算;方向场传函数时只在用到的点上求值;`soften()` 只在形状附近模糊(场景里和库里的遮罩模糊都换成它);render 按行分带;印刷颗粒在 `ground()` 里先算好;光栅化每带 80 万子像素:0.71–0.81 GB,耗时也从 12.4 秒降到约 10 秒 |+## 四、做成动画- 各画风都有 `stage(name)` 和 `save(path, stages_dir)`,按阶段依次淡入叠化,就是「一幅画被逐步画出来」。README 里的动图就是这样做的。@@ -2661,6 +2707,12 @@ from core import spline, curve, blob_pts, fbm1d, blur, polygon_mask- 调色板:第一帧是空白纸,只给 12 色;228 色只从和空白纸不同的像素里切(末帧 ×3、饱和色 ×3——橘猫、腮红、琥珀色的眼睛、赭黄的叶子,暗色 ×2——头发、瞳孔、眼线,浅粉蓝 ×1.5,大衣的软笔触才不出色带);再留 15 色,其中 3 个是强制的(最深的头发 / 瞳孔、纸白、猫的橘色),另外 12 色只从末帧误差超过 14 级的像素里切;最后 1 色是纯品红,当「和上一帧相同」的透明占位色。- 固定 4×4 Bayer(约 ±2.4 级),末帧不加抖动、精确发送(差 0.5 级以上就重发)。和屏上已显示颜色差不到 5 级(叠化帧)或 3 级(关键帧)的像素沿用上一帧;整帧都没变的叠化帧不单独发,时长并到上一帧。- 结果:40 帧,13.40 秒,约 0.54 MB,按解码结果逐帧自检(和应显示的画面最大差 0),末帧误差中位数 0、p99 14。四周大片是白纸,所以比满画面的画风小得多。+- 诗意万圣夜的动图(脚本在 `workspace_projects/arte3/work/make_gif_poetichalloween.py`):+ - 阶段:暗色画板 → 粉笔起稿(脸、波波头、帽子、外套、罐子、手套、小幽灵和树丛的轮廓)→ 夜空和星星 → 深色叶丛(给人物留着空)→ 平涂大块 → 极简的体积(瓷白的脸、整块的波波头和光泽、外套的底色、毛线和帽子的塑形)→ 织物(粗麻、格子呢、针织、罗纹、毛边)→ 五官(红晕、眼睛、鼻子、嘴)→ 小幽灵出来、暖光照亮叶子和脸 → 成品(前景叶子、刘海发梢、帽檐的麻线)。每段 900 毫秒加 5 帧叠化,末帧停 2600 毫秒。+ - 叠化一片片铺上去,和色粉小像的做法一样。+ - 调色板:暗底容易出色带,所以给暗色多留位置:第一帧是空的暗画板,只给 8 色;200 色从和它不同的像素里切(末帧 ×3、饱和色 ×3——琥珀色的光、红晕、深红毛线、锈色叶子,暗色 ×2——夜空、叶丛、头发、外套,暗的暖棕 ×4——粗麻帽子和盖布:面积小,不加的话它的棕色被叶子的橄榄绿抢走,帽子在动图里变成橄榄灰);再单独从暗像素里切 24 色;4 色强制(最深的头发、奶白的光芯、琥珀色的光、瓷白的脸);剩下 19 色只从末帧误差超过 12 级的像素里切;最后 1 色是纯品红,当「和上一帧相同」的透明占位色。+ - 固定 4×4 Bayer(约 ±2.4 级),末帧不加抖动、精确发送(差 0.5 级以上就重发)。和屏上已显示颜色差不到 5 级(叠化帧)或 3 级(关键帧)的像素沿用上一帧;整帧都没变的叠化帧不单独发,时长并到上一帧。+ - 结果:46 帧,14.75 秒,约 1.21 MB,按解码结果逐帧自检(和应显示的画面最大差 0),末帧误差中位数 1、p99 19,夜空看不出色带。- 绘本角色动画的动图是真动画,不是阶段叠化:`Storybook.gif()` 按时间逐帧渲染,720×405、15 fps(GIF 延时只能写厘秒,按累计取整写成 7、7、6 厘秒交替),共用一张加权调色板 + 固定 4×4 Bayer,没变的像素记成品红透明,151 帧(动作 9.95 秒 + 末帧停 1.4 秒)约 0.56 MB;范例加 `--gif out.gif` 出这张,`--stages` 的关键帧仍可喂给上面的阶段动图工具。- 形变动画可以直接出真动画:`Morph.at(keys, T)` 给出全局时间 T 的轮廓,逐帧渲染即可。- 更细的逐笔动画:把一组笔画单独画到透明层上导出,再用 Motion Canvas 遮罩按顺序显现。这个还没做成现成接口。@@ -2745,6 +2797,7 @@ lib/flexoki.py Flexoki 纸面(Flexoki 色板与角色名、浅色 /lib/pencilbook.py 暖调彩铅绘本(以 1 px 细颗粒为主的直方图均衡纸纹与沿 8 个方向拖开的纸纹,纸坑里留的一点蜡和越叠越深的蜡层缓冲;在方向场里积分出中心线、带手腕弧度的铅笔笔触;id 图光栅化:Pillow 按序号画折线、2 倍超采样,numpy 只对被盖住的子像素查回这一笔,算出沿笔位置和压力曲线,蜡只落在压力够得着的纸纹上,bincount 汇回像素;抖动网格落笔、逐像素压力的平滑过渡、留白(avoid);半透明的蜡混色与压光;软穹顶受光和照彩铅画家顺序的分层塑形:浅色底、固有色、同色系暗部、最深处、暖色和冷色罩染、交叉角度;漂移、等值线、放射方向场与双倍角混合;根部散开尖端聚拢、有亮面暗面的毛绺,整张毛皮,散开的草丛,树冠的叶簇;顺着表面的暖色发光笔触与带纸纹的提亮,亮灯的窗,提亮;镜像取样的横排线倒影、断开的涟漪圈;分别打光的团块树冠、小房子、石头、鳞片、野花、纸灯笼、雨衣小孩、点点眼和腮红;很淡的同色轮廓、几笔叠成的软线;轻微柔化、细颗粒、暖色暗角)lib/colortown.py 彩色小镇(id 图光栅化的不透明色块:Pillow 按序号填多边形、2 倍超采样,numpy 查颜色 / 不透明度 / 纹理权重表、box 平均回像素;整张预算的竖向、横向笔刷条纹和擦笔纹理加低频斑驳,按块取权重,浅色少一点;边缘重采样后沿法线抖动;深棕半透明墨线:3 倍 id 图、带圆角接头的折线,分段变粗细,方框四边分开画、转角偶尔出头,按底色乘出深红棕或近黑;远近雾化与细线;把平摊布局贴到四边形上的透视单应;联排房子生成器:灰泥墙、裸石斑块、腰线、檐口、墙脚罩染和檐下阴影,门、带字招牌和条纹遮阳篷的店面、拱门,每扇略不同的窗(窗框、带反光的玻璃、窗棂、窗台、带横条的百叶窗、窗帘、圆窗和拱窗),溢出来的窗台花箱,铁艺阳台和花盆;一片片错缝铺、裁切、描缝的石板和赤陶瓦,曼莎、四坡、侧山墙、尖山墙,老虎窗、烟囱和烟囱帽、电视天线、风向标;带隅石、钟面、木百叶钟楼开口、洋葱顶、灯笼亭、尖顶和旗的钟楼;越往上越小的台阶、石墙、铁栏杆;杯形花瓣的爬藤玫瑰,按穹顶打光的叶簇树冠,花盆;抛物线下垂、带折痕的三角彩旗串;路灯和壁灯、吊挂店招、海报、咖啡桌、猫、不画脸的小人(伞、气球、花篮);透视石板、逐列镜像并竖向拖尾的湿街倒影、重描的石板缝和反光,把之后画的东西也倒映下来的 mirror;轻微柔化、细颗粒、暖色、淡暗角)lib/pastelvignette.py 色粉小像(直方图均衡的白纸纸纹与存成 uint8、沿 8 个方向拖开的纸纹,颜料缓冲;按段编号的 id 图光栅化:Pillow 把每一笔的每一段按序号画进 2 倍超采样的整数 id 图,numpy 查回这一段,算出沿笔压力曲线(两头收圆)、两侧软边和越干越开的鬃毛条纹,色粉只挂在压力够得着的纸纹上,bincount 汇回像素,大批按 y 分带;近乎不透明的色粉混色;揉开的平滑色层(按场取色、纸坑留浅、边缘按纸纹断开)和按软穹顶光取色阶的塑形;干边与不长孤岛的游走边、按渐隐场逐像素减压变干的散开;漂移、函数、放射、等值线(只在形状附近算)方向场与双倍角混合;按流向场积分、成绺(共用起点、偏移、弯曲和明暗)、暗先亮后的发丝和飞丝;根散尖聚、背光侧暗的毛簇;从轮廓里侧取色往外长的蓬松边;带灰蓝眼皮影、放射纹虹膜、外眼角挑出眼线和双高光的大圆眼,色粉带加细毛的眉毛,粉状大腮红,鼻梁软影加红鼻尖,小嘴;平滑的细圆笔线、几笔叠成的淡铅笔线;受光一侧浅、带浅色叶脉的叶子和带叶的枝条;轻微柔化、细颗粒、只上在颜色上的一点暖色)+lib/poetichalloween.py 诗意万圣夜(直方图均衡的暗色画板纸纹与存成 uint8、沿 8 个方向拖开的纸纹,单像素细点子纹,颜料缓冲;和色粉小像同一套按段编号的 id 图光栅化,按 y 分带;取画布颜色「再画一遍」的笔触,以白为参照的乘法混色;按行分带的平滑色层和按软穹顶光取色阶的塑形,只在形状附近做的模糊;整块头发的窄带光泽和顺发流拉开的淡笔触、成绺的低对比发丝;重眼皮杏仁眼(眼皮盖住半个虹膜、外眼角下垂、湿红的下眼睑、虹膜里映出的暖光),平滑加单像素斑点的红晕和软斑、软环场,自成体积的长鼻子和红鼻尖,不笑的小嘴;粗麻平纹(各自粗细、有疙瘩、游走、一上一下交织的线,高度场打光,黑孔、纤维、毛边,可顺弧线织)、粗针织 V 形针脚与罗纹、镜像 sett 的 2/2 斜纹格子呢、从轮廓长出的纤维、顺管子弯的坐标;宽裂片重锯齿的掌状叶(压扁、对折、叶脉、投影)和从后往前的叶丛;陡衰减的暖色点光源、按接受度照亮已画好的东西、发光缓冲;银色细丝的半透明床单小幽灵(发光的眼睛、每绺末端的光珠);星星;柔化、三档光晕、印刷颗粒和暗部更显的粗纸纹、提亮的黑,按行分带算)examples/*.py 范例脚本;*.jpg 成品;drawing_*.gif 逐步画出的动图中文字体:自动找 Kaiti/Songti(macOS)、Noto CJK(Linux)、KaiTi/SimSun(Windows),或设 INKPAINT_FONT西文字体(后来新增的画风用):core.latin_font(style) 按 sans / sans_bold / rounded / script / hand / typewriter 等找系统字体,可用 INKPAINT_FONT_<STYLE> 指定;字体文件不要放进仓库diff --git a/examples/drawing_poetichalloween_ghost_jar.gif b/examples/drawing_poetichalloween_ghost_jar.gifnew file mode 100644index 0000000..ec5e42bBinary files /dev/null and b/examples/drawing_poetichalloween_ghost_jar.gif differdiff --git a/examples/poetichalloween_ghost_jar.jpg b/examples/poetichalloween_ghost_jar.jpgnew file mode 100644index 0000000..10826faBinary files /dev/null and b/examples/poetichalloween_ghost_jar.jpg differdiff --git a/examples/poetichalloween_ghost_jar.py b/examples/poetichalloween_ghost_jar.pynew file mode 100644index 0000000..dfd5041--- /dev/null+++ b/examples/poetichalloween_ghost_jar.py@@ -0,0 +1,515 @@+"""Example (poetic halloween): 罐子里的小幽灵 · The Ghost in the Jar -- a melancholic, surreal picture-book portrait+for an autumn night.++The last night of October. A pale child with a blunt jet-black bob and a dead-straight fringe, under a slouchy+burlap cloche with a frayed brim and a twine band, stands in a dark hedge of leaves. In her oxblood mittens she+holds a glass jar tied with a burlap cover; inside it a tiny sheet-ghost glows, and she looks down at it with heavy,+half-closed eyes that mirror its light. Its glow warms the wool, the glass and the underside of her face. More little+ghosts peer out of the hedge and float in the starry indigo sky, watching. Porcelain skin flushed red round the eyes,+on the nose and the cheeks; a chunky knit scarf up to the chin, a dark tartan coat with two horn buttons, a fine+printed grain over everything.++Painted in the order an illustrator works on a dark board: the board -> a chalk underdrawing -> the night sky and+stars -> the dark hedge -> flat colour -> simplified volumes (the porcelain face, the sculpted bob and its sheen) ->+the textiles (burlap, tartan, knit) -> the face (eyes, flush, nose, mouth) -> the jar and the ghosts, whose light+then warms everything near them -> the leaves in front, loose fibres and the last touches. --stages writes those+steps as snapshots for the draw-on. No image model.+python3 poetichalloween_ghost_jar.py [out.jpg] [--stages DIR]+"""+import os, sys, time+sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'lib'))+import numpy as np+from core import blur, smoothstep, noise2d+from poetichalloween import PoeticHalloween++W, H = 1920, 1080+HC = np.array([880.0, 500.0]) # centre of her face (between the eyes)+TILT_D = -5.0 # head tilted toward her right shoulder, looking down+TILT = np.deg2rad(TILT_D)+CS, SN = np.cos(TILT), np.sin(TILT)+JAR = dict(cx=884.0, top=726.0, bot=930.0, neck=56.0, half=74.0)+GHOST = dict(cx=884.0, top=782.0, w=96.0, h=118.0) # the one in the jar+OTHERS = [dict(cx=1490.0, top=318.0, w=122.0, h=168.0, look=(-1.0, 0.2), lean=4.0),+ dict(cx=1716.0, top=176.0, w=78.0, h=108.0, look=(-0.8, 0.4), lean=-3.0),+ dict(cx=1296.0, top=566.0, w=92.0, h=126.0, look=(-1.0, -0.2), lean=0.0),+ dict(cx=326.0, top=366.0, w=96.0, h=132.0, look=(1.0, 0.3), lean=-4.0),+ dict(cx=118.0, top=616.0, w=72.0, h=98.0, look=(1.0, 0.0), lean=3.0)]+++def F(u, v):+ """face-local (u right, v down, before the tilt) -> canvas"""+ return (HC[0] + u * CS - v * SN, HC[1] + u * SN + v * CS)+++def FL(pts):+ return [F(u, v) for u, v in pts]+++def to_local(x, y):+ dx, dy = x - HC[0], y - HC[1]+ return dx * CS + dy * SN, -dx * SN + dy * CS+++class Scene:+ def __init__(self, p):+ self.p = p+ self.plan()++ def __setattr__(self, k, v):+ # some forty canvas-sized masks and light fields are kept: float16 is plenty for 0..1 coverage and halves+ # them, which keeps the peak well under 1 GB+ if isinstance(v, np.ndarray) and v.dtype == np.float32 and v.shape == (H, W):+ v = v.astype(np.float16)+ object.__setattr__(self, k, v)++ # ------------------------------------------------------------------ shapes, planned before any paint+ def plan(self):+ p = self.p+ # the face: a child's soft oval turned a little to the viewer's left (features shifted, chin off-centre)+ self.face_pts = [(-106, -140), (-116, -80), (-120, -20), (-117, 34), (-106, 80), (-86, 116), (-56, 141),+ (-20, 152), (18, 149), (56, 134), (92, 104), (116, 60), (128, 4), (129, -70), (120, -140)]+ self.face = p.poly(FL(self.face_pts), smooth=True)+ # the bob: one solid mass from under the hat to a blunt cut at the jaw; the far-side curtain falls in+ # front of the far cheek, the near side shows behind the near cheek+ self.bob = p.poly(FL([(-176, -150), (-186, -70), (-190, 0), (-184, 64), (-172, 108), (-158, 134),+ (-126, 142), (-96, 138), (-60, 156), (60, 160), (110, 152), (150, 154), (178, 140),+ (192, 90), (198, 20), (196, -60), (188, -150)]), smooth=True)+ self.curtain_l = p.poly(FL([(-160, -60), (-186, -40), (-190, 0), (-184, 64), (-172, 108), (-158, 134),+ (-126, 142), (-96, 138), (-86, 120), (-96, 86), (-106, 40), (-110, 0),+ (-112, -36), (-140, -48)]), smooth=True)+ # the fringe: dead straight across, just above the eyes+ self.fringe = p.poly(FL([(-172, -160), (178, -160), (188, -100), (172, -36), (-124, -36), (-176, -80)]))+ # the hat: a slouchy burlap cloche pulled down to the fringe -- a soft lopsided crown, a short brim that+ # turns down and frays at its edge, a twine band+ self.brim_pts = [(-216, -80), (-202, -110), (-150, -126), (-60, -134), (40, -134), (140, -126), (204, -110),+ (226, -78), (212, -68), (150, -82), (60, -90), (-40, -90), (-140, -82), (-202, -68)]+ self.brim = p.poly(FL(self.brim_pts), smooth=True)+ self.brim_path = FL([(-206, -88), (-150, -104), (-50, -112), (50, -112), (150, -104), (214, -88)])+ self.crown_pts = [(-172, -112), (-178, -164), (-166, -216), (-134, -258), (-84, -284), (-24, -290),+ (30, -284), (86, -270), (132, -244), (162, -204), (176, -158), (178, -112)]+ self.crown = p.poly(FL(self.crown_pts), smooth=True)+ self.band_path = FL([(-176, -128), (-120, -138), (-40, -142), (40, -142), (120, -138), (178, -128)])+ self.hat = np.clip(self.brim + self.crown, 0, 1)+ # the coat: a child's narrow shoulders, two sleeves that bend in to the jar+ coat = p.poly([(784, 700), (706, 718), (634, 752), (594, 808), (572, 900), (562, 1080), (1200, 1080),+ (1190, 900), (1168, 808), (1128, 752), (1056, 718), (978, 700)])+ sw = [136, 140, 132, 112, 92]+ self.sleeves = np.clip(p.tube([(606, 808), (612, 914), (660, 976), (730, 966), (788, 942)], sw) ++ p.tube([(1160, 808), (1154, 914), (1108, 976), (1038, 966), (980, 942)], sw), 0, 1)+ self.coat = np.clip(coat + self.sleeves, 0, 1)+ # the scarf: a thick roll up to the chin, one end hanging down the front+ self.scarf_path = [(744, 676), (806, 706), (880, 718), (956, 706), (1018, 676)]+ self.scarf_roll = p.tube(self.scarf_path, [70, 80, 86, 80, 70])+ self.end_path = [(808, 712), (792, 790), (778, 870), (772, 940)]+ self.scarf_end = p.tube(self.end_path, [80, 78, 76, 74])+ self.scarf = np.clip(self.scarf_roll + self.scarf_end, 0, 1)+ # the jar: a neck, round shoulders, a straight body; a burlap cover tied over its mouth+ j = JAR+ cx, t, b, nk, hf = j['cx'], j['top'], j['bot'], j['neck'], j['half']+ self.jar = p.poly([(cx - nk, t + 2), (cx + nk, t + 2), (cx + nk + 2, t + 20), (cx + hf - 4, t + 34),+ (cx + hf, t + 50), (cx + hf, b - 18), (cx + hf - 8, b - 4), (cx, b), (cx - hf + 8, b - 4),+ (cx - hf, b - 18), (cx - hf, t + 50), (cx - hf + 4, t + 34), (cx - nk - 2, t + 20)],+ smooth=True)+ r = np.random.default_rng(3)+ hem = [(cx + 62 - k * 124 / 10, t + 28 + (6 if k % 2 else 0) + r.uniform(-3, 3)) for k in range(11)]+ self.cover = p.poly([(cx - 62, t + 22), (cx - 58, t - 4), (cx - 34, t - 20), (cx, t - 26), (cx + 34, t - 20),+ (cx + 58, t - 4), (cx + 62, t + 22)] + hem, smooth=False)+ self.cover = p.soften(self.cover, 0.8)+ # mittens holding the jar from the sides, thumbs over the front; ribbed cuffs at the wrists+ self.mitt_l = np.maximum(p.ellipse(816, 884, 34, 50, 12), p.ellipse(840, 852, 11, 21, 35))+ self.mitt_r = np.maximum(p.ellipse(952, 884, 34, 50, -12), p.ellipse(928, 852, 11, 21, -35))+ self.mittens = np.clip(self.mitt_l + self.mitt_r, 0, 1)+ self.cuff_l = p.tube([(804, 926), (784, 948)], 46) * (1 - self.mittens)+ self.cuff_r = p.tube([(964, 926), (984, 948)], 46) * (1 - self.mittens)+ self.cuffs = np.clip(self.cuff_l + self.cuff_r, 0, 1)+ # the hedge behind her+ self.hedge_line = ([0, 160, 330, 470, 600, 760, 1000, 1180, 1300, 1450, 1620, 1780, 1920],+ [520, 470, 500, 560, 610, 640, 650, 600, 520, 470, 430, 452, 470])+ self.hedge = p.below(*self.hedge_line)+ # visible parts (front to back)+ hands = np.clip(self.mittens + self.cuffs, 0, 1)+ self.v_hands = hands+ self.v_jar = self.jar * (1 - hands)+ self.v_cover = self.cover * (1 - hands)+ jar_all = np.clip(self.jar + self.cover, 0, 1)+ self.v_sleeves = self.sleeves * (1 - hands)+ self.v_scarf = self.scarf * (1 - hands) * (1 - self.sleeves) * (1 - jar_all)+ self.v_coat = self.coat * (1 - self.scarf) * (1 - hands) * (1 - self.sleeves) * (1 - jar_all)+ self.v_fringe = self.fringe * (1 - self.hat)+ self.v_face = self.face * (1 - self.fringe) * (1 - self.curtain_l) * (1 - self.hat) * (1 - self.scarf)+ self.v_curtain = self.curtain_l * (1 - self.hat) * (1 - self.fringe) * (1 - self.scarf)+ self.v_bob = self.bob * (1 - self.face) * (1 - self.hat) * (1 - self.fringe) * (1 - self.curtain_l) * \+ (1 - self.scarf) * (1 - self.coat)+ self.hair = np.clip(self.v_bob + self.v_curtain + self.v_fringe, 0, 1)+ self.figure = np.clip(self.hat + self.bob + self.face + self.coat + self.scarf + hands + jar_all, 0, 1)++ # ------------------------------------------------------------------ hair flow (degrees)+ def hair_flow(self, x, y):+ x = np.asarray(x, np.float32); y = np.asarray(y, np.float32)+ u, v = to_local(x, y)+ turn = 22 * smoothstep(70, 150, v) * np.where(u < 0, -1, 1) # ends turned under, toward the neck+ fringe = (v > -160) & (v < -30) & (np.abs(u) < 172)+ a = np.where(fringe, 90.0, 90 + turn + 6 * np.clip(u / 180, -1, 1))+ return a + TILT_D++ # ------------------------------------------------------------------ 1. chalk underdrawing+ def sketch(self):+ p = self.p+ r = np.random.default_rng(5)+ sk = lambda pts, a=0.42, w=2.0, **kw: p.sketch(pts, 'chalk', w, a, seed=int(r.integers(1 << 30)), **kw)+ sk(FL(self.face_pts[1:-1]))+ sk(FL([(-176, -150), (-190, 0), (-172, 108), (-126, 142), (-86, 112)]))+ sk(FL([(188, -150), (198, 20), (178, 140), (110, 152)]))+ sk(FL([(-124, -36), (172, -36)]), smooth=False)+ sk(FL(self.brim_pts[:8]))+ sk(FL(self.crown_pts))+ sk(FL([(-54 - 32, 6), (-54 + 32, 2)]), 0.28, smooth=False)+ sk(FL([(46 - 36, 4), (46 + 36, 0)]), 0.28, smooth=False)+ sk(FL([(-4, -4), (-8, 28), (-14, 54), (-22, 76)]), 0.25)+ sk([(634, 752), (594, 808), (572, 900), (562, 1080)]); sk([(1128, 752), (1168, 808), (1190, 900), (1200, 1080)])+ sk(self.scarf_path, 0.28); sk([(788, 942), (660, 976), (612, 914)]); sk([(980, 942), (1108, 976), (1154, 914)])+ j = JAR+ sk([(j['cx'] - j['neck'], j['top']), (j['cx'] - j['half'], j['top'] + 50), (j['cx'] - j['half'], j['bot'] - 18),+ (j['cx'], j['bot']), (j['cx'] + j['half'], j['bot'] - 18), (j['cx'] + j['half'], j['top'] + 50),+ (j['cx'] + j['neck'], j['top'])], 0.3)+ for (cx, cy, rx, ry, rot) in ((816, 884, 34, 50, 12), (952, 884, 34, 50, -12)):+ t = np.linspace(0, 2 * np.pi, 30)+ c, s = np.cos(np.deg2rad(rot)), np.sin(np.deg2rad(rot))+ sk([(cx + rx * np.cos(a) * c - ry * np.sin(a) * s, cy + rx * np.cos(a) * s + ry * np.sin(a) * c)+ for a in t], 0.25)+ for g in [GHOST] + OTHERS:+ cx, top, w, h = g['cx'], g['top'], g['w'], g['h']+ R = w / 2+ t = np.linspace(np.pi, 2 * np.pi, 14)+ sk([(cx - R * 1.08, top + h * 0.95)] + [(cx + R * np.cos(a), top + R + R * np.sin(a)) for a in t] ++ [(cx + R * 1.08, top + h * 0.95)], 0.22, 1.3)+ xs, ys = self.hedge_line+ sk(list(zip(xs[:5], ys[:5])), 0.18); sk(list(zip(xs[7:], ys[7:])), 0.18)++ # ------------------------------------------------------------------ 2. night sky+ def sky(self):+ p = self.p+ val = p.value(0.15, 0.85, 0, 760, mottle=0.06, scale=260, seed=21)+ p.wash(p.rect(0, 0, W, H), ('night', val), 1.0, grain=0.3, edge=0)+ # a faint haze low over the hedge on the right, a hint of violet on the left+ p.glaze(p.spot(1500, 380, 700, 260, solid=0.0), 'haze', 0.22, 'screen')+ p.glaze(p.spot(300, 360, 520, 220, solid=0.0), 'dusk', 0.18, 'screen')+ # the painterly hand: fine diagonal strokes over the whole sky, colours from the sky under them+ fl = p.flow(-14, 8, 300, seed=22)+ p.strokes(p.rect(0, 0, W, 760), fl, 'canvas', (50, 120), (2.5, 4.5), 1.1, pressure=0.7, alpha=0.55,+ value=0.07, hue=0.03, streak=0.4, soft=0.6, seed=23)+ p.strokes(p.rect(0, 0, W, 760), fl, ('night', val * 1.1 + 0.05), (30, 80), (1.5, 2.5), 0.5, pressure=0.6,+ alpha=0.3, value=0.1, seed=24)+ keep = 1 - p.soften(self.figure, 12)+ p.stars(p.rect(0, 0, W, 560) * keep * smoothstep(620, 360, p.YY), 260, (0.5, 1.4), bright=0.07, seed=25)+ # a thin drift of small stars across the upper right+ band = np.exp(-((p.YY - (40 + 0.26 * (p.XX - 1000))) / 70.0) ** 2) * (p.XX > 1050)+ p.stars(band * keep, 220, (0.4, 0.9), bright=0.02, seed=26)++ # ------------------------------------------------------------------ 3. the dark hedge+ def hedge_leaves(self):+ p = self.p+ hm = self.hedge+ p.wash(hm, ('leaf', p.value(0.25, 0.05, 420, 1080, seed=31)), 1.0, grain=0.3, edge=0.6)+ reg = blur(hm, 18) * (1 - 0.92 * p.soften(self.figure, 4))+ greens = ('leaf', 'leaf', 'leaf_olive', 'leaf')+ p.foliage(reg, 270, (70, 130), greens, (0.04, 0.3), veins=0.28, seed=32)+ p.foliage(reg, 240, (80, 140), greens + greens + ('leaf_maroon', 'leaf_rust'), (0.08, 0.42), veins=0.32,+ seed=33)+ # the leaves along the top edge of the hedge, against the sky+ xs, ys = self.hedge_line+ yl = np.interp(np.arange(W, dtype=np.float32), xs, ys)+ top = smoothstep(60, 0, np.abs(p.YY - yl[None])) * (1 - p.soften(self.figure, 6))+ p.foliage(top, 90, (70, 120), greens, (0.14, 0.45), veins=0.32, seed=34)+ # a painterly pass: short strokes in the colour under them+ p.strokes(hm * (1 - self.figure), p.flow(60, 60, 90, seed=35), 'canvas', (16, 36), (2.0, 3.5), 0.6,+ pressure=0.66, alpha=0.4, value=0.1, hue=0.04, seed=36)++ # ------------------------------------------------------------------ 4. flat colour+ def block(self):+ p = self.p+ p.wash(self.v_coat + self.v_sleeves, 'navy', 1.0, grain=0.3, edge=0.3)+ p.wash(self.hair, 'hair_black', 1.0, grain=0.15, edge=0.3)+ p.wash(self.v_face, 'porcelain', 1.0, grain=0.15, edge=0.3)+ p.wash(self.v_scarf, 'oxblood', 1.0, grain=0.25, edge=0.5)+ p.wash(self.v_hands, 'oxblood', 1.0, grain=0.25, edge=0.5)+ p.wash(self.v_jar, '#1d2a33', 0.55, grain=0.2, edge=0.3)+ p.wash(self.v_cover, 'burlap', 1.0, grain=0.3, edge=0.6)+ p.wash(self.hat, 'burlap_dark', 1.0, grain=0.3, edge=0.6)++ # ------------------------------------------------------------------ 5. simplified volumes+ def model(self):+ p = self.p+ # porcelain face: a soft dome, cool grey-mauve on the shadow side, the fringe's shadow on the brow+ face_r = ('#9c8790', '#bca9ae', '#d8cac8', '#ece2dd', '#f8f2ee')+ self.face_lit = p.model(self.v_face, face_r, light=(-0.8, -0.4, 0.45), sigma=84, lo=0.0, hi=1.0,+ gamma=0.9, grain=0.12, edge=0.3, mottle=0.04)+ p.glaze(np.maximum(p.spot(*F(60, 58), 84, 60, TILT_D, solid=0.0), p.spot(*F(-78, 54), 48, 54, TILT_D, solid=0.0))+ * self.v_face, '#f0c9bd', 0.35, 'multiply')+ p.glaze(p.soften(self.fringe, 10) * self.v_face, '#b39fa8', 0.5, 'multiply')+ rim = (1 - smoothstep(0.35, 0.95, p.soften(self.face, 16))) * self.v_face+ p.glaze(rim, '#c2adb5', 0.6, 'multiply')+ sockets = np.maximum(p.spot(*F(-54, -6), 52, 32, TILT_D, solid=0.1), p.spot(*F(46, -8), 58, 34, TILT_D, solid=0.1))+ p.glaze(sockets * self.v_face, '#cbb6bd', 0.5, 'multiply')+ p.glaze(p.spot(*F(78, 66), 52, 46, TILT_D, solid=0.0) * self.v_face, '#d0bfc4', 0.35, 'multiply')+ p.glaze(p.spot(*F(-20, 132), 34, 14, TILT_D, solid=0.0) * self.v_face, '#bfa8b1', 0.4, 'multiply')+ p.glaze(p.spot(*F(-70, 40), 40, 30, TILT_D, solid=0.0) * self.v_face, '#ffffff', 0.25, 'screen')+ p.glaze(p.soften(self.scarf, 9) * self.v_face * (1 - self.scarf), '#7a6470', 0.5, 'multiply')+ p.strokes(self.v_face, p.contour(self.face, 24, fallback=80), 'canvas', (24, 50), (3, 5), 0.6,+ pressure=0.6, opacity=0.95, alpha=0.35, value=0.03, streak=0.3, clip=self.v_face, seed=41)+ # the bob: one sculpted mass lit as a whole, a sheen band, a whisper of strands+ hm = np.clip(self.bob + self.fringe + self.curtain_l, 0, 1)+ lit = p.shading(hm, sigma=80)+ self.hair_lit = lit+ p.model(self.hair, 'hair', lit=lit, lo=0.0, hi=0.66, grain=0.15, edge=0.3)+ # where the far curtain turns away along the cheek, and the hat's shadow on the hair+ inner = p.soften(self.curtain_l, 7) * (1 - p.soften(self.curtain_l, 7)) * 4 * self.v_curtain * \+ smoothstep(0.02, 0.2, p.soften(self.face, 14))+ p.glaze(inner, '#000000', 0.5, 'normal')+ p.glaze(p.soften(self.hat, 14) * self.hair * (1 - self.hat), '#000000', 0.5, 'normal')+ fld = self.hair_flow+ p.sheen(self.hair, fld, lit, band=(0.5, 0.66, 0.8), colour='hair_sheen', alpha=0.45, strokes=0.25, seed=42)+ # the fringe curves forward under the hat: a soft band of sheen across its upper part+ u_, v_ = to_local(p.XX, p.YY)+ fb = self.v_fringe * smoothstep(-84, -66, v_) * smoothstep(-36, -58, v_)+ p.sheen(self.v_fringe, fld, 0.5 + 0.3 * fb, band=(0.55, 0.8, 0.95), colour='hair_shine', alpha=0.45,+ strokes=0.4, seed=47)+ del u_, v_+ cols = ('jet', 'hair_black', 'hair_dark', 'hair')+ p.strands(np.clip(self.v_bob + self.v_curtain, 0, 1), fld, cols, n=500, length=(60, 160), width=(1.0, 1.6),+ shade=lit, spread=0.25, alpha=0.3, lock=(10, 6), seed=45)+ p.strands(self.v_fringe, fld, ('jet', 'hair_dark', 'hair', 'hair_sheen'), n=320, length=(30, 70),+ width=(0.9, 1.4), shade=0.25 + 0.5 * fb, spread=0.3, alpha=0.4, seed=46)+ # the coat and sleeves: a dark under-colour lit from the upper left (the tartan goes on in the next step)+ self.coat_lit = np.clip(p.shading(self.coat, sigma=80) * (1 - self.sleeves) ++ p.shading(self.sleeves, sigma=30) * self.sleeves, 0, 1)+ p.model(self.v_coat + self.v_sleeves, ('#0b0e19', '#141a2c', '#1d2539', '#2a3349', '#3a4459'),+ lit=self.coat_lit, grain=0.3, edge=0.3)+ # wool: oxblood, rounded+ p.model(self.v_scarf, 'oxblood', sigma=22, lo=0.05, hi=0.68, grain=0.25, edge=0.5)+ p.model(self.mitt_l, 'oxblood', sigma=18, lo=0.05, hi=0.7, grain=0.25, edge=0.5)+ p.model(self.mitt_r * (1 - self.mitt_l), 'oxblood', sigma=18, lo=0.05, hi=0.7, grain=0.25, edge=0.5)+ p.model(self.cuffs, 'oxblood', sigma=10, lo=0.05, hi=0.7, grain=0.25, edge=0.5)+ # burlap hat: a modelled crown, the brim darker underneath, the brim's shadow on the crown; the jar's cover+ hat_r = ('#0d0b0b', '#171312', '#221c19', '#2f2722', '#43372f')+ p.model(self.crown * (1 - self.brim), hat_r, sigma=50, lo=0.08, hi=1.0, grain=0.3, edge=0.5)+ p.model(self.brim, hat_r, sigma=14, lo=0.05, hi=0.85, grain=0.3, edge=0.5)+ p.model(self.v_cover, 'burlap', sigma=14, lo=0.15, hi=1.0, grain=0.3, edge=0.5)++ # ------------------------------------------------------------------ 6. textiles+ def cloth(self):+ p = self.p+ # burlap on the hat (the brim woven along its curve) and on the jar's cover+ p.burlap(self.crown * (1 - self.brim), angle=TILT_D - 3, period=6.4, strength=0.8, seed=51)+ bs, bt = p.along(self.brim_path, self.brim)+ p.burlap(self.brim, coords=(bs, bt), period=6.0, strength=0.8, seed=53)+ del bs, bt+ p.burlap(self.v_cover, angle=4, period=5.0, strength=0.8, seed=54)+ # a soft dent and two creases in the crown, a twine band with a small bow on the side+ for pts in ([(-100, -262), (-40, -270), (10, -266)], [(-130, -170), (-112, -224)], [(96, -180), (118, -236)]):+ p.line(FL(pts), 3.0, '#060505', 0.4, taper=(0.5, 0.5))+ p.line(self.band_path, 4.0, '#9a8060', 0.95, taper=(0.05, 0.05))+ p.line([(x, y + 5) for x, y in self.band_path], 3.4, '#6f5a42', 0.9, taper=(0.05, 0.05))+ bx, by = F(128, -134)+ for sg in (-1, 1):+ p.line([(bx, by), (bx + sg * 16, by - 12), (bx + sg * 26, by - 4), (bx + sg * 14, by + 3), (bx, by)], 3.0,+ '#9a8060', 0.95, taper=(0.2, 0.2))+ p.line([(bx, by), (bx + 4, by + 22), (bx + 2, by + 38)], 2.8, '#87704f', 0.9, taper=(0.1, 0.6))+ p.line([(bx, by), (bx + 12, by + 18), (bx + 16, by + 32)], 2.8, '#87704f', 0.9, taper=(0.1, 0.6))+ # the frayed edge of the brim: loose threads hanging from it+ edge = np.zeros((H, W), np.float32)+ for uu in np.linspace(-200, 210, 240):+ x, y = F(uu, -72 - 12 * (1 - (uu / 215) ** 2))+ edge[int(y) - 1:int(y) + 2, int(x) - 1:int(x) + 2] = 1+ p.strands(self.brim, 90 + TILT_D, ('burlap', 'burlap_light', 'burlap_hi'), n=260, length=(6, 20),+ width=(0.7, 1.2), roots=edge, clip=False, curl=3, jitter=14, alpha=0.75, seed=57)+ del edge+ p.fuzz(self.hat, (5, 16), n=900, width=(0.7, 1.1), out=0.65, alpha=0.6, lift=0.4, curl=20, seed=55)+ p.fuzz(self.v_cover, (3, 9), n=240, width=(0.6, 1.0), out=0.6, alpha=0.6, lift=0.3, curl=20, seed=56)+ # tartan coat: a dark sett with thin rust and ochre lines, checks wobbling with the folds+ sett = [('navy', 14), ('tar', 3), ('bottle', 12), ('tar', 2), ('#6a2c1c', 2), ('tar', 2), ('bottle', 12),+ ('tar', 3), ('#806232', 1)]+ nu = (noise2d(H, W, 140, 3, 61) - 0.5) * 16; nv = (noise2d(H, W, 140, 3, 62) - 0.5) * 16+ U = p.XX + nu; V = p.YY + nv + 0.05 * (p.XX - 880) ** 2 / 40+ p.tartan(self.v_coat, sett, 2.6, coords=(U, V), lit=self.coat_lit, lo=0.28, hi=1.15, seed=63)+ for (sm, ang) in ((self.v_sleeves * (p.XX < 880), -34), (self.v_sleeves * (p.XX >= 880), 34)):+ a = np.deg2rad(ang)+ Us = (p.XX * np.cos(a) + p.YY * np.sin(a)) + nu; Vs = (-p.XX * np.sin(a) + p.YY * np.cos(a)) + nv+ p.tartan(sm, sett, 2.6, coords=(Us, Vs), lit=self.coat_lit, lo=0.22, hi=1.2, seed=64)+ del nu, nv, U, V+ # folds and shadows: the crease inside each elbow, the scarf's and the sleeves' shadow on the coat+ folds = np.maximum.reduce([p.tube([(640, 904), (676, 944), (722, 938)], 16),+ p.tube([(1124, 904), (1090, 944), (1044, 938)], 16)])+ p.glaze(p.soften(folds, 8) * self.coat, '#05060a', 0.5, 'normal')+ p.glaze(p.soften(np.roll(self.scarf, 18, axis=0), 14) * self.v_coat, '#05060a', 0.45, 'normal')+ # the arms in front of the body: the coat darkens round them, each sleeve darkens at its edges and catches+ # a little light along its top+ edge = p.soften(self.sleeves, 13)+ p.glaze(np.clip(edge * 2.2, 0, 1) * (1 - self.sleeves) * self.v_coat, '#04050a', 0.62, 'normal')+ p.glaze((1 - smoothstep(0.55, 0.97, p.soften(self.sleeves, 7))) * self.v_sleeves, '#04050a', 0.5, 'normal')+ top = self.v_sleeves * (1 - smoothstep(0.0, 1.0, np.clip(np.roll(p.soften(self.sleeves, 6), -16, axis=0), 0, 1)))+ forearms = np.maximum(p.spot(724, 948, 90, 50, solid=0.4), p.spot(1044, 948, 90, 50, solid=0.4))+ p.glaze(top * forearms, '#6c7894', 0.45, 'screen')+ # the coat's front edge and two horn buttons below the jar+ p.line([(904, 940), (910, 1000), (914, 1080)], 3.0, '#05060a', 0.7, taper=(0.1, 0.1))+ p.glaze(p.soften(p.tube([(916, 940), (922, 1080)], 10), 4) * self.v_coat, '#05060a', 0.35, 'normal')+ for (bx, by) in ((928, 978), (932, 1042)):+ p.dab(bx + 1, by + 4, 17, '#05050a', 0.5, soft=0.8)+ p.dab(bx, by, 15, '#3a281f', 1.0, soft=0.2)+ p.dab(bx - 1, by - 1, 11, '#58402f', 0.9, soft=0.5)+ p.dab(bx - 6, by - 6, 3.2, '#c0a185', 0.8, soft=0.4)+ for dx, dy in ((-4, -4), (4, -4), (-4, 4), (4, 4)):+ p.dab(bx + dx, by + dy, 1.8, '#140d0a', 0.9, soft=0.3)+ fld = p.blend(p.flow(92, 8, 200, seed=65), p.contour(self.sleeves, 26, fallback=90), self.sleeves)+ p.strokes(self.v_coat + self.v_sleeves, fld, 'canvas', (30, 70), (2.0, 3.2), 0.7, pressure=0.62, alpha=0.35,+ value=0.08, hue=0.03, streak=0.4, seed=66)+ # chunky knit: the scarf roll along its path, the hanging end down its own, mittens; ribbed cuffs+ p.knit(self.scarf_roll * self.v_scarf, (17, 12), path=self.scarf_path, strength=0.85, seed=67)+ p.knit(self.scarf_end * (1 - self.scarf_roll) * self.v_scarf, (17, 12), angle=-8, origin=(790, 800),+ strength=0.85, seed=68)+ p.knit(self.mitt_l, (13, 10), angle=14, origin=(826, 848), curve=0.5, strength=0.85, seed=69)+ p.knit(self.mitt_r * (1 - self.mitt_l), (13, 10), angle=-14, origin=(942, 848), curve=0.5, strength=0.85,+ seed=70)+ p.rib(self.cuff_l, [(780, 922), (806, 898)], 7.0)+ p.rib(self.cuff_r, [(962, 898), (988, 922)], 7.0)+ p.glaze(p.soften(np.roll(self.scarf_roll, 10, axis=0), 6) * self.scarf_end * (1 - self.scarf_roll), '#160406', 0.45,+ 'normal')+ p.fuzz(self.v_scarf, (5, 12), n=800, width=(0.7, 1.1), out=0.6, alpha=0.55, lift=0.18, seed=71)+ p.fuzz(self.mittens, (4, 10), n=420, width=(0.7, 1.1), out=0.6, alpha=0.55, lift=0.18, seed=72)++ # ------------------------------------------------------------------ 7. the face+ def features(self):+ p = self.p+ vf = self.v_face+ # the red flush: a band under and round the eyes running over the bridge, the cheeks, a little on the chin+ core = np.maximum.reduce([+ p.spot(*F(-54, 24), 44, 24, TILT_D, solid=0.25), p.spot(*F(46, 22), 52, 26, TILT_D, solid=0.25),+ p.spot(*F(-4, 20), 26, 16, TILT_D, solid=0.0) * 0.7,+ p.ring(*F(-54, 4), 34, 21, 16, TILT_D, below=0.5) * 0.85,+ p.ring(*F(46, 2), 39, 23, 18, TILT_D, below=0.5) * 0.85])+ p.flush(core * vf, 'flush', 0.62, speckle=0.3)+ wide = np.maximum.reduce([p.spot(*F(60, 56), 76, 56, TILT_D, solid=0.0),+ p.spot(*F(-80, 56), 44, 52, TILT_D, solid=0.0),+ p.spot(*F(-14, 140), 30, 14, TILT_D, solid=0.0) * 0.6])+ p.flush(wide * vf, 'flush_light', 0.4, speckle=0.85)+ # eyes: heavy, half closed, looking down at the jar+ look = (-0.1, 0.9)+ p.eye(*F(-54, 4), 36, 22, look=look, lid=0.52, lower=0.08, droop=0.45, rot=TILT_D - 4, side=-1, iris_r=0.68,+ fold='#e3a39b', reflect='#f7b45e', clip=vf)+ p.eye(*F(46, 2), 43, 25, look=look, lid=0.52, lower=0.08, droop=0.45, rot=TILT_D + 3, side=1, iris_r=0.68,+ fold='#e3a39b', reflect='#f7b45e', clip=vf)+ # the long nose with a red tip; the small unsmiling mouth; a soft contour on the shadow side+ p.nose(FL([(-4, -4), (-8, 28), (-14, 54), (-22, 76)]), 26, tip_r=14, side=1, shade=0.55, tip_strength=0.85,+ clip=vf)+ p.mouth(*F(-12, 112), 34, droop=0.25, rot=TILT_D)+ p.line(FL([(125, -10), (118, 50), (96, 92), (60, 124), (24, 144), (-14, 152), (-48, 140)]), 2.2,+ '#8f7480', 0.3, taper=(0.5, 0.5), dry=0.3, clip=vf)+ p.glaze(p.soften(self.curtain_l, 8) * vf * (1 - self.curtain_l), '#6e5a66', 0.4, 'multiply')++ # ------------------------------------------------------------------ 8. the jar, the ghosts and their light+ def ghosts(self):+ p = self.p+ g, j = GHOST, JAR+ p.light(g['cx'], g['top'] + g['h'] * 0.6, 140, power=1.35, squash=0.9)+ for o in OTHERS:+ p.light(o['cx'], o['top'] + o['h'] * 0.6, o['w'] * 1.15, power=0.7)+ # what catches the light: leaves fully, the sky a little (air), wool and porcelain facing down strongly+ rec = 0.12 + 0.88 * p.soften(self.hedge.astype(np.float32), 40)+ under = p.shading(self.face, light=(0.1, 0.9, 0.45), sigma=40)+ rec = rec * (1 - self.figure) + self.figure * 0.3+ rec = np.where(self.v_face > 0.5, 0.25 + 0.8 * under, rec)+ rec = np.where(self.v_hands > 0.5, 1.0, rec)+ rec = np.where(self.v_scarf > 0.5, 0.45, rec)+ rec = np.where((self.v_coat + self.v_sleeves) > 0.5, 0.7, rec)+ rec = np.where(self.v_cover > 0.5, 0.6, rec)+ p.illuminate(rec.astype(np.float32), gain=1.0, base=0.15, albedo=1.4)+ del rec, under+ for i, o in enumerate(OTHERS):+ p.ghost(o['cx'], o['top'], o['w'], o['h'], look=o['look'], lean=o['lean'], tips=6 if o['w'] < 90 else 7,+ seed=81 + i)+ # the jar: the coat seen through grey-green glass, the ghost inside, warm air filling the glass+ inside = self.v_jar * (1 - self.cover)+ p.glaze(inside, '#8fa3a6', 0.3, 'multiply')+ p.ghost(g['cx'], g['top'], g['w'], g['h'], look=(-0.6, -0.8), tips=6, glow=1.25, clip=inside, seed=80)+ p.glaze(p.spot(g['cx'], g['top'] + g['h'] * 0.6, 90, 110, solid=0.0) * inside, 'glow', 0.5, 'screen')+ # the glass itself: a band of light just inside its edge (cool on the left, warm on the right), a white+ # streak down the left, the thick base and the shoulders catching the glow+ cx, t, b, hf = j['cx'], j['top'], j['bot'], j['half']+ keep = 1 - self.mittens+ rim = self.jar * (1 - smoothstep(0.55, 0.95, p.soften(self.jar, 5))) * keep * (1 - self.cover)+ p.glaze(rim * (p.XX < cx), '#cdd8da', 0.35, 'screen')+ p.glaze(rim * (p.XX >= cx), 'glow', 0.45, 'screen')+ p.line([(cx - hf + 9, t + 58), (cx - hf + 8, t + 120), (cx - hf + 10, b - 30)], 3.0, '#f2efe6', 0.65,+ taper=(0.4, 0.5), clip=keep)+ p.line([(cx - hf + 22, t + 64), (cx - hf + 21, t + 110)], 7.0, '#e9eee9', 0.16, taper=(0.5, 0.5), clip=keep)+ p.line([(cx + hf - 7, t + 60), (cx + hf - 6, b - 34)], 2.4, 'glow', 0.6, taper=(0.4, 0.4), clip=keep)+ p.line([(cx - hf + 14, b - 12), (cx - 24, b - 2), (cx + 24, b - 2), (cx + hf - 14, b - 12)], 3.4, 'glow', 0.8,+ taper=(0.4, 0.4), clip=keep)+ p.line([(cx - hf + 18, b - 20), (cx, b - 12), (cx + hf - 18, b - 20)], 2.0, 'glow_core', 0.45,+ taper=(0.4, 0.4), clip=keep)+ p.line([(cx - j['neck'] - 2, t + 26), (cx - hf + 8, t + 42)], 2.2, '#f2efe6', 0.5, taper=(0.4, 0.4))+ p.line([(cx + j['neck'] + 2, t + 26), (cx + hf - 8, t + 42)], 2.2, 'glow', 0.5, taper=(0.4, 0.4))+ p.emit(cx, g['top'] + g['h'] * 0.6, 50, 0.3, ry=70)+ # twine round the neck of the jar, a small bow+ tw = [(cx - 60, t + 18), (cx - 30, t + 23), (cx, t + 24), (cx + 30, t + 23), (cx + 60, t + 18)]+ p.line(tw, 3.0, '#a08562', 0.95, taper=(0.1, 0.1))+ p.line([(x, y + 4) for x, y in tw], 2.6, '#7c6448', 0.9, taper=(0.1, 0.1))+ bx, by = cx - 22, t + 24+ for sg in (-1, 1):+ p.line([(bx, by), (bx + sg * 14, by - 10), (bx + sg * 22, by - 4), (bx + sg * 12, by + 2), (bx, by)], 2.6,+ '#a08562', 0.95, taper=(0.2, 0.2))+ p.line([(bx, by), (bx - 6, by + 18), (bx - 9, by + 30)], 2.4, '#8f7656', 0.9, taper=(0.1, 0.6))+ p.line([(bx, by), (bx + 5, by + 16), (bx + 4, by + 26)], 2.4, '#8f7656', 0.9, taper=(0.1, 0.6))++ # ------------------------------------------------------------------ 9. last touches+ def last(self):+ p = self.p+ # leaves in front: over the lower corners of her coat and round the ghosts in the hedge, lit by them+ front = np.maximum.reduce([p.spot(560, 1060, 220, 140, solid=0.3), p.spot(1240, 1070, 240, 130, solid=0.3),+ p.spot(1296, 700, 90, 50, solid=0.2), p.spot(118, 720, 80, 40, solid=0.2),+ p.spot(1500, 500, 120, 40, solid=0.2), p.spot(330, 512, 90, 30, solid=0.2)])+ p.foliage(front, 46, (80, 130), ('leaf', 'leaf_olive', 'leaf', 'leaf_maroon', 'leaf_rust'), (0.2, 0.5),+ lit=1.0, veins=0.4, seed=91)+ # the blunt cut: a few fine tips just below the fringe+ edge = np.zeros((H, W), np.float32)+ for uu in np.linspace(-120, 168, 140):+ x, y = F(uu, -37)+ xi, yi = int(x), int(y)+ edge[yi - 1:yi + 1, xi - 1:xi + 1] = 1+ p.strands(self.fringe, self.hair_flow, ('jet', 'hair_black', 'hair_dark'), n=60, length=(4, 9),+ width=(0.7, 1.0), roots=edge, clip=False, alpha=0.5, jitter=8, seed=92)+ # loose burlap fibres catching the light at the hat's edge+ b2 = p.soften(self.hat, 2)+ p.strands(self.hat, 0.0, ('burlap_hi', '#8a7462'), n=70, length=(8, 22), width=(0.6, 0.9),+ roots=((b2 > 0.4) & (b2 < 0.6)).astype(np.float32), curl=20, jitter=80, clip=False, alpha=0.5,+ seed=93)+ # a faint warm breath in the air round the jar+ p.glaze(p.spot(884, 820, 220, 180, solid=0.0) * (1 - self.v_face) * (1 - self.jar), 'glow', 0.07, 'screen')+++PHASES = ('sketch', 'sky', 'hedge_leaves', 'block', 'model', 'cloth', 'features', 'ghosts', 'last')+++def main():+ out = sys.argv[1] if len(sys.argv) > 1 and not sys.argv[1].startswith('--') else 'poetichalloween_ghost_jar.jpg'+ stages = sys.argv[sys.argv.index('--stages') + 1] if '--stages' in sys.argv else None+ T0 = time.time()+ tick = (lambda name: print(f'{name:12s} {time.time() - T0:5.1f}s')) if os.environ.get('PH_TIMING') else (lambda n: None)+ p = PoeticHalloween(W, H, seed=11, keep_stages=bool(stages), stages_dir=stages)+ p.finish()+ p.ground()+ p.stage('board')+ sc = Scene(p)+ tick('setup')+ for name in PHASES[:-1]:+ getattr(sc, name)()+ tick(name)+ p.stage(name)+ getattr(sc, PHASES[-1])()+ tick(PHASES[-1])+ p.save(out, stages_dir=stages)+ print('saved', out, f'{time.time() - T0:.1f}s', p.n_strokes, 'strokes')+++if __name__ == '__main__':+ main()diff --git a/lib/poetichalloween.py b/lib/poetichalloween.pynew file mode 100644index 0000000..1340f7f--- /dev/null+++ b/lib/poetichalloween.py@@ -0,0 +1,1848 @@+"""poetichalloween — 诗意万圣夜 / Poetic Halloween: melancholic, surreal picture-book portraits for an autumn night+(numpy + Pillow only).++The look: a quiet, slightly unsettling picture-book portrait for autumn and Halloween, painted in opaque gouache+and fine coloured-pencil hatching on a dark toned board and then printed. Pale porcelain faces with a strong red+flush on the nose, the cheeks, the eyelids and round the eyes (red-rimmed lower lids), heavy half-closed sad eyes+and a small unsmiling mouth, the volumes very simplified. Hair is one solid sculpted mass -- a blunt jet-black (or+silver-white) bob with a dead-straight fringe, almost no visible strands, a soft sheen. Clothes are tactile+textiles painted in: coarse burlap and felt hats, chunky wool scarves and mittens, tartan coats. The grounds are+dark and moody (night indigo with stars, dense dark foliage), and every picture has ONE luminous accent: little+sheet-ghosts with glowing eyes and glowing fringe tips whose warm light picks out the leaves, the wool and the+underside of a face. Fine painterly grain over everything, like a print with a tooth. Poetic, never gory.++Physical model+ board A dark toned board with a fine tooth `T`, rank-equalised to a uniform 0..1 so that "the paint reaches+ where tooth > 1 - pressure" turns pressure straight into coverage; the same tooth is pre-averaged along+ 8 directions (`TD`, uint8) so a dry stroke skips the pits in short streaks along itself; a separate+ single-pixel stipple `ST` (uint8) is kept for the speckled flush. A pigment buffer `F` records how much+ paint already sits in the tooth (later layers reach a little deeper).+ strokes Opaque gouache strokes and fine pencil hatching are short centrelines integrated through an+ orientation field (angles mod pi) with a slight wrist arc. Tens of thousands go at once: Pillow draws+ every *segment* of every stroke with its own id into a 2x supersampled integer map; numpy looks each+ covered sub-pixel up to its segment, recovers the position along the stroke (a pressure profile with+ rounded ends) and across it (soft sides, bristle lanes that open as the stroke runs dry), lays pigment+ where the pressure reaches the direction-matched tooth and sums back with bincount. A stroke can take+ its colour from the canvas under its centre (`colour='canvas'`): a painterly repaint of a computed+ base (a tartan, a modelled face) that keeps the colour but adds the hand. Big batches are split into+ bands of rows (`band_px` sub-pixels each) to keep the memory down.+ pigment Opaque paint: new = old + A x (target - old), target = (1 - opacity) x old x colour + opacity x colour+ (the white-referenced multiply, so it also works on a dark board).+ layers `wash()` a smooth opaque coat (colour may be a ramp looked up by a field), with the deepest pits of the+ tooth left a touch lighter and an edge that breaks into the tooth (computed in bands of rows, so a+ canvas-wide coat makes no canvas-wide RGB temporaries); `model()` lays a soft dome light on a shape and+ washes a dark -> light ramp over it -- the simplified volumes of the faces. `soften()` blurs a mask only+ round its shape.+ hair A bob is a solid mass: modelled with a near-black -> slate ramp, then `sheen()` streaks a soft+ anisotropic highlight band along the flow (long thin strokes where a dome light sits in a narrow band),+ and only a few low-contrast `strands()` show the lie of the hair; the blunt cut is the mask's edge plus+ a few fine tips.+ faces `eye()` a heavy-lidded sad eye: an almond of off-white ball shaded grey under a thick lid that covers+ about half of the iris and droops at the outer corner, a dark lid line, a red wet rim along the lower+ lid, a small catchlight and, optionally, the warm glint of a light below mirrored low in the iris.+ `flush()` lays the red flush as a smooth glaze plus a fine stipple of single specks, denser where the+ flush is stronger (the speckled red flush); `spot()` and `ring()` make the soft fields it takes.+ `nose()` a long simplified nose that is its own small volume -- lit, a mauve shadow side, a small cast+ shadow -- reddening to a red tip; `mouth()` small, closed, unsmiling lips.+ textiles `burlap()` a plain weave of coarse slubby threads (each row and column its own thickness, lumps along+ it, over-under alternation, dark holes between), lit as a height field and multiplied onto the paint,+ plus loose fibres and a fuzzy edge; it can follow a curve (`coords`, e.g. from `along()`); `knit()`+ stockinette V stitches (rows can follow a path: a scarf) and `rib()` ribbing, lit the same way;+ `tartan()` a symmetric sett woven 2/2 twill (warp or weft shows by a diagonal rule, each thread+ rounded), over a light field and a fold warp; `fuzz()` fibres growing out of a silhouette, coloured from+ the paint just inside it.+ foliage `leaf()` a broad palmate, double-serrated (currant / maple-like) leaf, foreshortened at random: each+ lobe folded along its midrib (one half lighter), veins, a mottle, a soft shadow cast down and to the+ right on what is behind (the depth of a hedge), optionally lit by the light map; `foliage()` scatters+ hundreds back to front, the far ones smaller and darker.+ light `light()` registers warm point lights (falloff 1 / (1 + (d / r)^2)^2) summed into a light map;+ `illuminate()` lights painted surfaces by it: C <- 1 - (1 - C) exp(-L x receptivity x (base + albedo C)),+ so pale wool and porcelain warm up strongly, dark leaves turn olive-orange near a ghost and black hair+ barely changes. `emit()` writes into an emission buffer that `render()` blooms (three blurs, screened).+ ghosts `ghost()` a small sheet-ghost: a translucent dome-and-bell body made of hundreds of fine silver strands+ that fall from the crown like hair to a fringe of locks, two glowing eyes (cream core, amber ring, halo),+ a warm glowing bead at the end of every lock, a hem lit warm and a faint halo round the whole sheet.+ sky `stars()` pinpricks with a few larger ones and a faint halo.+ finish `finish()` records a slight softness, the bloom, a fine print grain with a coarser tooth that shows in+ the darks (a risograph-like grain), and lifted blacks -- applied in render (in bands of rows; the grain+ is made in `ground()` while memory is low), so every stage snapshot matches the final look.++API (canvas pixel coordinates; a number given as a field is a direction in degrees, 0 = to the right, 90 = down;+ field arrays are radians; colours are PAINTS names, '#rrggbb' or RGB triples; ramps are RAMPS names or lists,+ dark -> light)+ surface PoeticHalloween(W, H, seed, keep_stages, stages_dir); ground(tone, tooth); finish(soft, grain, tooth,+ bloom, lift)+ masks poly(pts, smooth) / ellipse(cx, cy, rx, ry, rot) / blob(cx, cy, rx, ry, rough) / tube(path, w0, w1) /+ rect(x0, y0, x1, y1) / below(xs, ys) -> canvas-sized float masks; spot(cx, cy, rx, ry, rot, solid) /+ ring(cx, cy, rx, ry, width, rot) soft fields; soften(mask, sigma) a blur done only round the shape+ fields flow(angle, turb, scale); field(f(x, y) -> degrees) -- or pass f itself, evaluated only where it is+ needed; radial(cx, cy, offset); contour(mask, sigma,+ offset, fallback); blend(f1, f2, w); rotate(field, deg); value(top, bottom, y0, y1); shading(mask, light,+ sigma, wrap)+ strokes strokes(region, field, colour, length, width, density, pressure, opacity, alpha, streak, soft, taper,+ passes, clip, avoid, fade); lines(paths, colour, width, ...); sketch(path, colour, width, alpha)+ layers wash(mask, colour, alpha, grain, edge, dry, clip, opacity); model(mask, colours, light, lit, sigma,+ wrap, gamma, lo, hi); glaze(mask, colour, alpha, mode, soft); dab(x, y, r, colour, alpha, soft, ry,+ rot); line(path, width, colour, alpha, taper, dry, clip)+ hair strands(region, flow, colours, n, length, width, curl, jitter, shade, alpha, clip, roots, lock);+ sheen(mask, flow, lit, band, colour, alpha, strokes)+ faces eye(cx, cy, rx, ry, iris, look, lid, lower, droop, fold, rim, reflect, rot, side, clip); flush(field,+ colour, strength, speckle, clip); nose(path, width, tip_r, side, shade, tip, tip_strength, clip);+ mouth(x, y, w, droop, colour, rot)+ textiles burlap(mask, angle, period, coords, holes, slub, rust, fibres, fuzz); knit(mask, stitch, angle, path,+ origin, curve); rib(mask, path, period); tartan(mask, sett, scale, angle, coords, lit, lo, hi);+ fuzz(mask, length, n, width, out); along(path, mask) -> (S, T) coordinates that bend with a tube+ foliage leaf(x, y, size, angle, colours, value, fold, lit, veins, squash, shadow); foliage(region, n, size,+ colours, value, angle, fold, lit, veins, squash, shadow)+ light light(x, y, r, colour, power, squash, fall); lightmap(); illuminate(receptivity, gain, base, albedo);+ emit(x, y, r, power, ry)+ ghosts ghost(cx, top, w, h, look, tips, strands, glow, lean, eye_r, body_alpha, sheet, clip)+ sky stars(region, n, size, bright, warm)+ output render(); composite(); stage(name); save(path, stages_dir) -- save('x.jpg') quality 88, 4:4:4 chroma++ import sys; sys.path.insert(0, 'lib')+ from poetichalloween import PoeticHalloween+ p = PoeticHalloween(1920, 1080, seed=3); p.finish(); p.ground()+ p.wash(p.rect(0, 0, 1920, 1080), ('night', p.value(0.2, 0.7)))+ face = p.ellipse(960, 520, 130, 160)+ p.model(face, 'porcelain')+ p.flush(p.ring(910, 500, 40, 26, 22) + p.spot(960, 560, 30, 40), 'flush', 0.7)+ p.eye(905, 500, 34, 22, look=(0, 0.4), lid=0.52, side=-1); p.eye(1015, 500, 34, 22, look=(0, 0.4), lid=0.52)+ p.light(1300, 760, 260, 'glow', 1.2); p.illuminate(1.0)+ p.ghost(1300, 640, 110, 150)+ p.save('halloween.jpg')+"""+import io+import os+import numpy as np+from PIL import Image, ImageDraw+from core import blur, fbm1d, spline, noise2d, smoothstep, blob_pts++PAINTS = {+ # the board, chalk underdrawing+ 'board': '#14131c', 'chalk': '#cfc6b4', 'chalk_warm': '#d9b78c',+ # night sky and stars+ 'night_deep': '#0b0f24', 'night': '#141a38', 'indigo': '#1c2349', 'dusk': '#2a2c58', 'haze': '#3b3f6e',+ 'star': '#eef0ff', 'warmstar': '#ffe7c6',+ # porcelain skin and the red flush+ 'porcelain': '#f1e8e2', 'porcelain_light': '#fbf7f3', 'porcelain_shade': '#cdbdbd', 'porcelain_deep': '#9f8b93',+ 'flush': '#d8443b', 'flush_light': '#e8735e', 'flush_deep': '#b02f2e', 'rim': '#c23b36', 'lip': '#c45a54',+ 'lip_dark': '#7e2d2e', 'lid_line': '#3a1d1f', 'crease': '#a5585a',+ # eyes+ 'eye_white': '#e9e5e1', 'eye_shade': '#9a9db0', 'iris': '#2b2427', 'iris_light': '#6d5a50', 'pupil': '#0d0a0c',+ # hair+ 'jet': '#0a090f', 'hair_black': '#111019', 'hair_dark': '#1a1b27', 'hair': '#262b3d', 'hair_sheen': '#4d5876',+ 'hair_shine': '#7d88a6', 'silver': '#c9ccd6', 'silver_light': '#eceef3',+ # textiles+ 'burlap_dark': '#1d1816', 'burlap': '#2e2622', 'burlap_light': '#4b3e35', 'burlap_hi': '#6e5c4d',+ 'burlap_rust': '#6a3a22', 'oxblood_deep': '#3a0c10', 'oxblood_dark': '#5c1418', 'oxblood': '#7d1d21',+ 'oxblood_light': '#a03230', 'oxblood_pale': '#c4584a', 'navy': '#141b31', 'bottle': '#1b2b24', 'tar': '#0c0d12',+ 'rust': '#8a3b22', 'ochre': '#a47a34', 'mustard': '#c2953c',+ # foliage+ 'leaf_black': '#0b120f', 'leaf_deep': '#13201a', 'leaf': '#1e3023', 'leaf_olive': '#35432a', 'leaf_moss': '#4f5a33',+ 'leaf_maroon': '#3a171a', 'leaf_rust': '#6b2c18', 'leaf_orange': '#b4501f',+ # ghosts and their glow+ 'ghost_dark': '#4a5167', 'ghost': '#8c95ab', 'ghost_light': '#c6ccd9', 'ghost_white': '#eef0f5',+ 'glow': '#ffb04a', 'glow_core': '#fff2d2', 'glow_ring': '#e08a2e', 'ember': '#ff8a2c',+}+RAMPS = { # dark -> light+ 'night': ('#090c1f', '#0f1430', '#161c3c', '#1f2548', '#2c2f5a'),+ 'porcelain': ('#a8949a', '#cbbbbb', '#e3d8d4', '#f2ebe6', '#fcf9f6'),+ 'hair': ('#07070b', '#0d0d14', '#15161f', '#20243a', '#3a4462'),+ 'silver': ('#7f8596', '#a3a8b6', '#c4c8d2', '#dfe2e9', '#f5f6f9'),+ 'burlap': ('#151110', '#231d1a', '#342b26', '#4a3d34', '#65544a'),+ 'oxblood': ('#24070a', '#3e0d12', '#5c161a', '#7a2124', '#983630'),+ 'leaf': ('#070c0a', '#0d1712', '#15231a', '#203121', '#34442a'),+ 'leaf_olive': ('#0e120b', '#1a2214', '#29331c', '#3d4726', '#56603a'),+ 'leaf_maroon': ('#12080a', '#230e10', '#381618', '#4f2020', '#6a2d24'),+ 'leaf_rust': ('#1e0c07', '#3a170c', '#5c2412', '#83361a', '#a84d24'),+ 'ghost': ('#3b4157', '#5f677f', '#8a93a9', '#b8bfcd', '#e9ecf2'),+ 'glow': ('#7a2e0c', '#c4561a', '#f08a2e', '#ffbf5c', '#fff1cc'),+}+LIGHT = (-0.5, -0.62, 0.6) # upper left, a little in front (cool night light)+GLOW = (1.0, 0.68, 0.32) # the ghosts' warm light (amber), as an RGB triple+++def hexc(c):+ """'#rrggbb', a PAINTS name or an RGB triple -> float32 RGB in 0..1"""+ if not isinstance(c, str): return np.asarray(c, np.float32)+ h = PAINTS.get(c, c).lstrip('#')[:6]+ return np.array([int(h[i:i + 2], 16) for i in (0, 2, 4)], np.float32) / 255+++def mix(a, b, t):+ return hexc(a) * (1 - t) + hexc(b) * t+++def ramp(spec):+ """a RAMPS name or a list of colours -> (K, 3) array"""+ if isinstance(spec, np.ndarray): return spec.astype(np.float32)+ if isinstance(spec, str): spec = RAMPS[spec]+ return np.stack([hexc(c) for c in spec]).astype(np.float32)+++def ramp_at(R, l):+ """colour at 0..1 positions l along ramp R (vectorised)"""+ l = np.clip(np.asarray(l, np.float32), 0, 1) * (len(R) - 1)+ i = np.minimum(l.astype(np.int32), len(R) - 2)+ f = (l - i)[..., None]+ return R[i] * (1 - f) + R[i + 1] * f+++def hue_rotate(c, theta):+ """rotate RGB colours (N, 3) about the grey axis by theta radians (N,): a real hue shift, value kept"""+ cs, sn = np.cos(theta)[:, None], np.sin(theta)[:, None]+ m = c.mean(1, keepdims=True)+ cr = np.stack([c[:, 2] - c[:, 1], c[:, 0] - c[:, 2], c[:, 1] - c[:, 0]], 1) / np.sqrt(3)+ return (c * cs + cr * sn + m * (1 - cs)).astype(np.float32)+++def _equalise(a):+ """rank-equalise to a uniform 0..1 distribution"""+ flat = a.ravel()+ o = np.argsort(flat, kind='stable')+ out = np.empty(flat.size, np.float32)+ out[o] = np.linspace(0, 1, flat.size, dtype=np.float32)+ return out.reshape(a.shape)+++def _lookup(field, x, y):+ if callable(field): return np.deg2rad(np.asarray(field(x, y), np.float32)).astype(np.float32)+ if np.ndim(field) == 0: return np.full(len(x), float(field), np.float32)+ H, W = field.shape[:2]+ return field[np.clip(y.astype(np.int32), 0, H - 1), np.clip(x.astype(np.int32), 0, W - 1)]+++def _resample(P, step):+ P = np.asarray(P, np.float32)+ d = np.r_[0, np.cumsum(np.linalg.norm(np.diff(P, axis=0), axis=1))]+ if d[-1] < 1e-3: return P[:1]+ s = np.linspace(0, d[-1], max(2, int(d[-1] / step) + 1))+ return np.stack([np.interp(s, d, P[:, 0]), np.interp(s, d, P[:, 1])], 1).astype(np.float32)+++def _resample_k(P, k):+ """resample a polyline to exactly k points by arc length"""+ P = np.asarray(P, np.float32)+ if len(P) == 1: return np.repeat(P, k, 0)+ d = np.r_[0, np.cumsum(np.linalg.norm(np.diff(P, axis=0), axis=1))]+ if d[-1] < 1e-4: return np.repeat(P[:1], k, 0)+ s = np.linspace(0, d[-1], k)+ return np.stack([np.interp(s, d, P[:, 0]), np.interp(s, d, P[:, 1])], 1).astype(np.float32)+++def _hash(a, b):+ h = np.sin(a * 12.9898 + b * 78.233) * 43758.5453+ return (h - np.floor(h)).astype(np.float32)+++def _wrap(a):+ return (a + np.pi) % (2 * np.pi) - np.pi+++def _maple(size, angle, r, lobes=5):+ """outline of a broad palmate, double-serrated leaf (currant / maple: shallow sinuses, wide lobes), polar round+ the point where the veins meet, main lobe toward `angle` degrees; returns (points (N, 2) relative to that+ point, lobe tips (k, 2))"""+ if lobes >= 5:+ spec = [(-118, 0.52, 0.36), (-60, 0.84, 0.4), (0, 1.0, 0.4), (60, 0.84, 0.4), (118, 0.52, 0.36)]+ sinus = [0.42, 0.56, 0.56, 0.42]+ else:+ spec = [(-62, 0.8, 0.46), (0, 1.0, 0.44), (62, 0.8, 0.46)]+ sinus = [0.55, 0.55]+ pts = [(np.pi, 0.2)]+ tips = []+ for i, (a, L, w) in enumerate(spec):+ a = np.deg2rad(a + r.normal(0, 5)); L = L * r.uniform(0.9, 1.08); w = w * r.uniform(0.88, 1.12)+ lobe = [(a - w, 0.62 * L), (a - 0.62 * w, 0.8 * L), (a - 0.28 * w, 0.94 * L), (a, L), (a + 0.28 * w, 0.94 * L),+ (a + 0.62 * w, 0.8 * L), (a + w, 0.62 * L)]+ pts += lobe+ tips.append((a, L))+ if i < len(sinus):+ an = np.deg2rad((spec[i][0] + spec[i + 1][0]) / 2 + r.normal(0, 3))+ pts.append((an, sinus[i] * r.uniform(0.92, 1.08)))+ pts.append((np.pi, 0.2))+ P = np.array(pts, np.float32)+ # densify in polar coordinates, then serrate: teeth along the lobes, every third one bigger (double-serrate)+ th = np.unwrap(P[:, 0]); rr = P[:, 1]+ k = 5+ t = np.linspace(0, len(P) - 1, (len(P) - 1) * k + 1)+ th2 = np.interp(t, np.arange(len(P)), th); r2 = np.interp(t, np.arange(len(P)), rr)+ j = np.arange(len(t))+ tooth = np.where(j % 2 == 0, 1.0, -0.5) * np.where(j % 6 == 0, 0.06, 0.032) * smoothstep(0.45, 0.66, r2)+ r2 = (r2 + tooth) * size+ a0 = np.deg2rad(angle)+ out = np.stack([np.cos(th2 + a0) * r2, np.sin(th2 + a0) * r2], 1)+ tp = np.array([(np.cos(a + a0) * L * size, np.sin(a + a0) * L * size) for a, L in tips], np.float32)+ return out.astype(np.float32), tp+++class PoeticHalloween:+ PAINTS = PAINTS+ RAMPS = RAMPS+ LIGHT = LIGHT++ def __init__(self, W=1920, H=1080, seed=0, keep_stages=True, stages_dir=None):+ if W * H > 4096 * 4096: raise ValueError('canvas larger than 4096 x 4096')+ self.W, self.H, self.seed = W, H, seed+ self.rng = np.random.default_rng(seed)+ self.keep_stages, self.stages_dir = keep_stages, stages_dir+ self.stages, self._n_stages = [], 0+ self.YY, self.XX = np.mgrid[0:H, 0:W].astype(np.float32)+ self.C = np.empty((H, W, 3), np.float32); self.C[:] = hexc('board')+ self.F = np.zeros((H, W), np.float32) # pigment already sitting in the tooth+ self.E = np.zeros((H, W), np.float32) # emission (what glows), bloomed in render+ self._bloom = None # cached bloom of E+ self.T = None; self.TD = None; self.EN = None; self.ST = None+ self.lights, self._L = [], None+ self.fin = None+ self.floor = 0.24 # pigment a brush still leaves in the pits of the tooth+ self.band_px = 0.8e6 # sub-pixels per raster band (memory vs. speed)+ self.n_strokes = 0++ def _r(self, seed=None):+ return np.random.default_rng(int(self.rng.integers(1 << 30)) if seed is None else seed)++ # ================================================================== board+ def ground(self, tone='board', tooth=1.0, drag=3, seed=None):+ """a dark toned board: an equalised fine tooth (showing as a faint mottle) and the tooth dragged along 8+ stroke directions for the dry strokes"""+ H, W = self.H, self.W+ r = self._r(seed)+ z = lambda a: (a - a.mean()) / (a.std() + 1e-6)+ g1 = blur(r.random((H, W)).astype(np.float32), 0.6)+ g2 = noise2d(H, W, 2.6, 2, int(r.integers(1 << 30)))+ g3 = noise2d(H, W, 8.0, 2, int(r.integers(1 << 30)))+ self.T = _equalise(0.75 * z(g1) + 0.45 * z(g2) + 0.18 * z(g3))+ mot = noise2d(H, W, 180, 3, int(r.integers(1 << 30))) - 0.5+ self.C = (hexc(tone)[None, None] * (1 + 0.1 * mot[..., None] + 0.05 * tooth * (self.T[..., None] - 0.5))+ ).astype(np.float32)+ self.F[:] = 0+ TD = np.empty((8, H, W), np.uint8)+ ks = np.arange(-drag, drag + 1); wk = 1.0 - np.abs(ks) / (drag + 1.0)+ for b in range(8):+ a = np.pi * b / 8+ acc = np.zeros_like(self.T)+ for k, w in zip(ks, wk):+ acc += w * np.roll(self.T, (int(round(k * np.sin(a))), int(round(k * np.cos(a)))), axis=(0, 1))+ TD[b] = np.round(_equalise(0.4 * self.T + 0.6 * acc / wk.sum()) * 255).astype(np.uint8)+ del acc+ self.TD = TD+ self.EN = noise2d(H, W, 4.0, 2, int(r.integers(1 << 30))) - 0.5+ # a fine stipple (single pixels and pairs) for the speckled flush, kept as uint8+ self.ST = np.round(_equalise(blur(r.random((H, W)).astype(np.float32), 0.45)) * 255).astype(np.uint8)+ # the print grain and the coarser printed tooth used by render(), made now while memory is low+ rg = np.random.default_rng(self.seed + 7)+ g = rg.standard_normal((H, W), dtype=np.float32)+ self._grain = (0.7 * g + 0.6 * blur(g, 0.8)).astype(np.float32)+ del g+ self._tooth = (noise2d(H, W, 2.2, 2, self.seed + 11) - 0.5).astype(np.float32)+ return self++ def _need(self):+ if self.T is None: self.ground()++ # ================================================================== masks+ def poly(self, pts, smooth=False, ss=2):+ """filled polygon -> canvas-sized float mask (smooth=True runs a closed Catmull-Rom spline through the points)"""+ sl, m = self._poly_crop(pts, smooth, ss)+ out = np.zeros((self.H, self.W), np.float32)+ if sl is not None: out[sl] = m+ return out++ def _poly_crop(self, pts, smooth=False, ss=2):+ """filled polygon rasterised only over its own bounding box -> (slice, crop)"""+ P = np.asarray(pts, np.float32)+ if smooth:+ Q = np.vstack([P[-1:], P, P[:2]])+ P = spline(Q, 10)[10:-10]+ x0, y0 = max(0, int(np.floor(P[:, 0].min())) - 1), max(0, int(np.floor(P[:, 1].min())) - 1)+ x1, y1 = min(self.W, int(np.ceil(P[:, 0].max())) + 2), min(self.H, int(np.ceil(P[:, 1].max())) + 2)+ if x1 <= x0 or y1 <= y0: return None, None+ im = Image.new('L', ((x1 - x0) * ss, (y1 - y0) * ss), 0)+ ImageDraw.Draw(im).polygon([((float(x) - x0) * ss, (float(y) - y0) * ss) for x, y in P], fill=255)+ m = np.asarray(im.resize((x1 - x0, y1 - y0), Image.BOX), np.float32) / 255+ return (slice(y0, y1), slice(x0, x1)), m++ def ellipse(self, cx, cy, rx, ry=None, rot=0.0):+ """anti-aliased ellipse mask (rot in degrees)"""+ ry = rx if ry is None else ry+ c, s = np.cos(np.deg2rad(rot)), np.sin(np.deg2rad(rot))+ x0, x1 = max(0, int(cx - max(rx, ry) - 3)), min(self.W, int(cx + max(rx, ry) + 4))+ y0, y1 = max(0, int(cy - max(rx, ry) - 3)), min(self.H, int(cy + max(rx, ry) + 4))+ out = np.zeros((self.H, self.W), np.float32)+ if x1 <= x0 or y1 <= y0: return out+ dx, dy = self.XX[y0:y1, x0:x1] - cx, self.YY[y0:y1, x0:x1] - cy+ u, v = (dx * c + dy * s) / rx, (-dx * s + dy * c) / ry+ d = np.sqrt(u * u + v * v)+ out[y0:y1, x0:x1] = np.clip((1 - d) * min(rx, ry) + 0.5, 0, 1)+ return out++ def blob(self, cx, cy, rx, ry=None, rough=0.1, seed=None, rot=0.0):+ ry = rx if ry is None else ry+ return self.poly(blob_pts(cx, cy, rx, ry, rough, 120, int(self._r(seed).integers(1 << 30)), np.deg2rad(rot)))++ @staticmethod+ def tube_pts(path, w0, w1=None, per=8):+ """outline points of a tube of width w0 -> w1 along a path (arms, a scarf end, a stem)"""+ w1 = w0 if w1 is None else w1+ P = spline(path, per) if len(path) > 2 else _resample(path, 4)+ n = len(P)+ Tg = np.gradient(P, axis=0); Tg /= np.linalg.norm(Tg, axis=1, keepdims=True) + 1e-6+ Nn = np.stack([-Tg[:, 1], Tg[:, 0]], 1)+ w = (np.linspace(w0, w1, n) if np.ndim(w0) == 0 else np.interp(np.linspace(0, 1, n), np.linspace(0, 1, len(w0)), w0))+ w = np.asarray(w, np.float32)[:, None] * 0.5+ return np.vstack([P + Nn * w, (P - Nn * w)[::-1]])++ def tube(self, path, w0, w1=None):+ """mask of a tube; w0 may be a list of widths along the path"""+ return self.poly(self.tube_pts(path, w0, w1))++ def rect(self, x0, y0, x1, y1):+ X, Y = self.XX, self.YY+ return (np.clip(X - x0 + 0.5, 0, 1) * np.clip(x1 - X + 0.5, 0, 1) *+ np.clip(Y - y0 + 0.5, 0, 1) * np.clip(y1 - Y + 0.5, 0, 1)).astype(np.float32)++ def below(self, xs, ys, invert=False):+ """mask of everything below a line through (xs, ys) (spline), or a constant y if xs is None"""+ if xs is None:+ m = np.clip(self.YY - float(ys) + 0.5, 0, 1)+ else:+ x = np.arange(self.W, dtype=np.float32)+ P = spline(np.stack([np.asarray(xs, np.float32), np.asarray(ys, np.float32)], 1), 12)+ o = np.argsort(P[:, 0])+ yl = np.interp(x, P[o, 0], P[o, 1]).astype(np.float32)+ m = np.clip(self.YY - yl[None] + 0.5, 0, 1)+ return (1 - m if invert else m).astype(np.float32)++ def spot(self, cx, cy, rx, ry=None, rot=0.0, solid=0.2, power=1.3):+ """a soft 0..1 field: 1 inside `solid` of the ellipse, easing to 0 at its rim (cheeks, a red nose, glows)"""+ ry = rx if ry is None else ry+ c, s = np.cos(np.deg2rad(rot)), np.sin(np.deg2rad(rot))+ R = max(rx, ry)+ x0, x1 = max(0, int(cx - R - 2)), min(self.W, int(cx + R + 3))+ y0, y1 = max(0, int(cy - R - 2)), min(self.H, int(cy + R + 3))+ out = np.zeros((self.H, self.W), np.float32)+ if x1 <= x0 or y1 <= y0: return out+ dx, dy = self.XX[y0:y1, x0:x1] - cx, self.YY[y0:y1, x0:x1] - cy+ d = np.sqrt(((dx * c + dy * s) / rx) ** 2 + ((-dx * s + dy * c) / ry) ** 2)+ out[y0:y1, x0:x1] = smoothstep(1.0, solid, d) ** power+ return out++ def ring(self, cx, cy, rx, ry=None, width=20.0, rot=0.0, power=1.2, below=0.0):+ """a soft 0..1 ring round an ellipse (the red round an eye); below > 0 makes the lower half stronger"""+ ry = rx if ry is None else ry+ c, s = np.cos(np.deg2rad(rot)), np.sin(np.deg2rad(rot))+ R = max(rx, ry) + width+ x0, x1 = max(0, int(cx - R - 2)), min(self.W, int(cx + R + 3))+ y0, y1 = max(0, int(cy - R - 2)), min(self.H, int(cy + R + 3))+ out = np.zeros((self.H, self.W), np.float32)+ if x1 <= x0 or y1 <= y0: return out+ dx, dy = self.XX[y0:y1, x0:x1] - cx, self.YY[y0:y1, x0:x1] - cy+ u, v = dx * c + dy * s, -dx * s + dy * c+ d = np.sqrt((u / rx) ** 2 + (v / ry) ** 2)+ dist = (d - 1) * min(rx, ry) # approximate distance outside the ellipse+ f = smoothstep(width, 0.0, np.abs(dist)) ** power+ if below: f = f * (1 - below + below * smoothstep(-0.6 * ry, 0.4 * ry, v))+ out[y0:y1, x0:x1] = f+ return out++ def soften(self, mask, sigma):+ """a blurred copy of a mask, blurred only round the shape (a canvas-wide blur makes canvas-wide float64+ temporaries for a shape that covers a few percent of it)"""+ out = np.zeros((self.H, self.W), np.float32)+ bb = self._bbox(mask, pad=int(3 * sigma) + 4)+ if bb is None: return out+ x0, y0, x1, y1 = bb+ out[y0:y1, x0:x1] = blur(mask[y0:y1, x0:x1].astype(np.float32), sigma)+ return out++ def _mask(self, region):+ if isinstance(region, np.ndarray): return region.astype(np.float32, copy=False)+ x0, y0, x1, y1 = (int(round(v)) for v in region)+ M = np.zeros((self.H, self.W), np.float32)+ M[max(0, y0):max(0, y1), max(0, x0):max(0, x1)] = 1+ return M++ @staticmethod+ def _bbox(M, thr=0.004, pad=0):+ rows = np.flatnonzero(M.max(1) > thr); cols = np.flatnonzero(M.max(0) > thr)+ if not len(rows) or not len(cols): return None+ H, W = M.shape+ return (max(0, cols[0] - pad), max(0, rows[0] - pad), min(W, cols[-1] + 1 + pad), min(H, rows[-1] + 1 + pad))++ # ================================================================== fields+ def flow(self, angle=0.0, turb=8.0, scale=240.0, seed=None):+ """orientation field: `angle` degrees with +-turb degrees of low-frequency wander at `scale` px"""+ n = noise2d(self.H, self.W, scale, 3, int(self._r(seed).integers(1 << 30))) - 0.5+ return np.deg2rad(angle + 2 * turb * n).astype(np.float32)++ def field(self, f):+ """an orientation field from f(x, y) -> degrees, evaluated on the whole canvas"""+ return np.deg2rad(np.asarray(f(self.XX, self.YY), np.float32)).astype(np.float32)++ def radial(self, cx, cy, offset=0.0, turb=4.0, scale=120.0, seed=None):+ """directions pointing away from (cx, cy), offset in degrees"""+ a = np.arctan2(self.YY - cy, self.XX - cx) + np.deg2rad(offset)+ if turb:+ a = a + np.deg2rad(2 * turb * (noise2d(self.H, self.W, scale, 3, int(self._r(seed).integers(1 << 30))) - 0.5))+ return a.astype(np.float32)++ def contour(self, mask, sigma=8.0, offset=0.0, fallback=None):+ """directions along the iso-lines of a (blurred) shape: strokes that wrap round a cheek, a sleeve, a scarf.+ Only computed round the shape (outside it: `fallback` degrees or 0)."""+ if isinstance(fallback, np.ndarray): out = fallback.astype(np.float32).copy()+ else: out = np.full((self.H, self.W), 0 if fallback is None else np.deg2rad(fallback), np.float32)+ bb = self._bbox(mask, pad=int(3 * sigma) + 4)+ if bb is None: return out+ x0, y0, x1, y1 = bb+ d = blur(mask[y0:y1, x0:x1].astype(np.float32), sigma)+ gy, gx = np.gradient(d)+ a = np.arctan2(gy, gx) + np.pi / 2 + np.deg2rad(offset)+ if fallback is not None:+ g = np.hypot(gx, gy)+ w = smoothstep(0.0, 0.25 / max(sigma, 1.0), g)+ fb = np.deg2rad(fallback) if np.ndim(fallback) == 0 else fallback[y0:y1, x0:x1]+ a = self.blend(np.broadcast_to(np.float32(fb), a.shape) if np.ndim(fb) == 0 else fb, a, w)+ out[y0:y1, x0:x1] = a+ return out++ @staticmethod+ def blend(f1, f2, w):+ """blend two orientation fields (doubled-angle average, so 0 and pi are the same orientation)"""+ w = np.asarray(w, np.float32)+ c = (1 - w) * np.cos(2 * f1) + w * np.cos(2 * f2)+ s = (1 - w) * np.sin(2 * f1) + w * np.sin(2 * f2)+ return (0.5 * np.arctan2(s, c)).astype(np.float32)++ @staticmethod+ def rotate(field, deg):+ if np.ndim(field) == 0: return float(field) + deg+ return (field + np.deg2rad(deg)).astype(np.float32)++ def value(self, top=0.0, bottom=1.0, y0=0, y1=None, mottle=0.04, scale=220.0, seed=None):+ """a 0..1 field: a vertical ramp from `top` at y0 to `bottom` at y1, with low-frequency mottling"""+ y1 = self.H if y1 is None else y1+ t = np.clip((self.YY - y0) / max(1, y1 - y0), 0, 1)+ v = top + (bottom - top) * t+ if mottle:+ v = v + 2 * mottle * (noise2d(self.H, self.W, scale, 3, int(self._r(seed).integers(1 << 30))) - 0.5)+ return np.clip(v, 0, 1).astype(np.float32)++ def shading(self, mask, light=LIGHT, sigma=None, wrap=0.25, flat=0.0):+ """0..1 light on a soft dome raised from the silhouette (sum of blurs), lit from `light` (x, y, z; screen y+ down). wrap > 0 lets the light creep round the terminator; flat mixes toward 0.5."""+ bb = self._bbox(mask)+ out = np.zeros((self.H, self.W), np.float32)+ if bb is None: return out+ m = mask.astype(np.float32)+ if sigma is None: sigma = max(4.0, np.sqrt(m.sum()) / 7.0)+ pad = int(sigma * 3) + 4+ x0, y0, x1, y1 = max(0, bb[0] - pad), max(0, bb[1] - pad), min(self.W, bb[2] + pad), min(self.H, bb[3] + pad)+ mm = m[y0:y1, x0:x1]+ h = 0.45 * blur(mm, sigma * 0.33) + 0.35 * blur(mm, sigma * 0.7) + 0.2 * blur(mm, sigma * 1.4)+ gy, gx = np.gradient(h)+ k = sigma * 2.2+ nx, ny, nz = -gx * k, -gy * k, np.ones_like(h)+ nn = np.sqrt(nx * nx + ny * ny + nz * nz)+ L = np.asarray(light, np.float32); L = L / np.linalg.norm(L)+ lam = (nx * L[0] + ny * L[1] + nz * L[2]) / nn+ lam = np.clip((lam + wrap) / (1 + wrap), 0, 1)+ if flat: lam = lam * (1 - flat) + 0.5 * flat+ out[y0:y1, x0:x1] = lam+ return out * (m > 0.001)++ # ================================================================== stroke machinery+ def _sizes(self, spec, x, y, r):+ n = len(x)+ if callable(spec):+ return (np.asarray(spec(x, y), np.float32) * r.uniform(0.8, 1.2, n)).astype(np.float32)+ if np.ndim(spec) == 0: return np.full(n, float(spec), np.float32) * r.uniform(0.85, 1.15, n).astype(np.float32)+ return r.uniform(spec[0], spec[1], n).astype(np.float32)++ def _colours(self, spec, x, y, r):+ """'canvas' (the paint under the point) | paint | list of paints (picked at random) | (ramp, value field or+ f(x, y)) | f(x, y) -> (N, 3) | RGB"""+ n = len(x)+ if isinstance(spec, str) and spec == 'canvas': return _lookup(self.C, x, y).astype(np.float32).copy()+ if callable(spec): return np.asarray(spec(x, y), np.float32).reshape(n, 3).copy()+ if isinstance(spec, str): return np.broadcast_to(hexc(spec), (n, 3)).astype(np.float32).copy()+ if isinstance(spec, (tuple, list)) and len(spec) == 2 and (callable(spec[1]) or isinstance(spec[1], np.ndarray)):+ R = ramp(spec[0]); f = spec[1]+ v = f(x, y) if callable(f) else _lookup(f, x, y)+ return ramp_at(R, v).astype(np.float32)+ if isinstance(spec, (tuple, list)) and all(isinstance(c, str) for c in spec):+ R = ramp(list(spec))+ return R[r.integers(0, len(R), n)].astype(np.float32)+ return np.broadcast_to(hexc(spec), (n, 3)).astype(np.float32).copy()++ @staticmethod+ def _field_rad(field):+ """degrees -> radians for a number; a radians field or a callable f(x, y) -> degrees passes through (it is+ evaluated only at the points that need it)"""+ if callable(field): return field+ return np.float32(np.deg2rad(field)) if np.ndim(field) == 0 else field++ def _centrelines(self, x, y, L, field, jit, bend, k):+ """integrate k points through an orientation field from the centre outward (no flips)"""+ n = len(x)+ P = np.zeros((n, k, 2), np.float32)+ c = k // 2+ P[:, c, 0] = x; P[:, c, 1] = y+ st = L / (k - 1)+ a0 = _lookup(field, x, y) + jit+ d0 = np.stack([np.cos(a0), np.sin(a0)], 1).astype(np.float32)+ for sgn in (1, -1):+ px, py = x.copy(), y.copy()+ prev = d0 * sgn+ for j in range(1, (k - c) if sgn > 0 else (c + 1)):+ a = _lookup(field, px, py) + jit + sgn * bend * j+ v = np.stack([np.cos(a), np.sin(a)], 1).astype(np.float32)+ flip = (v * prev).sum(1) < 0+ v[flip] *= -1+ px = px + v[:, 0] * st; py = py + v[:, 1] * st+ P[:, c + sgn * j, 0] = px; P[:, c + sgn * j, 1] = py+ prev = v+ return P++ def _seed_points(self, M, bb, n_cells, r):+ """stratified (jittered-grid) candidate points over a box, accepted with probability M"""+ x0, y0, x1, y1 = bb+ bw, bh = x1 - x0, y1 - y0+ cell = max(1.0, np.sqrt(bw * bh / max(1, n_cells)))+ nx, ny = max(1, int(np.ceil(bw / cell))), max(1, int(np.ceil(bh / cell)))+ gx, gy = np.meshgrid(np.arange(nx, dtype=np.float32), np.arange(ny, dtype=np.float32))+ x = x0 + (gx.ravel() + r.random(nx * ny).astype(np.float32)) * cell+ y = y0 + (gy.ravel() + r.random(nx * ny).astype(np.float32)) * cell+ ok = (x < x1) & (y < y1)+ x, y = x[ok], y[ok]+ keep = r.random(len(x)) < _lookup(M, x, y)+ return x[keep], y[keep]++ def strokes(self, region, field=-60.0, colour='canvas', length=(30, 70), width=(8, 16), density=1.0,+ pressure=0.78, opacity=0.9, alpha=0.8, streak=0.45, soft=0.6, jitter=0.07, bend=0.03, value=0.035,+ hue=0.02, taper=(0.55, 0.1), passes=2, clip='auto', avoid=None, fade='auto', k=5, seed=None):+ """lay opaque dry strokes (gouache) or, thin and long, pencil hatching over `region` (a 0..1 landing-+ probability mask or a box) following `field` (degrees or a radians field). density ~ how many times the+ strokes would tile the region; length / width: (lo, hi), a number or f(x, y); colour: 'canvas' (the paint+ under each stroke's centre: a painterly repaint), a paint, a list of paints, (ramp, value field or f(x, y))+ or f(x, y) -> (N, 3); pressure: how deep the pigment reaches into the tooth; opacity: how much a pale stroke+ covers what is under it; streak: how much the bristle lanes open up as the stroke runs dry; soft: the soft+ fraction of the half-width; taper: pressure at (start, end); clip: a mask the strokes are cut to ('auto' =+ the region's support); fade: a 0..1 field easing the pressure off ('auto' = region ** 0.65); avoid: things+ to paint round. Returns the number of strokes."""+ self._need()+ r = self._r(seed)+ M = self._mask(region)+ if avoid is not None:+ keep = 1 - np.clip(avoid, 0, 1)+ M = M * keep+ bb = self._bbox(M)+ if bb is None: return 0+ x0, y0, x1, y1 = bb+ if float(M[y0:y1, x0:x1].sum()) < 1: return 0+ sx = r.uniform(x0, x1, 600).astype(np.float32); sy = r.uniform(y0, y1, 600).astype(np.float32)+ Lm = float(self._sizes(length, sx, sy, r).mean()); Wm = float(self._sizes(width, sx, sy, r).mean())+ n_cells = int(density * (x1 - x0) * (y1 - y0) / (0.8 * Lm * Wm)) + 1+ arr = isinstance(region, np.ndarray)+ x, y = self._seed_points(np.sqrt(M) if arr else M, bb, n_cells, r)+ n = len(x)+ if not n: return 0+ o = r.permutation(n); x, y = x[o], y[o]+ L = self._sizes(length, x, y, r); Wd = self._sizes(width, x, y, r)+ cols = self._colours(colour, x, y, r)+ if value: cols *= (1 + value * r.normal(0, 1, n).astype(np.float32))[:, None]+ if hue: cols = hue_rotate(cols, (hue * r.normal(0, 1, n)).astype(np.float32))+ cols = np.clip(cols, 0, 1)+ P = self._centrelines(x, y, L, self._field_rad(field), (jitter * r.normal(0, 1, n)).astype(np.float32),+ (bend * r.normal(0.6, 0.6, n)).astype(np.float32), k)+ if isinstance(clip, str) and clip == 'auto':+ clip = smoothstep(0.0, 0.08, M) if arr else None+ if avoid is not None:+ clip = keep if clip is None else clip * keep+ if isinstance(fade, str) and fade == 'auto':+ fade = (M ** 0.65) if arr else None+ pr = np.broadcast_to(np.asarray(pressure, np.float32), (n,)) * r.uniform(0.9, 1.06, n).astype(np.float32)+ al = np.broadcast_to(np.asarray(alpha, np.float32), (n,)) * r.uniform(0.82, 1.0, n).astype(np.float32)+ st = np.broadcast_to(np.asarray(streak, np.float32), (n,)) * r.uniform(0.6, 1.3, n).astype(np.float32)+ self._draw(P, Wd, cols, al, pr, taper, opacity, clip, passes, r, fade=fade, streak=st, soft=soft)+ self.n_strokes += n+ return n++ def lines(self, paths, colour='chalk', width=2.0, pressure=0.8, opacity=0.9, alpha=0.9, taper=(0.4, 0.2),+ streak=0.0, soft=0.5, value=0.03, hue=0.0, clip=None, fade=None, passes=1, k=None, seed=None):+ """draw explicit strokes: a list of polylines (each (m, 2)), resampled to k points each; painted in order+ (later on top) within each pass"""+ self._need()+ r = self._r(seed)+ if not len(paths): return 0+ if k is None: k = max(3, min(11, int(np.median([len(p) for p in paths]))))+ P = np.stack([_resample_k(np.asarray(p, np.float32), k) for p in paths]).astype(np.float32)+ n = len(P)+ mid = P[:, k // 2]+ Wd = self._sizes(width, mid[:, 0], mid[:, 1], r)+ cols = self._colours(colour, mid[:, 0], mid[:, 1], r)+ if value: cols *= (1 + value * r.normal(0, 1, n).astype(np.float32))[:, None]+ if hue: cols = hue_rotate(cols, (hue * r.normal(0, 1, n)).astype(np.float32))+ cols = np.clip(cols, 0, 1)+ pr = np.broadcast_to(np.asarray(pressure, np.float32), (n,)) * r.uniform(0.95, 1.04, n).astype(np.float32)+ al = np.broadcast_to(np.asarray(alpha, np.float32), (n,)).astype(np.float32)+ st = np.broadcast_to(np.asarray(streak, np.float32), (n,)).astype(np.float32)+ self._draw(P, Wd, cols, al, pr, taper, opacity, clip, passes, r, fade=fade, streak=st, soft=soft)+ self.n_strokes += n+ return n++ def _draw(self, P, Wd, cols, al, pr, taper, opacity, clip, passes, r, ss=2, fill=0.35, fade=None, streak=None,+ soft=0.45):+ n = len(P)+ tp = np.broadcast_to(np.asarray(taper, np.float32), (n, 2))+ st = np.zeros(n, np.float32) if streak is None else np.asarray(streak, np.float32)+ so = np.broadcast_to(np.asarray(soft, np.float32), (n,)) * r.uniform(0.8, 1.2, n).astype(np.float32)+ nb = np.clip(Wd / r.uniform(2.6, 4.2, n), 1.5, 9).astype(np.float32) # bristle lanes per stroke+ ph = r.uniform(0, 2 * np.pi, (n, 2)).astype(np.float32)+ passes = max(1, int(passes))+ my = P[:, P.shape[1] // 2, 1]+ for g in range(passes):+ sel = np.arange(g, n, passes)+ if not len(sel): continue+ # split a big pass into horizontal bands so the supersampled id map stays small+ lo = P[sel].reshape(-1, 2).min(0); hi = P[sel].reshape(-1, 2).max(0)+ area = (hi[0] - lo[0] + 2 * Wd.max()) * (hi[1] - lo[1] + 2 * Wd.max()) * ss * ss+ nband = int(np.clip(np.ceil(area / self.band_px), 1, 160))+ if nband > 1:+ edges = np.quantile(my[sel], np.linspace(0, 1, nband + 1))+ groups = [sel[(my[sel] >= edges[b]) & ((my[sel] < edges[b + 1]) | (b == nband - 1))]+ for b in range(nband)]+ else:+ groups = [sel]+ for gs in groups:+ if len(gs):+ self._raster(P[gs], Wd[gs], cols[gs], al[gs], pr[gs], tp[gs], opacity, clip, ss, fill, fade,+ st[gs], so[gs], nb[gs], ph[gs])++ def _raster(self, P, Wd, cols, al, pr, tp, opacity, clip, ss, fill, fade, st, so, nb, ph):+ n, k = P.shape[:2]+ ns = k - 1+ pad = float(Wd.max()) + 3+ lo = P.reshape(-1, 2).min(0) - pad; hi = P.reshape(-1, 2).max(0) + pad+ x0, y0 = max(0, int(np.floor(lo[0]))), max(0, int(np.floor(lo[1])))+ x1, y1 = min(self.W, int(np.ceil(hi[0]))), min(self.H, int(np.ceil(hi[1])))+ if x1 <= x0 or y1 <= y0: return+ w, h = x1 - x0, y1 - y0+ # segment tables (canvas units)+ A = P[:, :-1]; B = P[:, 1:]+ seg = B - A+ sl = np.linalg.norm(seg, axis=2) + 1e-4+ D = seg / sl[..., None]+ cum = np.cumsum(sl, axis=1) - sl+ LT = sl.sum(1)+ # draw every segment with its own id; segments are lengthened so a bend leaves no notch+ ext = np.minimum(Wd[:, None] * 0.35, sl * 0.5)[..., None] * D+ ext[:, -1] = 0+ A2 = (A - np.array([x0, y0], np.float32)) * ss+ B2 = (B + ext - np.array([x0, y0], np.float32)) * ss+ im = Image.new('I', (w * ss, h * ss), 0)+ d = ImageDraw.Draw(im)+ a2 = A2.tolist(); b2 = B2.tolist()+ wi = np.maximum(1, np.round(Wd * ss)).astype(np.int32).tolist()+ for i in range(n):+ ai, bi, wv = a2[i], b2[i], wi[i]+ base = i * ns + 1+ for j in range(ns):+ d.line((ai[j][0], ai[j][1], bi[j][0], bi[j][1]), fill=base + j, width=wv)+ flat = np.asarray(im, dtype=np.int32).ravel()+ nz = np.flatnonzero(flat).astype(np.int32)+ del im+ if not len(nz): return+ sid = flat[nz]+ del flat+ W2 = w * ss+ sy = nz // W2; sx = nz - sy * W2+ del nz+ si = np.r_[0, np.repeat(np.arange(n), ns)] # stroke of each segment (index 0 unused)+ z1 = lambda a: np.r_[0, np.asarray(a, np.float32).ravel()].astype(np.float32)+ AX, AY = z1(A[..., 0]), z1(A[..., 1])+ DX, DY = z1(D[..., 0]), z1(D[..., 1])+ SL, CU = z1(sl), z1(cum)+ ang = np.mod(np.arctan2(D[..., 1], D[..., 0]), np.pi).ravel()+ BIN = np.r_[0, (np.round(ang / np.pi * 8).astype(np.int32) % 8)]+ stk = si[sid].astype(np.int32)+ X = (sx.astype(np.float32) + 0.5) * (1.0 / ss) + x0; Y = (sy.astype(np.float32) + 0.5) * (1.0 / ss) + y0+ rx = X - AX[sid]; ry = Y - AY[sid]+ t = np.clip(rx * DX[sid] + ry * DY[sid], 0, SL[sid])+ u = np.clip((CU[sid] + t) / LT[stk], 0, 1)+ v = np.abs(rx * (-DY[sid]) + ry * DX[sid]) / (0.5 * Wd[stk] + 0.25)+ # pressure profile along the stroke, soft sides, bristle lanes that open as the stroke runs dry+ t0 = tp[stk, 0]; t1 = tp[stk, 1]+ prof = np.minimum(np.clip(t0 + (1 - t0) * u / 0.15, 0, 1), np.clip(t1 + (1 - t1) * (1 - u) / 0.45, 0, 1))+ # the ends are rounded off (a blunt start, a narrowing lift-off), not the square caps of a ruled line+ wf = 0.3 + 0.7 * np.sqrt(np.clip(np.minimum(u / 0.1, (1 - u) / 0.28), 0, 1))+ lat = smoothstep(1.0, 1.0 - so[stk], v / wf)+ sv = (rx * (-DY[sid]) + ry * DX[sid]) / (0.5 * Wd[stk] + 0.25)+ lane = 0.6 * (0.5 + 0.5 * np.sin(sv * nb[stk] * np.pi + ph[stk, 0])) + \+ 0.4 * (0.5 + 0.5 * np.sin(sv * nb[stk] * 2.3 * np.pi + ph[stk, 1]))+ p = pr[stk] * (0.55 + 0.45 * prof) * (1 - st[stk] * (1 - lane) * (0.3 + 0.7 * u))+ iy = y0 + sy // ss; ix = x0 + sx // ss+ if fade is not None:+ p = p * (0.4 + 0.6 * fade[iy, ix]) # a fading region also dries the stroke out+ Tt = self.TD[BIN[sid], iy, ix].astype(np.float32) * (1.0 / 255)+ catch = np.clip((Tt + fill * self.F[iy, ix] - (1 - p)) * 4.0 + 0.5, 0, 1)+ catch = self.floor * np.clip(p, 0, 1) + (1 - self.floor * np.clip(p, 0, 1)) * catch+ Aa = al[stk] * catch * lat * (0.45 + 0.55 * prof)+ pix = (sy // ss) * w + (sx // ss)+ npx = w * h+ k2 = 1.0 / (ss * ss)+ a1 = np.bincount(pix, Aa, npx).astype(np.float32) * k2+ c3 = np.empty((npx, 3), np.float32)+ for ch in range(3):+ c3[:, ch] = np.bincount(pix, Aa * cols[stk, ch], npx) * k2+ a1 = a1.reshape(h, w); c3 = c3.reshape(h, w, 3)+ if clip is not None:+ cf = clip[y0:y1, x0:x1]+ cf = np.clip((cf - 0.5) * 1.6 + 0.5 + 0.35 * self.EN[y0:y1, x0:x1] * (cf > 0.02) * (cf < 0.98), 0, 1)+ a1 = a1 * cf; c3 = c3 * cf[..., None]+ if fade is not None:+ ff = fade[y0:y1, x0:x1]+ a1 = a1 * ff; c3 = c3 * ff[..., None]+ m = a1 > 1e-4+ if not m.any(): return+ col = c3[m] / a1[m][:, None]+ Cb = self.C[y0:y1, x0:x1]+ old = Cb[m]+ tgt = (1 - opacity) * old * col + opacity * col+ Cb[m] = old + np.minimum(a1[m], 1)[:, None] * (tgt - old)+ Fb = self.F[y0:y1, x0:x1]+ Fb[m] = np.minimum(1.4, Fb[m] + a1[m] * 0.5)++ # ================================================================== smooth layers+ def _field_colour(self, colour, sl):+ """colour spec -> (h, w, 3) or (3,) for the slice: paint | (ramp, field) | array (H, W, 3) | f(X, Y)"""+ ys, xs = sl+ if isinstance(colour, np.ndarray) and colour.ndim == 3: return colour[ys, xs]+ if isinstance(colour, (tuple, list)) and len(colour) == 2 and isinstance(colour[1], np.ndarray):+ return ramp_at(ramp(colour[0]), colour[1][ys, xs])+ if callable(colour): return np.asarray(colour(self.XX[ys, xs], self.YY[ys, xs]), np.float32)+ return hexc(colour)++ def wash(self, mask, colour, alpha=1.0, grain=0.25, edge=0.5, dry=0.0, clip=None, opacity=1.0):+ """a smooth opaque coat over `mask`. colour: a paint, (ramp, 0..1 field), an (H, W, 3) array or f(X, Y).+ grain: the deepest pits of the tooth stay a little lighter; edge: within the soft rim of the mask the coat+ breaks up into the tooth; dry: the same over the whole area (a scumbled coat); opacity < 1 multiplies."""+ self._need()+ bb = self._bbox(mask)+ if bb is None: return+ x0, y0, x1, y1 = bb+ for ya in range(y0, y1, 240): # row bands keep the temporaries small+ self._wash_sl((slice(ya, min(y1, ya + 240)), slice(x0, x1)), mask, colour, alpha, grain, edge, dry, clip,+ opacity)++ def _wash_sl(self, sl, mask, colour, alpha, grain, edge, dry, clip, opacity):+ m = mask[sl].astype(np.float32)+ if clip is not None: m = m * clip[sl]+ Tt = self.T[sl]+ A = m * alpha+ if edge:+ rim = smoothstep(0.0, 0.85, m) * (1 - smoothstep(0.85, 1.0, m))+ br = smoothstep(0.35, 0.75, Tt + m * 0.55 - 0.15)+ A = A * (1 - edge * rim * (1 - br))+ if dry:+ A = A * (1 - dry * (1 - smoothstep(0.25, 0.65, Tt + (1 - dry) * 0.5)))+ if grain:+ A = A * (1 - grain * 0.35 * smoothstep(0.18, 0.0, Tt))+ col = self._field_colour(colour, sl)+ Cs = self.C[sl]+ if opacity < 1:+ col = (1 - opacity) * Cs * col + opacity * col+ Cs += (col - Cs) * A[..., None]+ np.clip(Cs, 0, 1, out=Cs)+ self.F[sl] = np.minimum(1.4, self.F[sl] + A * 0.6)++ def model(self, mask, colours, light=LIGHT, lit=None, sigma=None, wrap=0.3, gamma=1.0, lo=0.0, hi=1.0,+ alpha=1.0, grain=0.25, edge=0.5, clip=None, mottle=0.05, seed=None):+ """a softly modelled, simplified volume: a dome light (or `lit`) picks colours from a dark -> light ramp,+ mapped to lo..hi of the ramp, with a faint low-frequency mottle. Returns the light field."""+ if lit is None: lit = self.shading(mask, light, sigma, wrap)+ v = lo + (hi - lo) * np.clip(lit, 0, 1) ** gamma+ if mottle:+ bb = self._bbox(mask)+ if bb is not None:+ x0, y0, x1, y1 = bb+ nz = noise2d(y1 - y0, x1 - x0, 70, 3, int(self._r(seed).integers(1 << 30))) - 0.5+ v = v.copy(); v[y0:y1, x0:x1] += 2 * mottle * nz+ self.wash(mask, (colours, np.clip(v, 0, 1)), alpha, grain, edge, clip=clip)+ return lit++ def glaze(self, mask, colour, alpha=0.5, mode='multiply', soft=0.0):+ """a thin layer over what is there: 'multiply' (shadows), 'screen' (lights) or 'normal'"""+ m = self.soften(mask, soft) if soft else mask+ bb = self._bbox(m)+ if bb is None: return+ x0, y0, x1, y1 = bb+ sl = (slice(y0, y1), slice(x0, x1))+ A = m[sl] * alpha+ Cs = self.C[sl]+ col = hexc(colour)+ if mode == 'multiply': tgt = Cs * col+ elif mode == 'screen': tgt = 1 - (1 - Cs) * (1 - col)+ else: tgt = np.broadcast_to(col, Cs.shape)+ Cs += (tgt - Cs) * A[..., None]++ def dab(self, x, y, r, colour='white', alpha=0.95, soft=0.35, ry=None, rot=0.0):+ """a small soft round touch of opaque paint (catchlights, a glint, a glowing eye)"""+ ry = r if ry is None else ry+ R = max(r, ry)+ x0, x1 = max(0, int(x - R - 3)), min(self.W, int(x + R + 4))+ y0, y1 = max(0, int(y - R - 3)), min(self.H, int(y + R + 4))+ if x1 <= x0 or y1 <= y0: return+ c, s = np.cos(np.deg2rad(rot)), np.sin(np.deg2rad(rot))+ dx, dy = self.XX[y0:y1, x0:x1] - x, self.YY[y0:y1, x0:x1] - y+ dd = np.sqrt(((dx * c + dy * s) / r) ** 2 + ((-dx * s + dy * c) / ry) ** 2)+ A = smoothstep(1.0, max(0.0, 1.0 - soft - 0.6 / max(r, 1.0)), dd) * alpha+ Cs = self.C[y0:y1, x0:x1]+ Cs += (hexc(colour) - Cs) * A[..., None]++ # ================================================================== smooth painted lines+ def _lines_mask(self, paths, widths, taper=(0.15, 0.5), ss=3):+ """anti-aliased coverage of tapered polylines -> (slice, crop)"""+ allp = np.concatenate([np.asarray(p, np.float32) for p in paths])+ pad = float(np.max(widths)) + 3+ x0, x1 = max(0, int(allp[:, 0].min() - pad)), min(self.W, int(allp[:, 0].max() + pad) + 1)+ y0, y1 = max(0, int(allp[:, 1].min() - pad)), min(self.H, int(allp[:, 1].max() + pad) + 1)+ if x1 <= x0 or y1 <= y0: return None, None+ bw, bh = x1 - x0, y1 - y0+ ss = max(1, min(ss, 4096 // max(bw, bh)))+ im = Image.new('L', (bw * ss, bh * ss), 0)+ d = ImageDraw.Draw(im)+ o = np.array([x0, y0], np.float32)+ for i, Q in enumerate(paths):+ q = (np.asarray(Q, np.float32) - o) * ss+ n = len(q)+ if n < 2:+ rr = widths[i] * ss / 2+ d.ellipse([q[0, 0] - rr, q[0, 1] - rr, q[0, 0] + rr, q[0, 1] + rr], fill=255); continue+ tt = np.linspace(0, 1, n)+ prof = 0.15 + 0.85 * np.clip(np.minimum(tt / max(taper[0], 1e-3), (1 - tt) / max(taper[1], 1e-3)), 0, 1)+ ww = np.maximum(1, np.round(widths[i] * ss * prof)).astype(int)+ ql = [tuple(p) for p in q.tolist()]+ a = 0+ while a < n - 1:+ b = a + 1+ while b < n - 1 and ww[b] == ww[a]: b += 1+ d.line(ql[a:b + 1], fill=255, width=int(ww[a]), joint='curve' if ww[a] > 2 else None)+ a = b+ if widths[i] * ss > 4:+ for kk in (0, n - 1):+ rr = ww[kk] / 2+ d.ellipse([q[kk, 0] - rr, q[kk, 1] - rr, q[kk, 0] + rr, q[kk, 1] + rr], fill=255)+ cov = np.asarray(im.resize((bw, bh), Image.BOX), np.float32) / 255+ return (slice(y0, y1), slice(x0, x1)), cov++ def line(self, path, width, colour, alpha=1.0, taper=(0.2, 0.35), smooth=True, dry=0.0, clip=None):+ """a smooth line painted with a small round brush, tapering in and out (lid lines, a red rim, veins);+ dry > 0 lets it break up a little on the tooth"""+ self._need()+ Q = np.asarray(path, np.float32)+ if smooth and len(Q) > 2: Q = spline(Q, 8)+ sl, m = self._lines_mask([Q], [width], taper)+ if sl is None: return+ A = m * alpha+ if dry: A = A * smoothstep(0.15, 0.6, self.T[sl] + (1 - dry) * 0.55)+ if clip is not None: A = A * clip[sl]+ Cs = self.C[sl]+ Cs += (hexc(colour) - Cs) * A[..., None]++ def sketch(self, path, colour='chalk', width=1.8, alpha=0.6, pressure=0.6, seg=(40, 110), wobble=0.8,+ gaps=0.12, smooth=True, seed=None):+ """a light chalk underdrawing line on the dark board: several overlapping sketchy strokes, some left out"""+ r = self._r(seed)+ P = spline(path, 10) if (smooth and len(path) > 2) else np.asarray(path, np.float32)+ P = _resample(P, 2.0)+ if len(P) < 2: return 0+ paths = []+ i = 0+ while i < len(P) - 1:+ L = r.uniform(*seg) / 2.0+ j = min(len(P), int(i + L))+ q = P[i:j].copy()+ if len(q) >= 2:+ nn = np.array([-(q[-1, 1] - q[0, 1]), q[-1, 0] - q[0, 0]], np.float32)+ nn /= np.linalg.norm(nn) + 1e-6+ q += nn * (r.normal(0, wobble) + fbm1d(len(q), max(3, len(q) / 2), 2,+ int(r.integers(1 << 30)))[:, None] * wobble * 0.6)+ if not (gaps and r.random() < gaps): paths.append(q)+ i = max(i + 1, int(j - r.uniform(0.1, 0.3) * L))+ if not paths: return 0+ return self.lines(paths, colour, width, pressure, 0.9, alpha, (0.35, 0.2), soft=0.6,+ k=7, seed=int(r.integers(1 << 30)))++ # ================================================================== hair+ def strands(self, region, flow, colours, n=800, length=(40, 140), width=(1.0, 2.0), curl=0.0, jitter=6.0,+ step=4.0, shade=None, spread=0.2, alpha=0.9, pressure=0.92, opacity=0.95, taper=(0.3, 0.05),+ clip=True, pad=5.0, roots=None, lock=None, k=9, seed=None):+ """many fine strands (hair, ghost-sheet threads, fibres): each starts inside `region` (or `roots`), follows+ `flow` (degrees: a number, a canvas field in radians or f(x, y) -> degrees) with its own jitter and steady+ bend (`curl` degrees per step), drawn as a fine line pressed at the root and lifting off at the tip. Each+ picks a colour from `colours` (dark -> light) by the 0..1 field `shade` plus noise; dark first, light+ last. lock=(strands per lock, lock width px) groups them into locks sharing a root area, wander, curl and+ shade. clip=True keeps them within `pad` px of the region; False lets them fly loose; or a mask."""+ r = self._r(seed)+ src = roots if roots is not None else region+ bb = self._bbox(src, 0.5)+ if bb is None: return 0+ x0, y0, x1, y1 = bb+ sub = src[y0:y1, x0:x1] > 0.5+ idx = np.flatnonzero(sub)+ if not len(idx): return 0+ if lock:+ per, lw_ = lock+ nl = max(1, int(n / per))+ pick = r.choice(idx, nl)+ ly = (pick // sub.shape[1] + y0).astype(np.float32)+ lx = (pick % sub.shape[1] + x0).astype(np.float32)+ g = r.integers(0, nl, n)+ y = ly[g] + r.normal(0, lw_ * 0.5, n).astype(np.float32)+ x = lx[g] + r.normal(0, lw_ * 0.5, n).astype(np.float32)+ jit = (r.normal(0, jitter, nl)[g] + r.normal(0, jitter * 0.25, n)).astype(np.float32)+ bend = ((r.normal(0, 1, nl) * curl)[g] + r.normal(0, curl * 0.15 + 1e-6, n)).astype(np.float32)+ lshade = r.normal(0, spread, nl)[g] + r.normal(0, spread * 0.3, n)+ else:+ pick = r.choice(idx, n)+ y = (pick // sub.shape[1] + y0).astype(np.float32) + r.random(n).astype(np.float32)+ x = (pick % sub.shape[1] + x0).astype(np.float32) + r.random(n).astype(np.float32)+ jit = r.normal(0, jitter, n).astype(np.float32)+ bend = (r.normal(0, 1, n) * curl).astype(np.float32)+ lshade = r.normal(0, spread, n)+ lens = r.uniform(*length, n).astype(np.float32)+ nsteps = max(2, int(lens.max() / step) + 1)+ Xs = np.zeros((n, nsteps + 1), np.float32); Ys = np.zeros((n, nsteps + 1), np.float32)+ Xs[:, 0], Ys[:, 0] = x, y+ for s_ in range(nsteps):+ if callable(flow): a = np.asarray(flow(Xs[:, s_], Ys[:, s_]), np.float32)+ elif np.ndim(flow) == 2: a = np.rad2deg(_lookup(flow, Xs[:, s_], Ys[:, s_]))+ else: a = np.full(n, float(flow), np.float32)+ a = np.deg2rad(a + jit + bend * s_)+ Xs[:, s_ + 1] = Xs[:, s_] + np.cos(a) * step+ Ys[:, s_ + 1] = Ys[:, s_] + np.sin(a) * step+ npts = np.clip((lens / step).astype(int) + 1, 2, nsteps + 1)+ nc = len(colours)+ base = _lookup(shade, x, y) if shade is not None else np.full(n, 0.5, np.float32)+ cls = np.clip(np.floor((base + lshade) * nc), 0, nc - 1).astype(int)+ o = np.argsort(cls, kind='stable')+ paths = [np.stack([Xs[i, :npts[i]], Ys[i, :npts[i]]], 1) for i in o]+ R = ramp(list(colours))+ cols = R[cls[o]]+ if clip is True:+ cm = smoothstep(0.03, 0.3, self.soften(region, pad))+ elif clip is False or clip is None:+ cm = None+ else:+ cm = clip+ return self.lines(paths, lambda xx, yy, c=cols: c, width, pressure, opacity, alpha, taper, streak=0.0,+ soft=0.55, value=0.05, clip=cm, k=k, seed=int(r.integers(1 << 30)))++ def sheen(self, mask, flow, lit=None, band=(0.6, 0.78, 0.92), colour='hair_sheen', alpha=0.5, strokes=0.25,+ length=(60, 140), width=(1.2, 2.4), density=1.4, light=LIGHT, sigma=None, seed=None):+ """the soft sheen of a solid, sculpted hair mass: a smooth band of `colour` where the dome light sits in a+ narrow band (lo, peak, hi), brightest at the peak, then a few long thin strokes along the flow inside it+ (`strokes` their alpha) so the highlight is streaked along the hair without the mass breaking into+ strands. Returns the band field."""+ if lit is None: lit = self.shading(mask, light, sigma)+ lo, pk, hi = band+ b = smoothstep(lo, pk, lit) * smoothstep(hi + 0.02, pk, lit) * mask+ self.wash(self.soften(b, 2.0) * mask, colour, alpha, grain=0.2, edge=0.0)+ if strokes:+ self.strokes(b, flow, colour, length, width, density, pressure=0.62, opacity=0.95, alpha=strokes,+ streak=0.3, soft=0.8, taper=(0.25, 0.05), clip=mask, value=0.05, seed=seed)+ return b++ # ================================================================== faces+ def eye(self, cx, cy, rx, ry=None, iris='iris', iris_light='iris_light', iris_r=0.62, look=(0.0, 0.3), lid=0.5,+ lower=0.1, droop=0.3, lid_skin='porcelain', fold='#e2b5ad', line_colour='lid_line', line_w=None,+ rim='rim', rim_alpha=0.85, crease=0.45, catch=True, reflect=None, white='eye_white', shade='eye_shade',+ rot=0.0, side=1, clip=None):+ """a heavy-lidded, sad picture-book eye: an off-white ball shaded grey under the lid and at the corners, a+ dark iris (lighter low) with a pupil, a thick upper lid covering `lid` of the ball whose line droops toward+ the outer corner (`side` +1 = outer corner to the right; `droop` how much), the lid skin a modelled bulge+ flushed pink, a dark lid line, a red wet rim along the lower lid, a faint crease above, a small catchlight+ and, if `reflect` is a colour, a warm glint low in the iris (a light below her, mirrored in the eye).+ look = (dx, dy) in -1..1 moves the iris (dy > 0: looking down). Returns the visible-eye mask."""+ self._need()+ ry = rx * 0.62 if ry is None else ry+ a = np.deg2rad(rot); ca, sa = np.cos(a), np.sin(a)+ to = lambda u, v: (cx + u * ca - v * sa, cy + u * sa + v * ca)+ R = max(rx, ry) * 1.9 + 6+ x0, x1 = max(0, int(cx - R)), min(self.W, int(cx + R) + 1)+ y0, y1 = max(0, int(cy - R)), min(self.H, int(cy + R) + 1)+ sl = (slice(y0, y1), slice(x0, x1))+ X, Y = self.XX[sl], self.YY[sl]+ U = (X - cx) * ca + (Y - cy) * sa; V = -(X - cx) * sa + (Y - cy) * ca+ un = U / rx+ # an almond: the ball, cut by the upper lid line and the lower lid line+ ball = np.clip((1 - np.sqrt(un ** 2 + (V / ry) ** 2)) * min(rx, ry) + 0.5, 0, 1)+ vlid = -ry + 2 * ry * lid + ry * 0.2 * un ** 2 + droop * ry * 0.5 * (side * un)+ vlow = ry - 2 * ry * lower - ry * 0.18 * un ** 2 - droop * ry * 0.12 * (side * un)+ vis = ball * np.clip(V - vlid + 0.5, 0, 1) * np.clip(vlow - V + 0.5, 0, 1)+ if clip is not None: vis = vis * clip[sl]+ Cs = self.C[sl]+ # the white, grey under the lid and toward the corners+ q = np.clip((V - vlid) / (2 * ry), 0, 1)+ sideshade = np.clip(np.abs(un), 0, 1) ** 2.5+ sh_ = np.clip(0.9 * (1 - smoothstep(0.0, 0.55, q)) + 0.45 * sideshade, 0, 1)+ wf = hexc(white) + (hexc(shade) - hexc(white)) * sh_[..., None]+ Cs += (wf - Cs) * vis[..., None]+ # iris and pupil+ ir = iris_r * ry * 1.25+ iu, iv = look[0] * (rx - ir * 0.95), look[1] * (ry - ir * 0.5)+ ix, iy = to(iu, iv)+ dd = np.sqrt((X - ix) ** 2 + (Y - iy) ** 2) / ir+ im = np.clip((1 - dd) * ir + 0.5, 0, 1) * vis+ ic, il = hexc(iris), hexc(iris_light)+ qq = np.clip((Y - (iy - ir)) / (2 * ir), 0, 1)+ th = np.arctan2(Y - iy, X - ix)+ rad = 0.5 + 0.5 * np.sin(th * 21 + 1.3) * np.sin(th * 8 + 0.4)+ f = ic + (il - ic) * (smoothstep(0.45, 1.0, qq) * smoothstep(0.98, 0.4, dd) * (0.7 + 0.3 * rad))[..., None]+ f = f * (1 - 0.4 * smoothstep(0.7, 1.0, dd))[..., None]+ Cs += (f - Cs) * im[..., None]+ pm = np.clip((1 - dd / 0.45) * ir * 0.45 + 0.5, 0, 1) * vis+ Cs += (hexc('pupil') - Cs) * (pm * 0.95)[..., None]+ # the lid's shadow on the ball+ shadow = vis * smoothstep(vlid + ry * 0.55, vlid, V)+ Cs *= (1 - 0.42 * shadow[..., None] * (1 - hexc('#5e5a78')))+ # the heavy upper lid: a modelled bulge of flushed skin above the lid line+ bulge = np.clip((1 - np.sqrt((un / 1.12) ** 2 + ((V - vlid + ry * 0.05) / (ry * 0.95)) ** 2)) * ry + 0.5, 0, 1)+ bulge = bulge * np.clip(vlid - V + 0.5, 0, 1)+ if clip is not None: bulge = bulge * clip[sl]+ lt = np.clip(0.55 - 0.45 * ((V - vlid) / ry + 0.45) + 0.12 * (-un * np.sign(LIGHT[0])), 0, 1)+ lc = hexc(lid_skin) * (0.86 + 0.18 * lt)[..., None]+ lc = lc + (hexc(fold) - lc) * (0.55 * smoothstep(-ry * 0.9, 0, V - vlid))[..., None]+ Cs += (lc - Cs) * (bulge * 0.92)[..., None]+ np.clip(Cs, 0, 1, out=Cs)+ lw = max(1.8, ry * 0.2) if line_w is None else line_w+ us = np.linspace(-1.02, 1.02, 30)+ vl = -ry + 2 * ry * lid + ry * 0.2 * us ** 2 + droop * ry * 0.5 * (side * us)+ vb = ry - 2 * ry * lower - ry * 0.18 * us ** 2 - droop * ry * 0.12 * (side * us)+ ok = vl < vb + 1+ # the lower lid: a red wet rim, a lighter wet line just inside it+ lowp = [to(u * rx, v) for u, v in zip(us, vb)]+ self.line(lowp, max(1.6, lw * 0.75), rim, rim_alpha, taper=(0.3, 0.25))+ self.line([to(u * rx * 0.9, v - lw * 0.55) for u, v in zip(us, vb)], max(1.0, lw * 0.3), '#f0b8ad',+ 0.35, taper=(0.4, 0.4))+ # the lid line: thick in the middle, fine at the corners, a touch past the outer corner+ lidp = [to(u * rx, v - lw * 0.1) for u, v, o in zip(us, vl, ok) if o or abs(u) > 0.9]+ if len(lidp) > 2:+ self.line(lidp, lw, line_colour, 0.95, taper=(0.3, 0.2))+ if crease:+ cp = [to(u * rx * 1.04, v - ry * 0.95 - ry * 0.12 * (1 - u * u)) for u, v in zip(us[3:-2], vl[3:-2])]+ self.line(cp, max(1.0, lw * 0.4), 'crease', crease, taper=(0.5, 0.5), dry=0.3)+ if catch:+ cu, cv = iu - ir * 0.32, max(iv - ir * 0.25, -ry + 2 * ry * lid + ry * 0.12)+ self.dab(*to(cu, cv), max(1.2, ir * 0.13), '#f6f2ee', 0.85, soft=0.4)+ if reflect is not None:+ gx, gy = to(iu + ir * 0.22, min(iv + ir * 0.5, ry - 2 * ry * lower - ry * 0.3))+ self.dab(gx, gy, max(1.2, ir * 0.16), reflect, 0.8, soft=0.6, ry=max(1.0, ir * 0.1))+ out = np.zeros((self.H, self.W), np.float32); out[sl] = vis+ return out++ def flush(self, field, colour='flush', strength=0.6, speckle=0.55, clip=None):+ """the red flush on porcelain: a smooth glaze of `colour` over the 0..1 `field` plus a stipple that only+ catches the high points of the tooth (more of it where the flush is stronger) -- the speckled red"""+ self._need()+ bb = self._bbox(field)+ if bb is None: return+ x0, y0, x1, y1 = bb+ sl = (slice(y0, y1), slice(x0, x1))+ f = np.clip(field[sl], 0, 1)+ if clip is not None: f = f * clip[sl]+ Tt = self.ST[sl].astype(np.float32) * (1.0 / 255)+ smooth_ = f * strength * (1 - 0.5 * speckle)+ th = 1.0 - f * (0.3 + 0.55 * strength)+ stip = smoothstep(th, th + 0.08, Tt) * f ** 0.5 * speckle+ A = np.clip(smooth_ + stip * strength * 1.1, 0, 1)+ Cs = self.C[sl]+ col = hexc(colour)+ # a light flush reads as rosy, a strong one as red: keep the value of what is under it a little+ tgt = col * (0.8 + 0.25 * Cs.mean(-1, keepdims=True))+ Cs += (tgt - Cs) * A[..., None]+ np.clip(Cs, 0, 1, out=Cs)++ def nose(self, path, width=26.0, tip_r=None, side=1, shade=0.55, shadow='#8c7480', tip='flush',+ tip_strength=0.8, nostril=0.7, highlight=0.5, cast=0.35, clip=None):+ """a long, simplified nose down `path` (bridge -> tip): its own little volume -- a tube widening to a round+ tip, lit from the upper left, so the side away from the light (`side` +1 = right) is a soft mauve plane --+ a flush that strengthens toward a red tip, a soft shadow cast under the tip, a little nostril and a pale+ line of light down the bridge"""+ P = np.asarray(spline(np.asarray(path, np.float32), 10), np.float32)+ n = len(P)+ tp = P[-1]+ tip_r = width * 0.6 if tip_r is None else tip_r+ d = P[-1] - P[-2]; d /= np.linalg.norm(d) + 1e-6+ nrm = np.array([-d[1], d[0]], np.float32)+ if nrm[0] * side < 0: nrm = -nrm # nrm points to the shadow side+ m = np.maximum(self.tube(P, np.linspace(width * 0.45, width * 0.85, n)),+ self.ellipse(tp[0], tp[1], tip_r * 1.05, tip_r * 0.92))+ if clip is not None: m = m * clip+ lit = self.shading(m, LIGHT, sigma=width * 0.45, wrap=0.2)+ sh = self.soften(m, width * 0.12) * smoothstep(0.62, 0.25, lit)+ self.glaze(sh, shadow, shade, 'multiply')+ if cast:+ cs = self.soften(np.roll(np.roll(self.ellipse(tp[0], tp[1], tip_r * 1.1, tip_r * 0.8), int(tip_r * 0.7), 0),+ int(side * tip_r * 0.5), 1), tip_r * 0.4) * (1 - m)+ if clip is not None: cs = cs * clip+ self.glaze(cs, shadow, cast, 'multiply')+ f = np.zeros((self.H, self.W), np.float32)+ for i in range(0, n, 3):+ t = i / (n - 1)+ f = np.maximum(f, self.spot(P[i, 0], P[i, 1], width * (0.5 + 0.4 * t), width * (0.5 + 0.4 * t),+ solid=0.0, power=1.4) * (0.1 + 0.9 * t ** 2.4))+ f = np.maximum(f, self.spot(tp[0], tp[1], tip_r * 1.35, tip_r * 1.15, solid=0.3))+ if clip is not None: f = f * clip+ self.flush(f, tip, tip_strength, speckle=0.4)+ if nostril:+ self.line([tp + nrm * tip_r * 0.05 + d * tip_r * 0.62, tp + nrm * tip_r * 0.45 + d * tip_r * 0.7,+ tp + nrm * tip_r * 0.85 + d * tip_r * 0.4], max(1.2, width * 0.08), '#6e2a2c', nostril,+ taper=(0.4, 0.3))+ if highlight:+ hp = P[int(n * 0.1):int(n * 0.85)] - nrm * width * 0.16+ if len(hp) > 2: self.line(hp, max(1.5, width * 0.14), '#fbf4f0', highlight * 0.55, taper=(0.6, 0.6), dry=0.2)+ self.dab(*(tp - nrm * tip_r * 0.32 - d * tip_r * 0.28), max(1.2, tip_r * 0.22), '#ffe9e0', highlight,+ soft=0.7)++ def mouth(self, x, y, w=32.0, droop=0.15, colour='lip', dark='lip_dark', alpha=1.0, rot=0.0):+ """a small closed, unsmiling mouth: a thin upper lip, a slightly fuller lower lip, a dark parting line whose+ corners turn down by `droop`, a faint shadow under the lower lip"""+ h = w * 0.3+ c, s = np.cos(np.deg2rad(rot)), np.sin(np.deg2rad(rot))+ to = lambda pts: [(x + u * c - v * s, y + u * s + v * c) for u, v in pts]+ up = to([(-w * 0.5, droop * h), (-w * 0.22, -h * 0.42), (0, -h * 0.26), (w * 0.22, -h * 0.42),+ (w * 0.5, droop * h), (0, h * 0.06)])+ lo = to([(-w * 0.42, droop * h * 0.9), (-w * 0.15, h * 0.12), (w * 0.15, h * 0.12), (w * 0.42, droop * h * 0.9),+ (w * 0.2, h * 0.78), (-w * 0.2, h * 0.78)])+ self.wash(self.soften(self.poly(up, smooth=True), 0.8), mix(colour, dark, 0.3), 0.8 * alpha, grain=0.1, edge=0.2)+ self.wash(self.soften(self.poly(lo, smooth=True), 0.9), colour, 0.72 * alpha, grain=0.1, edge=0.2)+ self.dab(*to([(w * 0.04, h * 0.42)])[0], w * 0.12, '#efc1b8', 0.4 * alpha, ry=h * 0.12, soft=0.8, rot=rot)+ self.line(to([(-w * 0.52, droop * h * 1.5), (-w * 0.2, h * 0.04), (0, h * 0.08), (w * 0.2, h * 0.04),+ (w * 0.52, droop * h * 1.5)]), max(1.2, w * 0.05), dark, 0.8 * alpha, taper=(0.4, 0.4))+ sh = self.spot(*to([(0, h * 1.25)])[0], w * 0.3, h * 0.45, rot, solid=0.0)+ self.glaze(sh, 'porcelain_deep', 0.35 * alpha, 'multiply')++ # ================================================================== textiles+ def _lit_height(self, Hh, depth, light=LIGHT):+ hh = Hh * depth+ gy, gx = np.gradient(hh)+ Lv = np.asarray(light, np.float32); Lv = Lv / np.linalg.norm(Lv)+ nz = 1 / np.sqrt(gx * gx + gy * gy + 1)+ return np.clip((-gx * Lv[0] - gy * Lv[1] + Lv[2]) * nz, 0, 1)++ def _coords(self, sl, angle, coords):+ if coords is not None:+ return coords[0][sl].astype(np.float32), coords[1][sl].astype(np.float32)+ X, Y = self.XX[sl], self.YY[sl]+ a = np.deg2rad(angle); c, s = np.cos(a), np.sin(a)+ return X * c + Y * s, -X * s + Y * c++ def burlap(self, mask, angle=0.0, period=9.0, coords=None, thread=0.66, slub=0.4, wander=0.18, holes=0.85,+ hole_colour='#0a0807', strength=0.9, highlight=0.4, rust=0.0, fibres=1.0, fuzz=1.0, light=LIGHT,+ seed=None):+ """coarse burlap (hessian) multiplied onto the paint that is there: a plain weave of slubby threads -- each+ row and column its own thickness, lumps along it, rows and columns wandering a little, over-under+ alternation -- lit as a height field, dark holes between the threads, a share `rust` of rust-coloured+ threads (0 by default: whole rust threads read as seams), loose fibres on the surface and sticking out of+ the silhouette. coords = (U, V) canvas arrays (px) to make the+ weave follow a shape; else the canvas rotated by `angle`."""+ r = self._r(seed)+ bb = self._bbox(mask, pad=2)+ if bb is None: return+ x0, y0, x1, y1 = bb+ sl = (slice(y0, y1), slice(x0, x1))+ h, w = y1 - y0, x1 - x0+ U, V = self._coords(sl, angle, coords)+ sd = float(r.integers(1, 9999))+ nU = noise2d(h, w, period * 9, 2, int(r.integers(1 << 30))) - 0.5+ nV = noise2d(h, w, period * 9, 2, int(r.integers(1 << 30))) - 0.5+ Up = U / period + wander * 2 * nU+ Vp = V / period + wander * 2 * nV+ i = np.floor(Vp + 0.5); fv = Vp - i # nearest row (weft) and the offset from it+ k = np.floor(Up + 0.5); fu = Up - k # nearest column (warp)++ def slubs(idx, along):+ # thickness lumps along a thread: a hash per thread, interpolated every ~3 periods+ a = along / 3.0+ a0 = np.floor(a); t = a - a0+ t = t * t * (3 - 2 * t)+ return (1 - t) * _hash(idx + sd, a0) + t * _hash(idx + sd, a0 + 1)+ hw_r = 0.5 * thread * (0.82 + 0.36 * _hash(i, sd + 0.5)) * (1 + slub * (slubs(i, Up) - 0.5))+ hw_c = 0.5 * thread * (0.82 + 0.36 * _hash(k + 0.31, sd)) * (1 + slub * (slubs(k + 77.0, Vp) - 0.5))+ pr = np.sqrt(np.clip(1 - (fv / hw_r) ** 2, 0, 1))+ pc = np.sqrt(np.clip(1 - (fu / hw_c) ** 2, 0, 1))+ # over / under: a row is on top of a column where (row + column) is even+ hr = pr * (0.7 + 0.3 * np.cos(np.pi * (Up + i)))+ hc = pc * (0.7 + 0.3 * np.cos(np.pi * (Vp + k + 1)))+ top_r = hr >= hc+ Hh = np.maximum(hr, hc)+ lam = self._lit_height(Hh, period * 0.55, light)+ ao = 0.3 + 0.7 * smoothstep(0.0, 0.6, Hh)+ tj = np.where(top_r, _hash(i, sd + 3.1), _hash(k, sd + 5.7)) - 0.5 # every thread its own value+ kf = ao * (0.55 + 0.75 * lam) * (1 + 0.28 * tj)+ kf = kf * (1 + 0.12 * (noise2d(h, w, 1.5, 2, int(r.integers(1 << 30))) - 0.5)) # the hairy fibre+ m = mask[sl]+ mk = float((kf * m).sum() / (m.sum() + 1e-6))+ kf = kf / max(mk, 1e-3)+ Cs = self.C[sl]+ Cs *= (1 + strength * (kf - 1) * m)[..., None]+ if rust:+ rt = (np.where(top_r, _hash(i, sd + 9.3), _hash(k, sd + 2.2)) < rust) * smoothstep(0.2, 0.6, Hh) * m+ Cs += (hexc('burlap_rust') * kf[..., None] * 0.8 - Cs) * (rt * 0.55)[..., None]+ hole = (1 - smoothstep(0.0, 0.3, Hh)) * m * holes+ Cs += (hexc(hole_colour) - Cs) * hole[..., None]+ if highlight:+ hl = smoothstep(0.62, 0.92, lam * Hh) * smoothstep(0.45, 0.65, self.T[sl] + 0.1) * m+ Cs += (np.clip(Cs * 1.35 + 0.05, 0, 1) - Cs) * (hl * highlight)[..., None]+ np.clip(Cs, 0, 1, out=Cs)+ if fibres:+ mean = (Cs * m[..., None]).sum((0, 1)) / (m.sum() + 1e-6)+ nf = int(m.sum() / 260 * fibres)+ if nf > 0:+ sub = np.zeros((self.H, self.W), np.float32); sub[sl] = m+ self.strands(sub, angle if coords is None else 0.0, [mean * 1.25 + 0.02, mean * 1.6 + 0.04],+ n=nf, length=(4, 14), width=(0.6, 1.0), step=1.5, jitter=70, curl=14, alpha=0.45,+ clip=sub, seed=int(r.integers(1 << 30)))+ if fuzz:+ sub = np.zeros((self.H, self.W), np.float32); sub[sl] = m+ self.fuzz(sub, (4, 12), n=int(np.sqrt(m.sum()) * 2.2 * fuzz), width=(0.7, 1.1), out=0.6, alpha=0.6,+ lift=0.25, curl=18, seed=int(r.integers(1 << 30)))++ def along(self, path, mask, pad=4):+ """(S, T) canvas arrays round `mask`: arc length along `path` of the nearest point and the signed offset from+ it (px) -- coordinates that bend with a tube (a drooping hat tip, a scarf) for burlap(), tartan() or knit()"""+ bb = self._bbox(mask, pad=pad)+ S = np.zeros((self.H, self.W), np.float32); T = np.zeros((self.H, self.W), np.float32)+ if bb is None: return S, T+ x0, y0, x1, y1 = bb+ sl = (slice(y0, y1), slice(x0, x1))+ Q = np.asarray(spline(np.asarray(path, np.float32), 8) if len(path) > 2 else path, np.float32)+ S[sl], T[sl] = self._path_st(Q, sl)+ return S, T++ def _path_st(self, Q, sl):+ """for every pixel in sl: arc length of the nearest point on polyline Q and the signed offset"""+ X = self.XX[sl]; Y = self.YY[sl]+ seg = Q[1:] - Q[:-1]+ Ls = np.hypot(seg[:, 0], seg[:, 1]) + 1e-6+ cum = np.concatenate([[0], np.cumsum(Ls)])+ best = np.full(X.shape, 1e12, np.float32); S = np.zeros_like(X); Tt = np.zeros_like(X)+ for k in range(len(seg)):+ dx, dy = seg[k] / Ls[k]+ rx, ry = X - Q[k, 0], Y - Q[k, 1]+ a = np.clip(rx * dx + ry * dy, 0, Ls[k])+ px, py = rx - a * dx, ry - a * dy+ d2 = px * px + py * py+ m = d2 < best+ best = np.where(m, d2, best)+ S = np.where(m, cum[k] + a, S)+ Tt = np.where(m, -rx * dy + ry * dx, Tt)+ return S, Tt++ def knit(self, mask, stitch=(16, 12), angle=0.0, path=None, origin=None, curve=0.0, strength=0.8,+ highlight=0.3, fuzz=0.6, depth=0.5, light=LIGHT, seed=None):+ """chunky stockinette (rows of V stitches) multiplied onto the paint that is there. Each leg of a V is a+ rotated ellipse with a cylinder profile and faint ply grooves, the valleys between legs dark; lit as a+ height field. path: the stitch columns run along a polyline (a scarf); else rows are rotated by `angle`+ and bow by `curve` rows at the sides of `origin`."""+ r = self._r(seed)+ bb = self._bbox(mask, pad=1)+ if bb is None: return+ x0, y0, x1, y1 = bb+ sl = (slice(y0, y1), slice(x0, x1))+ sw, sh = stitch+ if path is not None:+ Q = np.asarray(spline(np.asarray(path, np.float32), 8) if len(path) > 2 else path, np.float32)+ S, Tt = self._path_st(Q, sl)+ Xr, Yr = Tt, S+ ox, hw = 0.0, 1.0+ else:+ Xr, Yr = self._coords(sl, angle, None)+ ox = (origin[0] if origin is not None else (x0 + x1) / 2)+ if angle:+ a = np.deg2rad(angle); ox = ox * np.cos(a) + (origin[1] if origin is not None else (y0 + y1) / 2) * np.sin(a)+ hw = max(1.0, (x1 - x0) / 2)+ U = (Xr - ox) / sw + 0.5+ V = Yr / sh + curve * ((Xr - ox) / hw) ** 2+ iu = np.floor(U); fu = U - iu - 0.5+ Hh = np.zeros_like(U); win_v = np.zeros_like(U)+ legd = np.array([0.44 * sw, 1.1 * sh]); legl = float(np.linalg.norm(legd))+ a_ = 0.5 * legl; b_ = 0.215 * sw+ for dv in (-1, 0, 1):+ iv = np.floor(V) + dv+ hj1 = _hash(iu + 0.37, iv) - 0.5; hj2 = _hash(iu, iv + 0.71) - 0.5; hj3 = _hash(iu + 0.13, iv + 0.29)+ fv = V - iv - 0.5 - hj2 * 0.12+ px, py = (fu - hj1 * 0.10) * sw, fv * sh+ sc = 0.9 + 0.2 * hj3+ for sd in (-1, 1):+ dx, dy = -sd * legd[0] / legl, legd[1] / legl+ rx_, ry_ = px - sd * 0.235 * sw, py+ al = rx_ * dx + ry_ * dy+ ac = -rx_ * dy + ry_ * dx+ e = (al / (a_ * sc)) ** 2 + (ac / (b_ * sc)) ** 2+ hl = np.sqrt(np.clip(1 - e, 0, 1))+ hl = hl * (0.86 + 0.14 * np.sin((al / a_ * 2.6 + ac / b_ * 0.9) * np.pi + hj3 * 3))+ hl = hl * (1.0 + 0.06 * dv)+ win = hl > Hh+ Hh = np.where(win, hl, Hh); win_v = np.where(win, iv, win_v)+ jit = _hash(iu, win_v) - 0.5+ lam = self._lit_height(Hh, depth * sw, light)+ ao = 0.38 + 0.62 * smoothstep(0.0, 0.55, Hh)+ kf = ao * (0.55 + 0.75 * lam) * (1 + 0.16 * jit)+ h, w = kf.shape+ kf = blur(kf, 0.55)+ if fuzz:+ kf = kf * (1 + fuzz * 0.12 * (noise2d(h, w, 1.6, 2, int(r.integers(1 << 30))) - 0.5))+ m = mask[sl]+ kf = kf / max(float((kf * m).sum() / (m.sum() + 1e-6)), 1e-3)+ Cs = self.C[sl]+ Cs *= (1 + strength * (kf - 1) * m)[..., None]+ if highlight:+ hl = smoothstep(0.62, 0.9, lam * Hh) * smoothstep(0.45, 0.65, self.T[sl] + 0.1) * m+ Cs += (np.clip(Cs * 1.25 + 0.05, 0, 1) - Cs) * (hl * highlight)[..., None]+ np.clip(Cs, 0, 1, out=Cs)++ def rib(self, mask, path, period=9.0, strength=0.75, highlight=0.25, rows=0.85, light=LIGHT):+ """ribbing across a band (a cuff, a hem): raised knit columns and sunken purl columns at right angles to+ `path` (the band's centre line), with small chevrons of stitches along each column"""+ bb = self._bbox(mask, pad=1)+ if bb is None: return+ x0, y0, x1, y1 = bb+ sl = (slice(y0, y1), slice(x0, x1))+ Q = np.asarray(path, np.float32)+ if len(Q) > 2: Q = spline(Q, 8)+ S, Tt = self._path_st(Q, sl)+ ph = S / period+ f = ph - np.floor(ph) - 0.5+ Hh = np.sqrt(np.clip(1 - (f / 0.34) ** 2, 0, 1))+ if rows:+ g = Tt / (period * 0.62) + np.abs(f) * 1.4+ Hh = Hh * (1 - 0.22 * rows + 0.22 * rows * np.abs(np.cos(g * np.pi)))+ lam = self._lit_height(Hh, period * 0.45, light)+ kf = (0.42 + 0.58 * smoothstep(0, 0.5, Hh)) * (0.55 + 0.75 * lam)+ m = mask[sl]+ kf = kf / max(float((kf * m).sum() / (m.sum() + 1e-6)), 1e-3)+ Cs = self.C[sl]+ Cs *= (1 + strength * (kf - 1) * m)[..., None]+ if highlight:+ hl = smoothstep(0.6, 0.92, lam * Hh) * smoothstep(0.45, 0.65, self.T[sl] + 0.1) * m+ Cs += (np.clip(Cs * 1.2 + 0.05, 0, 1) - Cs) * (hl * highlight)[..., None]+ np.clip(Cs, 0, 1, out=Cs)++ def tartan(self, mask, sett, scale=3.0, angle=0.0, coords=None, lit=None, lo=0.35, hi=1.05, alpha=1.0,+ threadshade=0.22, fuzz=0.5, gamma=1.0, seed=None):+ """a tartan cloth: `sett` is the half-sett [(colour, threads), ...] mirrored into a symmetric repeat, each+ thread `scale` px wide; woven 2/2 twill, so at every cell either the warp or the weft colour shows by a+ diagonal rule, and every thread is a little rounded (darker at its sides). The cloth colour is multiplied by+ lo..hi of the light field `lit` (the folds) and laid as an opaque coat. coords = (U, V) canvas arrays (px)+ to make the checks follow the folds; else the canvas rotated by `angle`."""+ r = self._r(seed)+ bb = self._bbox(mask, pad=1)+ if bb is None: return+ x0, y0, x1, y1 = bb+ sl = (slice(y0, y1), slice(x0, x1))+ h, w = y1 - y0, x1 - x0+ half = []+ for c, nthr in sett: half += [hexc(c)] * int(nthr)+ full = np.array(half + half[::-1], np.float32)+ per = len(full)+ U, V = self._coords(sl, angle, coords)+ uu, vv = U / scale, V / scale+ iu = np.floor(uu).astype(np.int64); iv = np.floor(vv).astype(np.int64)+ warp = full[np.mod(iu, per)]; weft = full[np.mod(iv, per)]+ show_warp = (np.mod(iu + iv, 4) < 2)[..., None]+ fu = uu - iu; fv = vv - iv+ rw = 1 - threadshade * (1 - np.sin(np.pi * fu)) ** 2+ rf = 1 - threadshade * (1 - np.sin(np.pi * fv)) ** 2+ col = np.where(show_warp, warp * rw[..., None], weft * rf[..., None])+ col = np.stack([blur(col[..., c], 0.45) for c in range(3)], -1)+ if fuzz:+ col = col * (1 + fuzz * 0.16 * (noise2d(h, w, 1.4, 2, int(r.integers(1 << 30))) - 0.5))[..., None]+ if lit is not None:+ col = col * (lo + (hi - lo) * np.clip(lit[sl], 0, 1) ** gamma)[..., None]+ m = mask[sl] * alpha+ Cs = self.C[sl]+ Cs += (np.clip(col, 0, 1) - Cs) * m[..., None]+ np.clip(Cs, 0, 1, out=Cs)+ self.F[sl] = np.minimum(1.4, self.F[sl] + m * 0.6)++ def fuzz(self, mask, length=(6, 16), n=None, width=(0.8, 1.3), out=0.7, field=None, alpha=0.7, lift=0.08,+ band=2.5, inset=4.0, curl=8.0, light=None, seed=None):+ """fibres growing out of a silhouette (wool, felt, burlap, a ghost's sheet): short strands rooted just inside+ the edge of `mask`, leaning outward (`out` 0..1 blends the outward normal with `field`), each coloured from+ the paint a few px inside it (lifted a touch, more on the lit side), so the edge is soft and hairy"""+ r = self._r(seed)+ b = self.soften(mask, band)+ rim = (smoothstep(0.35, 0.6, b) * smoothstep(0.98, 0.75, b))+ bb = self._bbox(rim, 0.3)+ if bb is None: return 0+ x0, y0, x1, y1 = bb+ sub = rim[y0:y1, x0:x1] > 0.3+ idx = np.flatnonzero(sub)+ if not len(idx): return 0+ if n is None: n = int(len(idx) / 6)+ if n <= 0: return 0+ pick = r.choice(idx, n)+ y = (pick // sub.shape[1] + y0).astype(np.float32) + r.random(n).astype(np.float32)+ x = (pick % sub.shape[1] + x0).astype(np.float32) + r.random(n).astype(np.float32)+ g = self.soften(mask, 5.0)+ gy, gx = np.gradient(g)+ ox, oy = -_lookup(gx, x, y), -_lookup(gy, x, y)+ on = np.sqrt(ox * ox + oy * oy) + 1e-6+ ox, oy = ox / on, oy / on+ if field is not None:+ fa = _lookup(self._field_rad(field), x, y)+ fx, fy = np.cos(fa), np.sin(fa)+ flip = (fx * ox + fy * oy) < 0+ fx[flip] *= -1; fy[flip] *= -1+ ox, oy = out * ox + (1 - out) * fx, out * oy + (1 - out) * fy+ ang = np.degrees(np.arctan2(oy, ox)).astype(np.float32)+ sx_ = np.clip(x - ox * inset, 0, self.W - 1).astype(int); sy_ = np.clip(y - oy * inset, 0, self.H - 1).astype(int)+ col = self.C[sy_, sx_].copy()+ lf = np.full((n, 1), lift, np.float32)+ if light is not None:+ L2 = np.asarray(light[:2], np.float32); L2 /= np.linalg.norm(L2)+ lf = lf * (1 + 1.5 * np.clip(ox * L2[0] + oy * L2[1], 0, 1))[:, None]+ col = np.clip(col * (1 + lf) + 0.015, 0, 1).astype(np.float32)+ lens = r.uniform(*length, n).astype(np.float32)+ k = 6+ a0 = np.deg2rad(ang + r.normal(0, 16, n))[:, None]; cv = np.deg2rad(r.normal(0, curl, n))[:, None]+ j = np.arange(k, dtype=np.float32)[None]+ st = (lens / (k - 1))[:, None]+ dx = np.cumsum(np.c_[np.zeros(n), (np.cos(a0 + cv * j[:, :-1]) * st)], 1)+ dy = np.cumsum(np.c_[np.zeros(n), (np.sin(a0 + cv * j[:, :-1]) * st)], 1)+ paths = [np.stack([x[i] + dx[i], y[i] + dy[i]], 1).astype(np.float32) for i in range(n)]+ return self.lines(paths, lambda xx, yy, c=col: c, width, 0.9, 0.95, alpha, (0.6, 0.0), soft=0.55,+ value=0.04, k=k, seed=int(r.integers(1 << 30)))++ # ================================================================== foliage+ def leaf(self, x, y, size, angle=-90.0, colours='leaf', value=0.5, fold=0.16, lit=0.0, rec=1.0, alpha=1.0,+ veins=0.45, lobes=5, mottle=0.08, squash=0.55, shadow=0.5, seed=None):+ """a palmate, serrated (maple-like) leaf whose veins meet at (x, y), main lobe toward `angle`, foreshortened+ by up to `squash` (seen at an angle): each lobe is folded along its midrib (one half lighter by `fold`),+ lighter toward the tips, mottled, with pale veins; first it casts a soft shadow (`shadow`) down and to the+ right on what is behind, which gives a hedge its depth. lit > 0 lights it by the light map (a leaf near a+ ghost turns warm). Returns the outline points."""+ r = self._r(seed)+ pts, tips = _maple(size, angle, r, lobes)+ if squash < 1: # seen at an angle: squashed along a random axis+ sa = r.uniform(0, np.pi); k = r.uniform(squash, 1.0)+ Rm = np.array([[np.cos(sa), -np.sin(sa)], [np.sin(sa), np.cos(sa)]], np.float32)+ S = Rm @ np.diag([1.0, k]).astype(np.float32) @ Rm.T+ pts = pts @ S.T; tips = tips @ S.T+ pts = pts + np.array([x, y], np.float32)+ if shadow:+ off = np.array([size * 0.07, size * 0.11], np.float32)+ s2, ms = self._poly_crop(pts + off)+ if s2 is not None:+ k = max(1.0, size * 0.06)+ ys, xs = s2+ pad = int(3 * k) + 2+ y0, y1 = max(0, ys.start - pad), min(self.H, ys.stop + pad)+ x0, x1 = max(0, xs.start - pad), min(self.W, xs.stop + pad)+ big = np.zeros((y1 - y0, x1 - x0), np.float32)+ big[ys.start - y0:ys.stop - y0, xs.start - x0:xs.stop - x0] = ms+ Cs = self.C[y0:y1, x0:x1]+ Cs *= (1 - shadow * blur(big, k))[..., None]+ sl, m = self._poly_crop(pts)+ if sl is None: return pts+ X, Y = self.XX[sl], self.YY[sl]+ dx, dy = X - x, Y - y+ rad = np.sqrt(dx * dx + dy * dy) / size+ phi = np.arctan2(dy, dx)+ ta = np.arctan2(tips[:, 1], tips[:, 0])+ dif = _wrap(phi[..., None] - ta[None, None, :])+ near = np.argmin(np.abs(dif), -1)+ side = np.sign(np.take_along_axis(dif, near[..., None], -1)[..., 0])+ s = 1.0 if r.random() < 0.5 else -1.0+ h, w = m.shape+ mot = noise2d(h, w, max(4, size * 0.3), 2, int(r.integers(1 << 30))) - 0.5+ v = value + fold * 0.5 * side * s + 0.16 * (rad - 0.45) + mottle * 2 * mot+ col = ramp_at(ramp(colours), v)+ Cs = self.C[sl]+ A = m * alpha+ Cs += (col - Cs) * A[..., None]+ # veins: a pale midrib to every lobe, a few side veins+ vc = ramp_at(ramp(colours), min(1.0, value + 0.3))+ if veins:+ for (tx, ty) in tips:+ self.line([(x, y), (x + tx * 0.5, y + ty * 0.5), (x + tx * 0.92, y + ty * 0.92)], max(0.9, size * 0.018),+ vc, veins * alpha, taper=(0.1, 0.8))+ L = np.hypot(tx, ty); d = np.array([tx, ty]) / (L + 1e-6); nrm = np.array([-d[1], d[0]])+ for t in (0.38, 0.62):+ for sg in (-1, 1):+ p0 = np.array([x, y]) + d * L * t+ p1 = p0 + (d * 0.7 + nrm * sg * 0.7) * L * 0.22+ self.line([p0, p1], max(0.7, size * 0.01), vc, veins * 0.6 * alpha, taper=(0.1, 0.8))+ if lit:+ self._illuminate_sl(sl, A * rec * lit, 1.0, 0.3, 1.8)+ np.clip(Cs, 0, 1, out=Cs)+ return pts++ def foliage(self, region, n=200, size=(60, 120), colours=('leaf',), value=(0.25, 0.7), angle=(-180, 180),+ fold=0.16, lit=0.0, veins=0.45, depth_size=0.4, squash=0.55, shadow=0.5, seed=None):+ """scatter `n` leaves over `region` (a 0..1 probability mask) back to front: each draws a depth; deeper+ leaves are smaller and darker; colours is a list of ramps picked at random; angle is the range of the main+ lobe's direction (degrees)"""+ r = self._r(seed)+ M = self._mask(region)+ bb = self._bbox(M)+ if bb is None: return 0+ x0, y0, x1, y1 = bb+ xs, ys = [], []+ tries = 0+ while len(xs) < n and tries < 60:+ cx = r.uniform(x0, x1, n * 3); cy = r.uniform(y0, y1, n * 3)+ ok = r.random(n * 3) < _lookup(M, cx, cy)+ xs += list(cx[ok]); ys += list(cy[ok]); tries += 1+ xs, ys = np.array(xs[:n]), np.array(ys[:n])+ depth = np.sort(r.random(len(xs)))+ o = r.permutation(len(xs))+ xs, ys = xs[o], ys[o]+ for i in range(len(xs)):+ d = depth[i]+ sz = r.uniform(*size) * (1 - depth_size + depth_size * d)+ v = value[0] + (value[1] - value[0]) * d + r.normal(0, 0.05)+ c = colours[int(r.integers(len(colours)))]+ self.leaf(xs[i], ys[i], sz, r.uniform(*angle), c, v, fold, lit, 1.0, 1.0, veins, squash=squash,+ shadow=shadow, seed=int(r.integers(1 << 30)))+ return len(xs)++ # ================================================================== light+ def light(self, x, y, r, colour=GLOW, power=1.0, squash=1.0, fall=2.0):+ """register a warm point light (falloff 1 / (1 + (d / r)^2)^fall -- steep, so a small ghost lights only+ what is near it; squash < 1 flattens it vertically)"""+ self.lights.append((float(x), float(y), float(r), hexc(colour), float(power), float(squash), float(fall)))+ self._L = None++ def lightmap(self):+ if self._L is None:+ L = np.zeros((self.H, self.W, 3), np.float32)+ for (x, y, rr, col, pw, sq, fa) in self.lights:+ d2 = ((self.XX - x) / rr) ** 2 + ((self.YY - y) / (rr * sq)) ** 2+ L += (pw / (1 + d2) ** fa)[..., None] * col+ self._L = L+ return self._L++ def _illuminate_sl(self, sl, rec, gain, base, albedo):+ L = self.lightmap()[sl]+ Cs = self.C[sl]+ l = L * (rec * gain)[..., None]+ Cs[:] = 1 - (1 - Cs) * np.exp(-l * (base + albedo * Cs))++ def illuminate(self, receptivity=1.0, gain=1.0, base=0.3, albedo=1.6, rows=270):+ """light what is painted by the registered lights: C <- 1 - (1 - C) exp(-L x receptivity x (base + albedo C)).+ receptivity: a number or a canvas field (what faces the light, what is near it)"""+ self.lightmap()+ for y0 in range(0, self.H, rows):+ sl = (slice(y0, min(self.H, y0 + rows)), slice(0, self.W))+ rec = receptivity[sl] if isinstance(receptivity, np.ndarray) else np.full((sl[0].stop - y0, self.W),+ float(receptivity), np.float32)+ self._illuminate_sl(sl, rec, gain, base, albedo)++ def emit(self, x, y, r, power=1.0, ry=None, rot=0.0):+ """add a soft spot to the emission buffer (bloomed in render: the halo of a glowing eye or tip)"""+ ry = r if ry is None else ry+ R = max(r, ry) * 2.2+ x0, x1 = max(0, int(x - R)), min(self.W, int(x + R) + 1)+ y0, y1 = max(0, int(y - R)), min(self.H, int(y + R) + 1)+ if x1 <= x0 or y1 <= y0: return+ c, s = np.cos(np.deg2rad(rot)), np.sin(np.deg2rad(rot))+ dx, dy = self.XX[y0:y1, x0:x1] - x, self.YY[y0:y1, x0:x1] - y+ d2 = ((dx * c + dy * s) / r) ** 2 + ((-dx * s + dy * c) / ry) ** 2+ self.E[y0:y1, x0:x1] += power * np.exp(-d2 * 1.6)+ self._bloom = None++ # ================================================================== ghosts+ def ghost(self, cx, top, w, h, look=(0.0, 0.0), tips=7, strands=None, glow=1.0, lean=0.0, eye_r=0.1,+ body_alpha=0.32, sheet=0.42, colours=('ghost_dark', 'ghost', 'ghost_light', 'ghost_white'), clip=None,+ seed=None):+ """a small sheet-ghost: a translucent dome-and-bell body of fine silver strands flowing over the crown and+ falling to a fringe of `tips` locks, two glowing eyes (cream core, amber ring, halo; `look` shifts them,+ -1..1) and a warm glowing bead at the end of every lock. `lean` tilts the fall of the sheet (degrees).+ clip: a mask the ghost is painted into (to hide it behind leaves). Returns the body mask."""+ r = self._r(seed)+ R = w / 2.0+ cy = top + R # centre of the dome+ bot = top + h+ ln = np.tan(np.deg2rad(lean))+ # outline: the dome, the sides falling and flaring a little, a scalloped fringe of locks+ th = np.linspace(np.pi, 2 * np.pi, 24)+ dome = [(cx + R * np.cos(t), cy + R * 0.98 * np.sin(t)) for t in th]+ side = lambda sg, ts: [(cx + sg * R * (1.0 + 0.1 * t) + ln * (bot - cy) * t, cy + (bot - cy) * t * 0.92) for t in ts]+ right = side(1, np.linspace(0.1, 1, 6))+ xs_t = np.linspace(cx + R * 1.1, cx - R * 1.1, tips * 2 + 1) + ln * (bot - cy)+ fringe = []+ for j, xt in enumerate(xs_t):+ if j % 2 == 1: fringe.append((xt + r.normal(0, w * 0.015), bot + r.normal(0, h * 0.02)))+ else: fringe.append((xt, bot - h * (0.07 + 0.03 * r.random())))+ left = side(-1, np.linspace(1, 0.1, 6))+ body = self.poly(dome + right + fringe + left, smooth=True)+ if clip is not None: body = body * clip+ tip_pts = [p for j, p in enumerate(fringe) if j % 2 == 1]+ # a translucent sheet: some of the dark shows through, lighter over the crown, warm at the hem+ val = np.clip(0.75 - 0.6 * (self.YY - top) / h, 0, 1)+ self.wash(body, ('ghost', val), body_alpha, grain=0.4, edge=0.6)+ hem = body * smoothstep(bot - h * 0.4, bot, self.YY)+ self.glaze(hem, 'glow', 0.25 * glow, 'screen')+ bb = self._bbox(body, pad=2)+ if bb is not None: # the whole sheet glows a little (a soft halo)+ x0, y0, x1, y1 = bb+ self.E[y0:y1, x0:x1] += body[y0:y1, x0:x1] * 0.05 * glow+ self._bloom = None++ def flow(x, y):+ # the sheet falls from the crown like hair: away from a point just above it, turning to hang down+ a_fall = np.degrees(np.arctan2(y - (top - 0.35 * R), x - cx))+ a_down = 90 - 12 * np.clip((x - cx) / R, -1.2, 1.2) - lean+ g = smoothstep(cy - 0.2 * R, cy + 0.6 * R, y)+ return a_fall * (1 - g) + a_down * g+ shade = np.clip(1.0 - 0.75 * (self.YY - top) / h, 0, 1) * \+ (1 - 0.35 * np.clip(np.abs(self.XX - cx) / (R * 1.1), 0, 1) ** 2)+ crown = body * (self.YY < cy - 0.45 * R)+ ns = int(w * 6) if strands is None else strands+ cm = smoothstep(0.05, 0.4, self.soften(body, 2.0))+ self.strands(crown, flow, colours, n=ns, length=(h * 0.55, h * 1.05), width=(0.7, 1.3), step=3.0,+ shade=shade, spread=0.28, curl=0.15, jitter=4, alpha=sheet, clip=cm, lock=(10, 4),+ seed=int(r.integers(1 << 30)))+ self.strands(body, flow, colours, n=int(ns * 0.7), length=(h * 0.25, h * 0.6), width=(0.7, 1.2), step=3.0,+ shade=shade, spread=0.28, curl=0.2, jitter=6, alpha=sheet * 0.85, clip=cm,+ seed=int(r.integers(1 << 30)))+ # glowing eyes+ er = eye_r * w+ for sg in (-1, 1):+ ex = cx + sg * 0.22 * w + look[0] * 0.08 * w+ ey = top + 0.43 * w + look[1] * 0.06 * w+ if clip is not None and clip[int(np.clip(ey, 0, self.H - 1)), int(np.clip(ex, 0, self.W - 1))] < 0.5:+ continue+ self.dab(ex, ey, er * 2.0, 'glow', 0.25 * glow, soft=1.0)+ self.dab(ex, ey, er * 1.08, 'glow_ring', 0.95, soft=0.25)+ self.dab(ex, ey, er * 0.82, 'glow', 0.95, soft=0.3)+ self.dab(ex - er * 0.08, ey - er * 0.08, er * 0.55, 'glow_core', 1.0, soft=0.45)+ self.emit(ex, ey, er * 1.3, 0.75 * glow)+ # the glowing tips: the last part of every lock lit warm, a small elongated bead of light at its end+ for (tx, ty) in tip_pts:+ if clip is not None and clip[int(np.clip(ty - 3, 0, self.H - 1)), int(np.clip(tx, 0, self.W - 1))] < 0.5:+ continue+ paths = []+ for _ in range(5):+ ox = r.normal(0, w * 0.018)+ paths.append(np.array([(tx + ox - ln * h * 0.14, ty - h * r.uniform(0.1, 0.18)), (tx + ox, ty - h * 0.05),+ (tx + ox * 0.8, ty + r.uniform(-2, 1))], np.float32))+ self.lines(paths, ('glow_ring', 'glow', 'glow'), (0.7, 1.1), 0.85, 0.95, 0.45, (0.05, 0.5), k=5,+ seed=int(r.integers(1 << 30)))+ bw, bh = max(1.4, w * 0.016), max(2.4, h * 0.036)+ self.dab(tx, ty - bh * 0.4, bw * 1.6, 'glow', 0.55, soft=0.9, ry=bh * 1.5)+ self.dab(tx, ty - bh * 0.4, bw, 'glow', 0.9, soft=0.6, ry=bh)+ self.dab(tx, ty - bh * 0.5, bw * 0.55, 'glow_core', 0.95, soft=0.6, ry=bh * 0.6)+ self.emit(tx, ty - bh * 0.5, max(2.0, w * 0.028), 0.55 * glow, ry=max(3.0, h * 0.05))+ return body++ # ================================================================== sky+ @staticmethod+ def _dot(buf, x, y, rad, amp):+ H, W = buf.shape+ k = int(rad * 3 + 2)+ ix, iy = int(x), int(y)+ if ix < k or iy < k or ix >= W - k or iy >= H - k: return+ yy, xx = np.mgrid[-k:k + 1, -k:k + 1].astype(np.float32)+ g = np.exp(-((xx - (x - ix)) ** 2 + (yy - (y - iy)) ** 2) / (2 * (rad * 0.6) ** 2)) * amp+ sl = buf[iy - k:iy + k + 1, ix - k:ix + k + 1]+ np.maximum(sl, g, out=sl)++ def stars(self, region, n=150, size=(0.5, 1.5), bright=0.06, colour='star', warm=0.15, seed=None):+ """pinpricks of light over the sky; `bright` of them larger with a faint halo"""+ r = self._r(seed)+ M = self._mask(region)+ ys, xs = np.nonzero(M > 0.05)+ if not len(xs): return+ S = np.zeros((self.H, self.W), np.float32); Sw = np.zeros((self.H, self.W), np.float32)+ cnt = 0+ for i in r.choice(len(xs), size=min(n * 5, len(xs))):+ if r.random() > M[ys[i], xs[i]]: continue+ big = r.random() < bright+ rad = r.uniform(*size) * (1.7 if big else 1.0)+ amp = r.uniform(0.4, 1.0) * (1.0 if big else 0.75)+ self._dot(Sw if r.random() < warm else S, xs[i] + r.random(), ys[i] + r.random(), rad, amp)+ if big: self._dot(S, xs[i] + 0.5, ys[i] + 0.5, rad * 4, 0.1)+ cnt += 1+ if cnt >= n: break+ for buf, c in ((S, colour), (Sw, 'warmstar')):+ self.C += (hexc(c) - self.C) * np.clip(buf, 0, 1)[..., None]++ # ================================================================== finish and output+ def finish(self, soft=0.2, grain=1.0, tooth=1.0, bloom=1.0, lift=0.025, warmth=0.0):+ """record the finishing (applied in render, so every stage snapshot matches the final look; call it before+ the first mark): a slight softness, the bloom of what glows, a fine print grain plus a coarser tooth that+ shows in the darks, lifted blacks"""+ self.fin = dict(soft=soft, grain=grain, tooth=tooth, bloom=bloom, lift=lift, warmth=warmth)+ return self++ def render(self, rows=216):+ """the finished picture (the canvas is untouched): softened channel by channel, then bloom, grain, tooth and+ lifted blacks applied in row bands so the temporaries stay small"""+ C = self.C+ f = self.fin+ if not f: return np.clip(C, 0, 1)+ out = np.empty_like(C)+ if f['soft']:+ for c in range(3): out[..., c] = C[..., c] * (1 - f['soft']) + blur(C[..., c], 0.7) * f['soft']+ else:+ out[:] = C+ if f['bloom'] and self._bloom is None and self.E.max() > 0:+ E = self.E+ self._bloom = 0.55 * self.soften(E, 2.5)+ self._bloom += 0.4 * self.soften(E, 9.0)+ self._bloom += 0.3 * self.soften(E, 28.0)+ self._need()+ glow = np.asarray(GLOW, np.float32)+ lift = hexc('#151424')+ for y0 in range(0, self.H, rows):+ o = out[y0:y0 + rows]+ if f['bloom'] and self._bloom is not None:+ g = np.clip(self._bloom[y0:y0 + rows] * f['bloom'], 0, 4)[..., None] * glow+ o[:] = 1 - (1 - o) * np.exp(-g)+ lum = o.mean(-1, keepdims=True)+ if f['grain']:+ o *= 1 + f['grain'] * 0.022 * self._grain[y0:y0 + rows, :, None]+ if f['tooth']:+ # a printed tooth: the coarse grain lifts the darks a little (paper showing through the ink)+ dk = 1 - smoothstep(0.05, 0.5, lum)+ o += f['tooth'] * (0.035 * dk + 0.012) * self._tooth[y0:y0 + rows, :, None]+ if f['warmth']:+ o *= 1 + f['warmth'] * np.array([0.012, 0.002, -0.016], np.float32)+ if f['lift']:+ o[:] = f['lift'] * lift + o * (1 - f['lift'])+ np.clip(o, 0, 1, out=o)+ return out++ def composite(self):+ out = self.render()+ out *= 255; out += 0.5+ return Image.fromarray(out.astype(np.uint8))++ def stage(self, name):+ if not self.keep_stages: return+ im = self.composite()+ if self.stages_dir:+ os.makedirs(self.stages_dir, exist_ok=True)+ im.save(f'{self.stages_dir}/{self._n_stages:02d}_{name}.png', compress_level=1)+ else:+ b = io.BytesIO(); im.save(b, 'PNG', compress_level=1)+ self.stages.append((name, b.getvalue()))+ self._n_stages += 1++ def save(self, path, stages_dir=None, quality=88):+ img = self.composite()+ if str(path).lower().endswith(('.jpg', '.jpeg')): img.save(path, quality=quality, subsampling=0)+ else: img.save(path)+ sd = stages_dir or self.stages_dir+ if sd and self.keep_stages:+ os.makedirs(sd, exist_ok=True)+ for i, (name, b) in enumerate(self.stages):+ with open(f'{sd}/{i:02d}_{name}.png', 'wb') as f: f.write(b)+ img.save(f'{sd}/{self._n_stages:02d}_final.png', compress_level=1)+ return img