Skip to content

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.

Add colour town style (75 total): festival steps after the rain

cloveric21673719249e
diff --git a/README.md b/README.md
index 05361bc..87d17b9 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# Claude Drawing · Claude 绘图
-**Claude paints with code — no image model.** Seventy-four 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 and a warm coloured-pencil storybook spread.
-**不用生图模型,Claude 用代码一笔一笔作画。** 七十四种画风,从水墨、油画到黏土、蓝晒、彩色玻璃花窗、罗马马赛克、代尔夫特蓝瓷砖、赛博朋克、光线追踪的小球海、低多边形 3D、热成像、X 光片、VHS 录像带、Synthwave 落日、产品发布片式的粉彩界面、红笔批改的答题卡、油灯下的皮影戏、钢笔淡彩的速写小卡、复古水粉的绘本大头像、蓝调绘本的雨天跨页、江南园林的春水园景、干刷色块的 mid-century 海报、暮色微缩绘本里转入星空的黄昏、排线夜景里流进海里的熔岩、深色笔记应用里渲染出的流程图、卡片铺开的无限白板、Flexoki 暖纸上的五图图解和暖调彩铅叠出来的绘本跨页。
+**Claude paints with code — no image model.** Seventy-five 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 and a colour town of gouache houses strung with bunting.
+**不用生图模型,Claude 用代码一笔一笔作画。** 七十五种画风,从水墨、油画到黏土、蓝晒、彩色玻璃花窗、罗马马赛克、代尔夫特蓝瓷砖、赛博朋克、光线追踪的小球海、低多边形 3D、热成像、X 光片、VHS 录像带、Synthwave 落日、产品发布片式的粉彩界面、红笔批改的答题卡、油灯下的皮影戏、钢笔淡彩的速写小卡、复古水粉的绘本大头像、蓝调绘本的雨天跨页、江南园林的春水园景、干刷色块的 mid-century 海报、暮色微缩绘本里转入星空的黄昏、排线夜景里流进海里的熔岩、深色笔记应用里渲染出的流程图、卡片铺开的无限白板、Flexoki 暖纸上的五图图解、暖调彩铅叠出来的绘本跨页和挂满彩旗的水粉彩色小镇。
[English](#english) · [中文](#中文)
@@ -59,6 +59,8 @@
| **Warm pencil storybook · 暖调彩铅绘本** | **Ink wash · 水墨(月印万川)** | **Watercolour · 水彩(底纹)** |
| ![pencilbook](examples/drawing_pencilbook_tortoise_crossing.gif) | ![moonriver](examples/drawing_moon_river.gif) | ![washes](examples/drawing_watercolor_washes.gif) |
+<p align="center"><img src="examples/drawing_colortown_festival_steps.gif" width="45%"><br><sub><b>Colour town · 彩色小镇</b> — portrait 3:4 · 竖幅</sub></p>
+
### Gallery · 画廊
| | |
@@ -139,8 +141,10 @@
| <img src="examples/obsidianui_reading_notes.jpg" width="100%"> | <img src="examples/canvasboard_moving_plan.jpg" width="100%"> |
| **一杯手冲咖啡** · *Pour-over, in Five Diagrams*<br><sub>Flexoki paper · Flexoki 纸面</sub> | **大龟过河** · *The Tortoise Crossing*<br><sub>Warm pencil storybook · 暖调彩铅绘本</sub> |
| <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> | |
+| <img src="examples/colortown_festival_steps.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, and a night sea laid stroke by stroke under the one warm light of lava meeting the water. 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, and a hill town of gouache houses, inked line by line and slate by slate, strung with bunting and mirrored in a wet square. 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.
---
@@ -148,7 +152,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-four styles:
+A [Claude Code](https://claude.com/claude-code) skill and a small painting library with seventy-five styles:
| Style | Module | What makes it read as the real medium |
|---|---|---|
@@ -226,6 +230,7 @@ A [Claude Code](https://claude.com/claude-code) skill and a small painting libra
| **Canvas board (白板卡片)** | `lib/canvasboard.py` · `CanvasBoard` | the canvas view of a dark note-taking app, as a product film shows it: a dark page with a faint violet glow, the app window (traffic lights and a `.canvas` tab in the tab bar, a ribbon of line icons, the zoom buttons top right) and in it an infinite board of grey dots seen through a camera. Nothing is rasterised when you draw: every shape is recorded in board coordinates into a named node — a group, a card, an edge — and `render()` draws every node again through the camera, so the board can be panned and zoomed with crisp edges and type at any scale; the dot grid lives on the board and moves with it, the chrome does not. Rounded rectangles, discs, rings and strokes are signed-distance fields with 1 px analytic anti-aliasing, polylines are measured segment by segment inside their own bounds (a 64-segment edge or a sketch of hundreds of segments stays cheap), arrowheads and the pointer are 4× supersampled polygons, shadows follow CSS box-shadow. Groups are rounded frames with their labels floating above; cards have a 2 px border in one of six card colours with a 5 % tint of it, a soft shadow, a file-name label, a violet halo when selected and a big shadow when lifted. Cards hold inline Markdown laid out again at every zoom — headings, ==violet highlights==, `mono code`, bold — task lists that tick (the box pops violet, the check draws on, a strike runs through, the text greys), quotes with a violet bar, tag pills, colour chips and progress bars; image cards hold a picture drawn in hand-drawn strokes (each segment slightly bowed and overshooting, drawn twice) with notes in a handwriting face. Edges are cubics that leave and enter along the sides' normals, with an arrowhead and a label on a board-coloured pill. Every node has a pose (offset, scale, opacity) and named progress vars that its shapes read — fade, draw, reveal or pop — and `tween()` writes the in-between stages: cards dropping in with a little bounce, edges drawing on, the camera panning and zooming, a sketch drawn stroke by stroke, the pointer clicking "fit". One accent: violet |
| **Flexoki paper (Flexoki 纸面)** | `lib/flexoki.py` · `FlexokiPaper` | an explainer sheet the way a docs site themed with the Flexoki palette shows its diagrams: warm paper #FFFCF0, ink-black type, a ladder of warm greys (surface, track, hairline, border, faint and muted text) and eight accents in two shades. Light-grey rounded panels with no border and no shadow carry a heavy CJK title, a grey English tag and a mono index; inside them the diagrams are drawn the way a lightweight Mermaid-style renderer draws them — boxes one step off their ground with a 2 px grey border (rect, round, stadium, exact rhombus, cylinder, circle), 2.4 px ink lines ending in small filled triangular heads, plain semibold labels on a patch of ground colour, dashed lifelines, activation bars, replies and notes, pies with paper-coloured gaps, bar charts on hairline grids, tables with a tinted header and accent dots — plus an orange focus ring, ink chips, step chips and big tight-tracked numbers. Every shape is a signed-distance field with 1 px analytic anti-aliasing; polylines carry their arc length, so an edge can be drawn on to any fraction (the cut end keeps its round cap), dashed along its length and trimmed under its head; a node (fill, border, label) is composited as one group, so it pops in and fades as a whole. Layers with poses, plus `layer(name, fresh=True)` to redraw a progress state, make the draw-on animation: panels rise dim and light up one by one, edges draw on one by one and land their heads, messages fly, a timer and the bar values roll, the pie sweeps, table rows slide in |
| **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 |
Ask Claude to *"draw it yourself"*, *"paint this with code"*, or *"claude绘图"*, and name a style if you like. Claude then:
@@ -402,6 +407,15 @@ Every style has a complete example: `python3 examples/<name>.py out.png --stages
- cross-hatching on a thin stick is candy stripes — run its strokes along it;
- a lit rim drawn round a whole silhouette shows through whatever sits on top of it.
Keep the child small against the creature with a simple face (a dot eye, a cheek, a nose bump), and the creature's eye gentle — a soft lid, not a brow.
+- **Colour town**: flat opaque colour plus a fine, slightly shaky ink line. The line makes the style, so ink nearly everything (frames, glazing bars, sills, slates, pennants), in a warm dark brown, never pure black. Make it dense and layered: big windows near, tiny ones far, each row overlapping the one above, roofs, chimneys and aerials against the sky. Vary widths, heights, bases and roof shapes (pointy gables, narrow tower houses, a few terracotta roofs), or the hill reads as shelving. Let the colour gather in the middle: keep the near walls pale (white, cream, blush, pale yellow) and put the saturated houses in the stack. Make every window a little different, and don't give every one shutters or a box. Keep texture to a few percent, less on light colours, with almost no cast shadows. Watch for accidental reads:
+ - two dark arched openings above a clock face are a pair of eyes — use three narrow louvred ones;
+ - dense dark slats on every shutter make a roller blind and a busy wall;
+ - round pale roses with a white highlight are bubbles — give them an irregular cup, a darker heart and petal arcs;
+ - an even, smooth-edged tree crown is a printed pattern — light each clump as a dome and let leaves break the outline;
+ - a string of bunting across the clock face hides the one thing everyone looks for — route it below;
+ - a mirrored figure that isn't smeared leaves a dark ball under its feet — reflect what was painted, smeared and fading;
+ - paving stones with strong value variation turn into a chessboard under the reflection.
+ Keep the people tiny and faceless.
### Roadmap
@@ -413,7 +427,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,加上一个小巧的绘图库,内置七十五种画风:
| 画风 | 模块 | 为什么看起来像真的 |
|---|---|---|
@@ -491,6 +505,7 @@ Every style has a complete example: `python3 examples/<name>.py out.png --stages
| **白板卡片** | `lib/canvasboard.py` · `CanvasBoard` | 深色笔记应用的白板视图,像产品片里拍的那样:深色页面左上一片淡紫光,一扇应用窗口(标签栏上红黄绿三点和「.canvas」标签页、左边一列线性图标、右上角缩放按钮),里面是一块透过镜头看的灰点阵无限白板。画的时候什么都不栅格化:每个形状都按白板坐标记进一个有名字的节点(分组、卡片、连线),`render()` 按镜头把所有节点重画一遍,所以白板可以任意平移缩放,边和字始终锐利;点阵长在白板上跟着动,窗口不动。圆角矩形、圆、环和线条是有符号距离场、1 px 解析抗锯齿,折线逐段只在自己的包围盒里算(64 段的连线、几百段的草图都很快),箭头和指针是 4 倍超采样多边形,阴影按 CSS box-shadow 算。分组是圆角框,组名浮在框上方;卡片是 2 px 的卡片色边(六种卡片色)加 5 % 同色底、软阴影、上方的文件名,选中时一圈淡紫光,举起时一层大阴影。卡片里是每次缩放都重新排版的行内 Markdown——标题、紫色高亮、等宽行内代码、粗体——会打勾的清单(紫色方框弹出、对勾画出、删除线划过、文字变灰)、紫色竖条的引用、标签胶囊、颜色胶囊和进度条;图片卡片里是手绘笔触画的图(每段略弯、两头出头、画两遍)和手写体批注。连线是沿两条边的法线出入的三次曲线,末端箭头,中间一块白板底色的标签。每个节点有位姿(位移、缩放、不透明度)和有名字的进度变量,形状按 淡入 / 画出 / 揭开 / 弹出 读它;`tween()` 写出中间阶段:卡片掉落、回弹落定,连线画出来,镜头平移缩放,草图一笔笔画,指针点「适合窗口」。只有一个强调色:紫 |
| **Flexoki 纸面** | `lib/flexoki.py` · `FlexokiPaper` | 照用 Flexoki 配色的文档站那样摆一页图解:暖白纸 #FFFCF0、墨黑字、一串暖灰(卡片底、轨道、细线、边框、最淡和次要的字),八种强调色各两档。不描边、不投影的浅灰圆角卡片,粗黑中文标题、灰色英文、等宽编号;卡片里的图照轻量的 Mermaid 式渲染器画——比底色差一级的框和 2 px 灰边(直角、圆角、胶囊、精确菱形、圆柱、圆),2.4 px 墨线末端一个小的实心三角箭头,普通半粗体标签垫一块底色,虚线生命线、激活条、回复和便签,带纸色缝的饼图,细网格上的柱状图,表头着色、带强调色小圆点的表格;还有橙色聚焦框、黑底胶囊、步骤胶囊和字距收紧的大数字。所有形状都是有符号距离场、1 px 解析抗锯齿;折线带弧长,一条边能画到任意几成(切口仍是圆头)、沿弧长画虚线、在箭头下面截短;一个框(底、边、字)先合成一组再放下,所以弹出和淡入是整个一起的。带姿态的图层加上 `layer(name, fresh=True)` 按进度重画,就是逐边画出的动图:卡片暗着升起、一张张亮起,线一条条画过去再落下箭头,消息飞过去,计时器和柱顶数字滚动,饼图扫开,表格一行行滑进来 |
| **暖调彩铅绘本** | `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()` 把之后画的东西(人、路灯)也倒映下来。附带洋葱顶、木百叶钟楼开口的钟楼,越往上越小的台阶、石墙、铁栏杆、路灯、吊挂店招、海报、咖啡桌、猫和不画脸的小人 |
对 Claude 说「claude绘图」「你自己画」「用代码画」,也可以指定画风。它会:
1. **先定构图**:层次、焦点、留白,而且画面要图解内容本身;
@@ -594,6 +609,7 @@ python3 examples/obsidianui_reading_notes.py out.jpg --stages stages/ # 笔记
python3 examples/canvasboard_moving_plan.py out.jpg --stages stages/ # 白板卡片:搬家计划
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/ # 彩色小镇:雨后的节日台阶街
```
### 作画要点(Claude 交图前逐条自查)
@@ -719,6 +735,15 @@ python3 examples/pencilbook_tortoise_crossing.py out.jpg --stages stages/ #
- 细杆上交叉排线是拐杖糖——笔触顺着杆走;
- 围着整个轮廓画的边光,会从盖在上面的东西里透出来。
小孩要比那只生物小得多、脸要简单(点点眼、腮红、一个小鼻头),生物的眼睛要温和——一道软软的眼皮,不要眉毛。
+- **彩色小镇**:不透明的平涂加一道细细的、微微抖的墨线。这个画风靠线立住,所以几乎每样东西都要描(窗框、窗棂、窗台、石板、彩旗),墨用暖深棕,不用纯黑。要密、要有层次:近处的窗大,远处的窗小,每一排压住上一排,屋顶、烟囱和天线衬着天空;房子的宽、高、地基和屋顶形状都要错开(尖山墙、窄的塔楼式房子、几片赤陶瓦),不然山坡像一排货架。颜色往中间收:近处的墙用浅色(白、奶油、浅粉、浅黄),饱和的房子放进中间那一堆。窗户每扇都略有不同,不要每扇都有百叶窗和花箱。纹理只差百分之几,浅色更少,几乎不画投影。小心看错:
+ - 钟面上方两个深色的拱形开口是一双眼睛——改成三个窄的木百叶开口;
+ - 每扇百叶窗都是又密又黑的横条,就是卷帘,整面墙会很花;
+ - 带白色高光的圆圆的浅色玫瑰是泡泡——要不规则的杯形、深一点的花心和花瓣弧线;
+ - 均匀、轮廓光滑的树冠是一块印花——每团按穹顶打光,让叶子破开轮廓;
+ - 一串彩旗挡在钟面上,挡住的正是大家要看的东西——让它从钟下面过;
+ - 没有拖尾的镜像小人,会在脚下留一个深色圆球——镜像实际画出来的像素,竖向拖尾、往下渐淡;
+ - 明暗差太大的石板,在倒影下面会变成棋盘格。
+ 小人要很小、不画脸。
### 计划
diff --git a/SKILL.md b/SKILL.md
index e42ebc6..9599893 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(暖白、有齿纹的纸上一层层叠涂的彩色铅笔绘本页:天空、山坡、草、水、一只大而温柔的生物和一个小小的孩子,全由顺着形体走向的细铅笔线叠成——天空横向长排线,山坡顺着坡势,龟壳绕着每块盾片的生长纹,脖子横过褶皱,雨衣顺着衣褶,苔藓和头发一簇簇顺毛;每块先铺一层浅色底,再上固有色、背光处叠同色系的深色,受光处罩一层暖色、阴影里罩一层冷色,每层角度错开一点、笔触交叉;蜡只挂在纸齿的峰上,同一批纸坑一层层都透出细白点,压得重、叠得多的地方才慢慢合上;后画的东西先留白再铺背景,颜色不互相混;毛是一绺一绺的:根部散开、尖端聚拢、顺着毛向,每绺受光一侧亮、背光一侧暗;没有墨线、没有黑色,只有很淡的同色轮廓;黄昏的暖光:灯笼和窗灯是一层层橙黄的发光叠涂(不是一团光晕,也不是放射线),低低的太阳给受光一侧一道暖边;水里的倒影也是一笔笔横排线;附带树、小房子、石头、鳞片、野花、纸灯笼和穿雨衣提灯笼的小孩等绘本部件)。用户说「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 图、图表渲染器、灰底圆角框、小三角箭头、橙色聚焦框、数字滚动、计时器大数字、配方图解、步骤图解、手冲咖啡图解、菜谱图解、工作流程图解、暖调彩铅绘本、暖调彩铅、彩铅绘本、彩铅童书、彩铅童书插画、彩色铅笔绘本、彩色铅笔童书、软彩铅、彩铅叠涂、层层叠涂的彩铅、顺着形体排线、纸齿白点、纸纹透白、怀旧童书、翻绘本的感觉、温暖怀旧的绘本、暖色绘本页、巨物与小孩、大动物和小孩、巨大温柔的生物、温柔的巨兽、大乌龟、巨龟、老乌龟、背着花园的乌龟、龟背上的小花园、大龟过河、过河、小溪、踏脚石、提灯笼的小孩、黄色雨衣、纸灯笼、亮灯的窗、亮灯的小房子、黄昏小镇、成簇的毛、顺毛、毛一绺一绺、苔藓、金黄的树),或 "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" 时使用;也用于需要逐步画出(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,剖面和施工图仍用蓝图工程图。「暖调彩铅绘本 / 彩铅绘本 / 彩铅童书插画 / 巨物与小孩 / 大龟过河 / 纸齿白点 / 层层叠涂」指暖调彩铅绘本(暖白纸上满画面顺形体的彩铅叠涂、纸齿透出细白点、毛发成簇顺毛,大而温柔的生物和小小的孩子,黄昏暖光和橙黄的灯,没有墨线和黑色);单说「彩铅」仍指韩国彩铅(明亮可爱的甜品小物、粉嫩高光),黑白石墨仍用铅笔素描,软蓝限色、刮擦墨线加蜡笔颗粒的绘本跨页仍用蓝调绘本,粉彩黄昏转入星空、满坡小野花仍用暮色微缩绘本,不透明水粉的特写大头像仍用复古水粉,深蓝夜色里只有一个暖光的排线小版画仍用排线夜景;单说「绘本」仍指绘本角色动画。
+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(不透明水粉平涂加细细的深棕墨线画的童话山城街景:高高窄窄的房子漆成番茄红、芥末黄、青绿、薄荷、珊瑚、奶白,一排压一排堆上山坡,近大远小、前后遮挡;深蓝灰的石板曼莎屋顶是一片片瓦错缝铺出来的,带老虎窗、烟囱和赤陶烟囱帽、电视天线;白色钟楼、淡蓝的天和奶白的云;三角彩旗串在好几层深度上斜穿街道,远处的小、近处的大,每面旗有一道深一点的折痕;红色爬藤玫瑰、溢出来的窗台花箱、铁艺阳台、石头台阶和扶手、路灯、吊挂的店招、拱门和彩色木门、写着字的店面和条纹遮阳篷;前景是湿亮的街面,把整条街倒映成一道道竖向的笔触;每块颜色都是带一点笔刷纹理的不透明平涂,边缘像手画的那样微微抖,和描线不完全对齐;墨线分成几段、粗细略有变化,方框的转角偶尔出头;墨是半透明的,压在红墙上是深红棕,压在玻璃上近乎黑;窗户排得整齐,但每扇都略有不同;一整面墙可以用透视单应贴成往消失点收的峡谷墙;几乎没有投影;附带钟楼、台阶、矮墙、栏杆、树、花盆、彩旗、路灯、店招、海报、咖啡桌、猫和概括的小人等部件)。用户说「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 图、图表渲染器、灰底圆角框、小三角箭头、橙色聚焦框、数字滚动、计时器大数字、配方图解、步骤图解、手冲咖啡图解、菜谱图解、工作流程图解、暖调彩铅绘本、暖调彩铅、彩铅绘本、彩铅童书、彩铅童书插画、彩色铅笔绘本、彩色铅笔童书、软彩铅、彩铅叠涂、层层叠涂的彩铅、顺着形体排线、纸齿白点、纸纹透白、怀旧童书、翻绘本的感觉、温暖怀旧的绘本、暖色绘本页、巨物与小孩、大动物和小孩、巨大温柔的生物、温柔的巨兽、大乌龟、巨龟、老乌龟、背着花园的乌龟、龟背上的小花园、大龟过河、过河、小溪、踏脚石、提灯笼的小孩、黄色雨衣、纸灯笼、亮灯的窗、亮灯的小房子、黄昏小镇、成簇的毛、顺毛、毛一绺一绺、苔藓、金黄的树、彩色小镇、彩色房子、彩色街景、童话小镇、童话街景、治愈小镇、理想的生活环境、欧洲小镇、山城小镇、钟楼小镇、彩虹小镇、彩旗、三角彩旗、彩旗串、彩旗街、节日街道、节日早晨、钟楼、白色钟楼、洋葱顶、石板屋顶、曼莎屋顶、老虎窗、烟囱帽、电视天线、风向标、爬藤玫瑰、窗台花箱、铁艺阳台、台阶街、石头台阶、拱门下的台阶、湿街倒影、雨后街道、雨后的广场、水粉街景、水粉加描线、水粉平涂加细线、细节多到看不完、小红书彩色小镇),或 "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" 时使用;也用于需要逐步画出(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 绘图
@@ -88,6 +88,7 @@ description: Claude 绘图 / Claude Drawing —— 不借助任何生图模型
| 白板卡片 · Canvas Board | `lib/canvasboard.py` · `CanvasBoard` | `examples/canvasboard_moving_plan.py` 搬家计划 · Moving Plan(深色页面左上一片淡紫光,一扇深色应用窗口:标签栏上红黄绿三点和标签页「搬家计划.canvas ×」,左边一列线性图标,右上角一列缩放按钮 + − 适合窗口 ?;窗口里是灰点阵的无限白板,三个分组框,组名浮在框上方。「收拾 · 第 1 周」:紫边、带淡紫光圈的选中卡片「搬家计划」——老城区 → 河边新家,「11 月 8 日 · 周六 · 还有 12 天」里后半句压着紫色高亮,三个紫色标签胶囊;红边清单「先清掉的东西」,三项打了紫色勾、变灰加删除线,两项还空着;组外一张散放的采购卡和紫色进度条「已买 2/3」。「搬家当天 · 11/8」:时间线卡,一根竖线串起 08:00 → 13:30 四个时间点,最后一个是紫点、「新家卸货」压紫色高亮;黄边卡片「箱子编号」,四个颜色胶囊 厨房 K1–K6(橙)、书房 S1–S9(青)、卧室 B1–B5(绿)、易碎 ×4(红)。「新家 · 河边 3 楼」:图片卡片「新家平面图.png」,深色方格纸上手绘的平面图——墙、门的开启弧线、窗、卧室里绿色的床、客厅里青色的书桌、厨房橙色的台面、手写体房间名,一条紫色虚线从大门画到床边,旁边手写「床先进卧室」;紫色竖条的引用卡「先把床装好,其他的明天再说。」;绿边清单「第一晚要用的」,底下一行「都装在 `B1` 箱」。四条弯曲连线带箭头和标签:紫色「当天」、灰色「装箱」「13:30」、绿色「B1 先开」;`--stages` 出 121 个阶段加成品:卡片一张张掉落、打勾、连线画出、镜头平移到下一组、平面图一笔笔画出、指针点「适合窗口」后拉远到整块白板) | 约 0.6 秒(`--stages` 约 26 秒) |
| Flexoki 纸面 · Flexoki Paper | `lib/flexoki.py` · `FlexokiPaper` | `examples/flexoki_pour_over.py` 一杯手冲咖啡 · Pour-over, in Five Diagrams(暖白纸 #FFFCF0 上的一页图解:左上黑底胶囊「图解 · 手冲咖啡」、粗黑大标题「一杯手冲咖啡」和灰色英文 Pour-over, in five diagrams,右上灰胶囊「总时长」和大字 2:30;五张不描边的浅灰圆角卡片排成两行(右边一列和上一行共用一条缝),每张有粗黑中文标题、灰色英文类型名和等宽编号:① 流程图「从豆子到一杯」:称豆 15 g → 研磨 · 中细 → 冲洗滤纸 → 闷蒸 30 g 水,往下到菱形「鼓包平了?」,绿色「是」→ 分两段注水 → 胶囊形「出杯」,红色「否」沿一条倒圆角的折线绕回闷蒸;② 时序图「两分半里发生了什么」:水壶 / 滤杯 / 分享壶三条虚线生命线、滤杯上的激活条、左边一列等宽时间 0:00 0:45 1:15 2:30、三次注水、浅黄便签「排气 · 45 s」、虚线回复「约 210 g 咖啡液」;③ 柱状图「磨多细,滴多久」:粗 / 中 / 中细 / 细四根青色柱,选中的中细是橙色,柱顶写时间;④ 饼图「240 g 水分三次」:30 / 120 / 90 g 三块(橙、蓝、绿),块之间是纸色的缝,块上写 1/8 1/2 3/8,旁边图例;⑤ 对比表「三种冲法」:手冲 / 法压壶 / 意式(表头前橙、紫、青三个小圆点)× 方式、研磨、时间、口感,手冲一列套橙色圆角框;底下一行灰色小字写配方并注明数字是示意;`--stages` 出 151 个阶段加成品:标题升起,五张卡片暗着升起,再一张张亮起、套上橙色聚焦框,图一边一边画出来——框弹出,线画过去再落下箭头,消息飞过去,右上的计时器从 0:00 走到 2:30,柱子长高、数字跟着滚,饼图顺时针扫开,表格一行行滑进来) | 约 0.3 秒 |
| 暖调彩铅绘本 · 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 秒 |
各画风共用 `lib/core.py` 里的底层工具:噪声、模糊、样条曲线、多边形遮罩、有机轮廓 `blob_pts`、毛笔 `bristle_stroke`、中文字体查找;新四种还用到补零平移 `shift`、文字遮罩 `text_mask`、西文字体查找 `latin_font`/`load_font`,以及高度图打光 `height_normals`、`height_shadow`(沿光线步进的投影)、`ambient_occlusion`。
@@ -165,7 +166,8 @@ description: Claude 绘图 / Claude Drawing —— 不借助任何生图模型
- 讲解片里讲「笔记 / 知识库 / 双链 / Markdown / 代码块怎么变成图」的那一页,或任何要「在一个像真的深色应用窗口里演示一个操作」的画面:文件列表、标题和正文、代码块切到阅读视图渲染、关系图谱亮起来,一屏讲清一件事 → 笔记应用界面(要明亮的粉彩底和白色窗口卡片用粉彩界面;要点阵白板上的卡片和连线用白板卡片;要暖白纸面上的图表用 Flexoki 纸面;要磨砂玻璃和弥散渐变用弥散玻璃;要绿屏荧光字符用绿屏终端 CRT);
- 计划和想法之间的关系,「把几张卡片摆在一块白板上、用箭头连起来」的整理:旅行 / 搬家 / 活动计划、读书和研究笔记的脉络、头脑风暴、项目拆解、评论区里的一问一答,讲解片里「白板上一步步摆出来、镜头跟着移过去」的页 → 白板卡片(要笔记正文、文件列表和关系图谱用笔记应用界面;要暖白纸上的流程图和图表用 Flexoki 纸面;要明亮的粉彩产品界面用粉彩界面;要一层层叠起来的图解用描图纸叠层);
- 讲解片、文档、教程里的「图表页」:步骤和流程、时间线上的往来、占比、对比,要像文档站或技术博客里的图——暖白纸、墨黑字、浅灰圆角卡片,图像 Mermaid 渲染出来那样干净(灰边框、墨线小三角箭头、普通标签),一页放几张图讲清一件事(一份配方、一个工作流程、一次部署、一组产品数字),还能做成「图一边一边画出来、数字滚动」的动图 → Flexoki 纸面(要手写粉笔的示意图用黑板板书;要铅笔图表和便利贴的实验记录用实验笔记本;要彩色粉彩底和 macOS 窗口的产品界面用粉彩界面;要深色笔记应用窗口用笔记应用界面;要点阵白板上的卡片和连线用白板卡片;要系统的微缩模型用等轴 2.5D);
-- 温暖、怀旧、像翻开一本童书的一页:一只大而温柔的生物陪着一个小小的孩子(巨龟、大熊、温柔的怪兽陪孩子过河、等车、看日落),午后和黄昏的暖光、亮灯的窗和灯笼、草地、小溪和小镇,要满画面看得见彩色铅笔的笔触和纸齿,讲解片里「温柔的陪伴 / 慢慢来 / 一起走一段」的页,童书封面和插页 → 暖调彩铅绘本(要明亮可爱的彩铅甜品小物用韩国彩铅;要软蓝限色、乱线墨线的绘本跨页用蓝调绘本;要粉彩黄昏转入星空、满坡野花用暮色微缩绘本;要黑白石墨写生用铅笔素描;要不透明水粉的特写大头像用复古水粉)。
+- 温暖、怀旧、像翻开一本童书的一页:一只大而温柔的生物陪着一个小小的孩子(巨龟、大熊、温柔的怪兽陪孩子过河、等车、看日落),午后和黄昏的暖光、亮灯的窗和灯笼、草地、小溪和小镇,要满画面看得见彩色铅笔的笔触和纸齿,讲解片里「温柔的陪伴 / 慢慢来 / 一起走一段」的页,童书封面和插页 → 暖调彩铅绘本(要明亮可爱的彩铅甜品小物用韩国彩铅;要软蓝限色、乱线墨线的绘本跨页用蓝调绘本;要粉彩黄昏转入星空、满坡野花用暮色微缩绘本;要黑白石墨写生用铅笔素描;要不透明水粉的特写大头像用复古水粉);
+- 治愈、明亮、「细节多到看不完」的童话街景:一座彩色的欧洲小镇、节日的街道、雨后的广场、钟楼和台阶,满街彩旗、玫瑰、花箱和阳台,要一眼就是「手画的水粉插画加细细的描线」,竖幅海报、小红书封面、旅行 / 城市 / 节日 / 「理想的生活」的配图,讲解片里「一个地方 / 一个社区 / 很多人一起生活」的页 → 彩色小镇(要中式园林、古镇和春水用江南园林;要锡釉蓝砖上的运河小镇用代尔夫特蓝瓷砖;要彩纸剪出来的小镇用剪纸拼贴;要系统的微缩模型用等轴 2.5D;要针管笔速写加淡彩的小卡用钢笔淡彩;要没有描线的几何色块用扁平矢量;要彩铅叠涂的黄昏小镇用暖调彩铅绘本)。
每种画风一幅范例作为质量基准(范例都不用禅意主题);水墨另加一幅「月印万川」(留白托月、水面倒影)。
@@ -1276,6 +1278,27 @@ from core import spline, curve, blob_pts, fbm1d, blur, polygon_mask
- 收尾:`finish(soft, grain, vignette, warmth)`;`render()`、`composite()`、`stage(name)`、`save(path, stages_dir)`;`save('x.jpg')` 默认 quality 88、4:4:4 色度。
- 颜色用 `PAINTS` 里的名字(paper white cream ivory;sky_top cobalt sky cornflower sky_pale powder periwinkle lavender mauve violet ultramarine indigo slate teal aqua;lemon butter sun apricot peach glow lantern flame orange tangerine;meadow yellowgreen grass leaf sage moss olive forest pine lichen;ochre gold amber sienna brown umber sepia tan sand stone warmgrey pebble;terracotta brick rose coral vermilion red cheek pink;skin skin_shade hair hair_light raincoat raincoat_shade raincoat_deep denim boot eye)或 '#rrggbb';色阶用 `RAMPS` 里的名字(dusk_sky day_sky glow water meadow hills shell skin stone autumn)或自己给一串颜色。
+**彩色小镇 `ColorTown`**:
+- 思路:照水粉插画师的顺序从远往近画一条街(空纸 → 天空和云 → 远处的小镇和钟楼 → 一排排往近的房子 → 台阶和广场边的房子 → 两侧近处的墙 → 玫瑰、花和招牌 → 近处的彩旗 → 湿街和倒影 → 人),每块颜色都是不透明的平涂,几乎每样东西都有一道细细的、微微抖的深棕墨线。
+ - 色块:每块是一个多边形,后上的盖住先上的。几万块一次画完:Pillow 把每块按序号填进 2 倍超采样的整数 id 图(序号就是画的先后),numpy 对每个 id 查一张表(颜色、不透明度、纹理权重),再 box 平均回 1 倍,所以边是抗锯齿的,一块只要几微秒。整张画布预先算好三张纹理场——竖向笔刷条纹、横向笔刷条纹、各向同性的擦笔(scumble)——再加一层低频斑驳,每块按自己的权重取,明度只差百分之几:墙用 `PLASTER`(擦笔 0.7 加一点竖向笔刷 0.5),天空和铺地偏横向,屋顶、树叶和花用擦笔。浅色的纹理和斑驳按亮度减到约 45%,白墙才干净、不发灰。多边形的边每隔几 px 重采样一次,再沿法线推一点平滑的随机抖动,长边就是手画的直,不是尺子画的直,颜色和描线也不会严丝合缝。
+ - 墨线:深暖棕色,每组颜色画完再画这一组的线(`flush()`)。每条线在 3 倍 id 图里有自己的序号(Pillow 画带圆角接头的折线),交叉处不会叠出墨珠。长线分成几段、粗细各差一点;每条都重采样、加一点低频的手抖;方框的四条边分开画,约三成的转角出头 0.3–1.3 px。墨是半透明的:60% 墨色加 40% 墨色乘底色,所以压在奶油色上是深棕,红墙上是深红棕,玻璃上近乎黑。
+ - 远近:`depth(far)`(0 近 … 1 很远,可以当上下文,也可以当参数)把颜色往天空的淡蓝灰拉、降一点饱和度,线变细、变淡;其余的远近靠尺度(近处的窗几十 px,远处的不到十 px)和从后往前画的遮挡。
+ - 透视墙:`plane(src, dst)` 设一个单应,把一块平摊的矩形布局贴到一个四边形上,整面立面(窗、花箱、阳台、玫瑰)就能按一点透视往消失点收;墨线粗细跟着局部尺度变。
+ - 房子:`house()` 用几个数就搭出一栋窄高的联排房子。墙是带裸石斑块的灰泥(几块石头描了边),还有层间腰线、檐口,墙脚有一层很薄的乘色罩染,檐口下有一道淡阴影。底层可以是门、店面(招牌上写字、壁柱、小方格橱窗、条纹遮阳篷)或拱门。楼上的窗格子每扇都略有不同:奶油色窗框,深青绿的玻璃上一道斜的浅色反光,窗棂、窗台,部分窗户有带横条的百叶窗(`shutter_p`),部分挂窗帘,还有圆窗和拱窗。窗台花箱里是一堆叶子,上面是花点,前面垂下藤;铁艺阳台后面摆着花盆。屋顶的石板一片片错缝铺上去,每片蓝灰各不相同,裁进屋顶的轮廓,缝再描出来;有曼莎、四坡、侧山墙、尖山墙几种,还有老虎窗、带赤陶帽的烟囱、电视天线。返回窗户、屋顶线、烟囱顶的坐标,方便挂彩旗、牵玫瑰。
+ - 植物:玫瑰是沿路径弯弯绕绕往上爬的茎,带侧枝和成对的小叶;花是不规则的杯形,花心深一点,三道深色花瓣弧线,上沿一道混色的浅边,越往上越多、三两成簇。树是树干和枝(墨线),树冠是一团团叶片,每团按左上来光当穹顶打光:下面的团先画,浅色只落在受光的尖上,叶子溢出深色底,轮廓才是叶子边。
+ - 彩旗:绳子在两点之间按抛物线下垂,三角旗按等距挂在绳上,顺着绳子的斜度,比绳的法线更往下垂;每面旗半边深一点(折痕),颜色按一串欢快的颜色轮着取,描线。远处的小、近处的大,在好几个深度上各画一串。
+ - 湿街:先按透视铺石板,缝朝消失点;再把画街之前的画面按每一列的墙脚线镜像下来,加涟漪横推、按列的平滑偏移,离墙脚越远竖向拖得越长,压暗、混进石板色,乘上竖向笔刷条纹;最后把石板缝淡淡地重描一遍,加几道横向反光。之后画的东西(人、路灯、咖啡桌)用 `mirror()` 包起来:里面画出来的像素自动镜像到地面上,竖向拖尾、往下渐淡。
+ - 收尾:`finish()` 只记参数、在 render 里加(每张阶段快照都和成品一致,要在画第一笔之前调用):轻微柔化、细颗粒、一点暖色、很淡的暗角。
+- 构造:`ColorTown(W, H, seed, keep_stages=True, stages_dir=None)`(总像素不超过 4096²),先 `finish()` 再 `paper(tone)`。坐标是整张画布的像素;`t.lw` 是默认墨线粗细,画远处的东西前调小。
+- 底层:`fill(pts, colour, tex, dir, mot, hand, alpha, vary)`(`dir` 是 0 竖 / 1 横 / 2 擦笔,或者一个三元权重,如 `PLASTER`)、`ink(pts, width, closed, alpha, colour, hand, corners, over)`、`box(x0, y0, x1, y1, colour)`、`flush(clip)`(`clip` 是裁切多边形)、`dab(x, y, r, colour)`、`leaf(x, y, length, width, angle, colour)`、`glaze(P, colour, top, bottom)`、`mask(P, soft)`、`paint_mask(mask, colour, alpha, tex, dir, sl)`、`text(cx, cy, s, size, colour)`;上下文 `depth(far)`、`plane(src, dst)`;形状函数 `rect()`、`arch()`、`ellipse_pts()`、`leaf_pts()`。
+- 天空:`sky(top, mid, bottom, y1)`、`clouds([(cx, cy, w, h), …])`、`birds(region, n)`。
+- 房子:`house(x, base, w, h, wall, roof, roof_h, roof_col, floors, cols, frame, glass, shutters, shutter_p, curtains, boxes, flowers, balconies, ground, door_col, shop, sign, letters, awning, stones, boards, bands, chimneys, chimney_col, dormers, aerials, win_kind, win_w, win_h, arch_top, arch_w, top_window, cornice, lw, far, seed)` 返回 windows / roof / ridge / chimneys 等(`ground` 取 'door' | 'shop' | 'arch' | None,`roof` 取 'mansard' | 'hip' | 'side' | 'gable' | 'pyramid' | 'flat' | None,`roof_col='tile'` 是赤陶瓦,`balconies` 是 (楼层, 列) 的列表,列写 -1 表示整层)。部件:`window(x0, y0, x1, y1, kind, frame, glass, panes, shutters, curtains, sill, lintel)`(kind 取 std / arch / round)、`door(…, kind, panels, fanlight, step)`、`shopfront(…, text, letters, door, goods)`、`awning(x0, x1, y, depth, colours)`、`balcony(x0, x1, y, h, pots, style)`、`flowerbox(x0, x1, y, h, box, flowers, mound, trail)`(花色见 `FLOWER_SETS`:pink red sunny violet white)、`roof(kind, x0, x1, y, h, colour, dormers)`、`dormer()`、`slates(P, tile, ramp)`、`chimney()`、`aerial()`、`vane()`、`patches()`。
+- 钟楼和台阶:`clock_tower(cx, base, w, h, body, quoins, dome, time, flag)`(dome 取 'slate' 或 'verdigris');`stairs(bottom, top, n, ratio)`(bottom / top 各是 (左 x, 右 x, y),越往上台阶越小);`parapet(top 折线, bottom 折线, course)`;`railing(path, h)`。
+- 街:`street(y0, vp, poly)`;`reflect(src, base, y0, strength, smear, ripple, darken, region)`(`src` 传画街之前的画布,`base` 可以是逐列的数组);`joints(alpha)`;`mirror(base, x0, x1, top, strength)` 上下文;`glints(y0, y1, n, region)`。
+- 植物和小物:`roses(path, n, colour, dark, light, size)`、`tree(x, base, h, rad, clumps, leaf)`、`pot(x, base, w, h, plant, flowers)`(plant 取 bush / tall / flowers)、`bunting(p0, p1, sag, size, colours)`、`lamp(x, base, h, wall)`、`sign(wall_x, y, r, colour, icon, side)`(icon 取 cup / key / loaf / flower)、`person(x, base, h, coat, legs, hair, umbrella, balloon, basket, facing)`、`cat(x, base, s)`、`bistro(x, base, s)`、`poster(x0, y0, x1, y1, colour)`。
+- 收尾:`finish(soft, grain, warmth, vignette)`;`render()`、`composite()`、`stage(name)`、`save(path, stages_dir)`;`save('x.jpg')` 默认 quality 88、4:4:4 色度。
+- 颜色用 `PAINTS` 里的名字(paper ink ink_soft iron;sky_top sky sky_low haze cloud cloud_shade;tomato red brick coral salmon pink blush rose_wall mustard ochre yellow butter pale_yellow orange apricot teal teal_deep jade mint pale_mint aqua turquoise blue cobalt powder cerulean green sage lavender cream ivory white stone stone_mid stone_dark warmgrey;slate slate_dark slate_light slate_blue tile tile_dark verdigris copper;glass glass_light glass_dark curtain wood wood_dark gold;leaf_dark leaf leaf_mid leaf_light leaf_pale trunk rose rose_dark rose_light rose_pink rose_pink_dark blossom_white blossom_yellow blossom_orange blossom_purple blossom_pink terracotta pot_dark;street cobble cobble_dark wet;skin hair hair_light)或 '#rrggbb';彩旗的颜色是 `BUNTING`,石板和瓦是 `SLATE_RAMP`、`TILE_RAMP`。
+
**顺序**:都是先远后近、先大后小,文字最后叠加。水墨的雾要画在它该吞没的东西之后;水彩的叶梗要先画,并且只画在叶子外面。
## 三、毛病清单(都真实出现过)
@@ -2472,6 +2495,30 @@ from core import spline, curve, blob_pts, fbm1d, blur, polygon_mask
| 树冠是一团黄色的海绵 | 团块更小、更分开(离中心 0.42–0.7 r,半径 0.3–0.44 r),每团单独打光,暗部用赭红,团与团之间才有缝 |
| 动图 1.58 MB,超了 | 普通叠化每帧都把整片天空、整条溪流改一点,细铅笔纹理每次都要重发:每个像素只在 5 帧里的约 2 帧完成过渡(先后由柔和的噪声加从左到右的扫过决定,像下一层彩铅一片片铺上去),0.99 MB;去掉 Bayer 反而更大(1.67 MB) |
+**彩色小镇**
+
+| 问题 | 改法 |
+|---|---|
+| 天空的横向笔刷条纹太显,像拉丝金属 | 天空以擦笔纹理为主(0.35),横向条纹只另叠半透明的一层(0.25) |
+| 云是一团带颗粒的灰,脏 | 云的纹理 0.8 → 0.22,下沿只往暖灰过渡,不加颗粒 |
+| 窗框四角像描了两遍,线乱 | 方框转角出头的概率 0.5 → 0.28,出头长度 0–1.8 → 0.3–1.3 px,不出头时只差 −0.4–0.3 px |
+| 窗台花箱是一条细带,几粒花点,不像「溢出来」 | 花箱上面堆一个叶丛(高 2.4 倍箱高):叶子由外往里、由深到浅,花点画在叶子上,大的加一点浅色花心,前面垂下几串藤 |
+| 玫瑰是一串红点;粉玫瑰带亮白高光,像一串泡泡 | 花是不规则的杯形(半径带 4–5 瓣的起伏),花心深一点,三道深色花瓣弧线,上沿一道和底色混出来的浅边(不用白),每朵旁边塞两片叶子;粉玫瑰放在浅墙上,白墙上用红玫瑰 |
+| 百叶窗横条又密又黑,像条纹卷帘,整面墙很花 | 横条间距 2.6 → 3.6 倍线宽,不透明度 0.45 → 0.32;百叶窗只给一部分窗户(`shutter_p`),近处的白墙 0.3 |
+| 钟楼上两个深色的拱形开口在钟面上方,像一双眼睛 | 改成三个窄的木百叶开口(浅木色横条) |
+| 两棵树几乎看不见,被前排的屋顶盖住 | 树画在上排房子之后、广场边的房子之前,树冠中心抬高 |
+| 树冠是一片均匀的浅绿印花,轮廓是光滑的一团 | 每团按穹顶打光,下面的团先画,浅色只落在受光的尖上(ramp 去掉最浅的黄绿);深色底缩到 0.9 倍,叶子撒到 1.06 倍,轮廓才是叶子边 |
+| 白墙发灰、发脏 | 浅色的纹理和斑驳按亮度减(亮度 0.72–0.95 之间减到约 45%),墙脚的罩染 0.13 → 0.1 |
+| 墙像一块块木板,竖向笔刷太重 | 墙用 `PLASTER` 权重:擦笔 0.7 加竖向 0.5,斑驳 1.2 |
+| 倒影的竖边被推成一级级台阶,底下一片照片式的灰模糊,铺地上一道道横线像扫描线 | 涟漪尺度 6 → 18 px、随距离增长得更慢,加按列的平滑偏移,远处拖成竖条;铺地改用擦笔纹理;倒影之后再淡淡地重描石板缝 |
+| 每个人脚下有一个深色的圆球(镜像出来的头) | 不再自己画镜像的人形:用 `mirror()` 把实际画出来的像素镜像下来,竖向拖尾、往下渐淡、强度 0.35–0.5 |
+| 最大的一串近景彩旗正好挂在钟面上 | 先算出绳子在钟楼那几列的高度,再挪端点,让它从钟下面过(约 y 684,钟面外圈下沿约 616) |
+| 花店招牌是奶油色的字写在奶油色的底上,看不见 | `house()` 加 `letters` 参数,花店用深青绿字 |
+| 颜色太满,近处的墙和中间一样饱和,眼睛没处歇 | 左边的峡谷墙改成浅粉、白、浅黄,右边是白墙,饱和的房子集中在中间那一堆;中间每排也混进白和奶油色的房子 |
+| 山上的房子一排排一样的盒子,像货架 | 行生成器:宽、高、地基都随机错开,约两成是尖山墙,一成是窄的塔楼式房子,一成五是赤陶瓦,阁楼窗在圆、方、拱里随机取 |
+| 换了一个参数,行生成器的随机序列整个变了,一栋房子正好挡住钟楼下半截 | 钟楼前面那一段(x 300–520)单独一行,压低高度、不出尖山墙 |
+| 清理代码时修掉了一个把石块整体推出画面的坐标错误,石块露出来,每块明暗差 7%,在倒影下面成了棋盘格 | 石块明暗差 7% → 2.5%,缝的颜色接近石色(#a29f98),倒影下面才是一片湿石板 |
+
## 四、做成动画
- 各画风都有 `stage(name)` 和 `save(path, stages_dir)`,按阶段依次淡入叠化,就是「一幅画被逐步画出来」。README 里的动图就是这样做的。
@@ -2552,6 +2599,13 @@ from core import spline, curve, blob_pts, fbm1d, blur, polygon_mask
- 调色板:第一帧(空纸)只给 12 色;228 色从和它不同的像素切(末帧 ×3),饱和色 ×2(雨衣、金黄的树、灯笼、屋顶、野花)、偏暗的绿和褐 ×1.5(苔藓、龟壳的沟和背光面、肚子底下的阴影)、接近纸色的浅色 ×1.5(纸齿白点、白云);再留 14 色,其中 3 个是强制的(最深的褐、纸色、灯笼的光),另外 11 色只从末帧误差最大(> 16 级)的像素里切。
- 固定 4×4 Bayer(去掉反而更大)。和屏上已显示颜色差不到 5 级(叠化帧)或 3 级(关键帧)的像素沿用上一帧,末帧精确发送。
- 结果:55 帧、14.75 秒、约 0.99 MB,按解码结果逐帧自检,末帧 p99 误差 20。
+- 彩色小镇的动图(脚本在 `workspace_projects/xhs_colortown/work/make_gif_colortown.py`):
+ - 竖幅,所以是 540×720(长边 720,和横幅的 720×405 一致)。
+ - 阶段:暖白空纸 → 天空和云 → 远处的小镇和钟楼(山上两串小彩旗)→ 上面两排房子和两棵树 → 拱门房子、台阶和广场边的房子 → 两侧的峡谷墙 → 玫瑰、花盆、店招和壁灯 → 近处的彩旗 → 湿广场和倒影 → 成品(行人、路灯、咖啡桌、反光)。每段 900 毫秒加 5 帧叠化,末帧停 2600 毫秒。
+ - 叠化一片片铺上去,和暖调彩铅绘本的做法一样:每个像素只在 5 帧中的约 2 帧里完成过渡,先后由柔和的低频噪声加从上往下的扫过决定,像下一层水粉一块块盖上去。
+ - 调色板:240 色中值切分,取样时末帧 ×3、饱和色 ×3(彩旗、玫瑰、红门)、暗色 ×2(墨线、玻璃、石板暗部),再加每段叠化中间一帧的样本;另从末帧误差超过 14 级的像素里切 15 色;最后 1 色是纯品红,当「和上一帧相同」的透明占位色。
+ - 固定 4×4 Bayer(约 ±2.4 级)。和屏上已显示颜色差不到 5 级(叠化帧)或 3 级(关键帧)的像素沿用上一帧,末帧精确发送;整帧都没变的叠化帧不单独发,时长并到上一帧。
+ - 结果:46 帧,14.75 秒,约 1.33 MB,按解码结果逐帧自检,末帧误差中位数 6、p99 27。颜色很多,255 色不够细,比暖调彩铅绘本的 p99 20 差一点,肉眼看不出。
- 绘本角色动画的动图是真动画,不是阶段叠化:`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 遮罩按顺序显现。这个还没做成现成接口。
@@ -2634,6 +2688,7 @@ lib/obsidianui.py 笔记应用界面(近黑页面与淡紫光晕;距离
lib/canvasboard.py 白板卡片(保留式绘制:所有形状按白板坐标记进有名字的节点,每次按镜头重画;距离场抗锯齿的圆角矩形、圆、环,逐段只算包围盒的折线和虚线,4 倍超采样的多边形,CSS box-shadow;节点的位姿和进度变量(fade / draw / reveal / pop),tween 出中间阶段,drop 缓动;随镜头移动缩放的点阵;应用窗口、标签栏、图标栏、缩放按钮、鼠标指针和点击波纹;分组框、卡片色边和淡色底、选中光圈、举起的大阴影、图片卡片和方格纸;行内 Markdown(高亮、行内代码、粗体)、会打勾的清单、引用、标签胶囊、颜色胶囊、进度条;沿法线出入的三次曲线连线、箭头和标签;手绘抖线、椭圆和弧、箭头;苹方 + SF Pro + SF Mono + 手札体,浮点字号)
lib/flexoki.py Flexoki 纸面(Flexoki 色板与角色名、浅色 / 深色主题;有符号距离场的圆角矩形、圆、环、精确菱形、圆柱、扇形与折线,1 px 解析抗锯齿;带弧长的折线:按进度画出、沿弧长虚线、在箭头下截短,三次曲线、按切线出入的曲线、倒圆角折线;4 倍超采样的小三角箭头;先合成再放下的节点组;苹方加假粗的粗黑标题、SF Pro 可变字重、SF Mono;带姿态的图层与 fresh 重画;卡片、聚焦框、胶囊、步骤胶囊、大数字、轨道条、窗口、虚线框、宽度标注、代码行;流程图的框和边、时序图的生命线 / 激活条 / 消息 / 便签、饼图、图例、柱状图、表格)
lib/pencilbook.py 暖调彩铅绘本(以 1 px 细颗粒为主的直方图均衡纸纹与沿 8 个方向拖开的纸纹,纸坑里留的一点蜡和越叠越深的蜡层缓冲;在方向场里积分出中心线、带手腕弧度的铅笔笔触;id 图光栅化:Pillow 按序号画折线、2 倍超采样,numpy 只对被盖住的子像素查回这一笔,算出沿笔位置和压力曲线,蜡只落在压力够得着的纸纹上,bincount 汇回像素;抖动网格落笔、逐像素压力的平滑过渡、留白(avoid);半透明的蜡混色与压光;软穹顶受光和照彩铅画家顺序的分层塑形:浅色底、固有色、同色系暗部、最深处、暖色和冷色罩染、交叉角度;漂移、等值线、放射方向场与双倍角混合;根部散开尖端聚拢、有亮面暗面的毛绺,整张毛皮,散开的草丛,树冠的叶簇;顺着表面的暖色发光笔触与带纸纹的提亮,亮灯的窗,提亮;镜像取样的横排线倒影、断开的涟漪圈;分别打光的团块树冠、小房子、石头、鳞片、野花、纸灯笼、雨衣小孩、点点眼和腮红;很淡的同色轮廓、几笔叠成的软线;轻微柔化、细颗粒、暖色暗角)
+lib/colortown.py 彩色小镇(id 图光栅化的不透明色块:Pillow 按序号填多边形、2 倍超采样,numpy 查颜色 / 不透明度 / 纹理权重表、box 平均回像素;整张预算的竖向、横向笔刷条纹和擦笔纹理加低频斑驳,按块取权重,浅色少一点;边缘重采样后沿法线抖动;深棕半透明墨线:3 倍 id 图、带圆角接头的折线,分段变粗细,方框四边分开画、转角偶尔出头,按底色乘出深红棕或近黑;远近雾化与细线;把平摊布局贴到四边形上的透视单应;联排房子生成器:灰泥墙、裸石斑块、腰线、檐口、墙脚罩染和檐下阴影,门、带字招牌和条纹遮阳篷的店面、拱门,每扇略不同的窗(窗框、带反光的玻璃、窗棂、窗台、带横条的百叶窗、窗帘、圆窗和拱窗),溢出来的窗台花箱,铁艺阳台和花盆;一片片错缝铺、裁切、描缝的石板和赤陶瓦,曼莎、四坡、侧山墙、尖山墙,老虎窗、烟囱和烟囱帽、电视天线、风向标;带隅石、钟面、木百叶钟楼开口、洋葱顶、灯笼亭、尖顶和旗的钟楼;越往上越小的台阶、石墙、铁栏杆;杯形花瓣的爬藤玫瑰,按穹顶打光的叶簇树冠,花盆;抛物线下垂、带折痕的三角彩旗串;路灯和壁灯、吊挂店招、海报、咖啡桌、猫、不画脸的小人(伞、气球、花篮);透视石板、逐列镜像并竖向拖尾的湿街倒影、重描的石板缝和反光,把之后画的东西也倒映下来的 mirror;轻微柔化、细颗粒、暖色、淡暗角)
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/colortown_festival_steps.jpg b/examples/colortown_festival_steps.jpg
new file mode 100644
index 0000000..230b11c
Binary files /dev/null and b/examples/colortown_festival_steps.jpg differ
diff --git a/examples/colortown_festival_steps.py b/examples/colortown_festival_steps.py
new file mode 100644
index 0000000..f1aec16
--- /dev/null
+++ b/examples/colortown_festival_steps.py
@@ -0,0 +1,298 @@
+"""Example (colour town): 雨后的节日台阶街 · Festival Steps After the Rain -- a dense, cheerful hill town in gouache
+and fine ink.
+
+Morning, just after a shower, on a festival day. A lane of stone steps climbs from a wet little square, passes under
+a mint-green house that bridges the lane on an archway, and goes on up the hill. Tall narrow houses in tomato red,
+mustard, teal, mint, coral and cream are piled up the slope behind it, row above row, under blue-grey slate mansard
+roofs with dormers, chimney pots and TV aerials; a white clock tower with an onion dome stands on top of the hill
+on the left, and the sky is pale blue with creamy clouds. On the left the street is a canyon wall that runs away
+toward the vanishing point; on the right a tall house with a cafe stands close to us. Strings of bunting cross the
+street at four depths. Red roses climb the walls, window boxes overflow, there are iron balconies, a flower shop and
+a bakery, a lamp post, hanging signs, a cat on the steps, and a few people out early -- one with an umbrella, a child
+with a red balloon. The square is still wet and mirrors all of it.
+
+Gouache and ink: every surface is flat opaque colour with a little brush texture (walls in vertical strokes, the sky
+and the paving in horizontal ones), and almost everything has a fine, slightly shaky dark-brown ink line; slates are
+laid one by one, windows are each a little different, pennants have a darker fold.
+
+Painted back to front, the way an illustrator works: paper -> sky -> far town and clock tower -> the upper rows ->
+the bridge-house, the steps and the houses on the square -> the canyon walls -> roses, flowers and signs -> the near
+bunting -> the wet square and its reflections -> people, the lamp and the last glints.
+--stages writes those steps as snapshots for the draw-on. No image model.
+python3 colortown_festival_steps.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 colortown import ColorTown, _homography
+
+W, H = 1500, 2000
+VP = (700, 1180) # vanishing point (eye level)
+PLAZA = 1640 # where the houses on the square stand
+NEAR_R = 1900 # foot of the near house on the right
+# the canyon wall on the left: a flat layout of 900 x 2200 laid onto this quad (near edge off-canvas)
+CANYON_SRC = (0, 0, 900, 2200)
+CANYON_DST = [(-80, -358), (300, 391), (300, 1650), (-80, 2096)]
+CH = _homography([(0, 0), (900, 0), (900, 2200), (0, 2200)], CANYON_DST)
+
+
+def canyon(x, y):
+ q = CH @ np.array([x, y, 1.0])
+ return q[0] / q[2], q[1] / q[2]
+
+
+def base_line():
+ """the line each column's reflection is mirrored about"""
+ xs = np.arange(W, dtype=np.float32)
+ b = np.full(W, PLAZA, np.float32)
+ b[xs < 300] = 1650 + 1.175 * (300 - xs[xs < 300])
+ b[xs >= 1180] = NEAR_R
+ return b
+
+
+class Scene:
+ def __init__(self, t):
+ self.t = t
+
+ # ------------------------------------------------------------------ sky
+ def sky(self):
+ t = self.t
+ t.sky(y1=1150)
+ t.clouds([(960, 300, 520, 170), (640, 150, 300, 95), (1200, 140, 260, 80), (300, 560, 260, 80)])
+ t.birds((760, 380, 980, 470), n=4, size=(6, 10))
+
+ # ------------------------------------------------------------------ far town and the clock tower
+ def row(self, x0, x1, base, wr, hr, fl, seed, slope=0.0, jitter=20, boxes=0.5, palette=None, tiles=0.15,
+ pointy=0.22, tower=0.12, chimneys=True):
+ """a storybook-irregular row of houses climbing the hill: widths, heights, bases and roofs all vary"""
+ t = self.t
+ r = np.random.default_rng(seed)
+ pal = palette or ('tomato', 'white', 'mustard', 'teal', 'cream', 'coral', 'mint', 'butter', 'cerulean',
+ 'ivory', 'salmon', 'jade', 'yellow', 'pink', 'powder', 'white')
+ x, prev = x0, None
+ while x < x1 - 12:
+ narrow = r.random() < tower
+ w = r.uniform(wr[0] * 0.62, wr[0] * 0.8) if narrow else r.uniform(*wr)
+ if x1 - (x + w) < wr[0] * 0.55: w = x1 - x
+ b = base + slope * (x - x0) + r.uniform(-jitter, jitter * 0.5)
+ h = r.uniform(*hr) * (1.25 if narrow else 1.0)
+ c = prev
+ while c == prev: c = pal[r.integers(0, len(pal))]
+ prev = c
+ u = r.random()
+ if narrow or u < pointy:
+ rf, rh = 'gable', w * r.uniform(0.75, 1.0)
+ else:
+ rf = ('mansard', 'mansard', 'hip', 'side', 'gable')[r.integers(0, 5)]
+ rh = w * (0.42 if rf != 'gable' else 0.6)
+ light = c in ('white', 'cream', 'ivory', 'butter', 'pale_yellow')
+ sh = ('cobalt', 'jade', 'tomato', 'cerulean', 'mint')[r.integers(0, 5)] if (light and r.random() < 0.7) else None
+ t.house(x, b, w, h, c, roof=rf, roof_h=rh, floors=max(3, int(round(h / fl))),
+ cols=max(1 if narrow else 2, int(round(w / (fl * 1.0)))), boxes=boxes, shutters=sh,
+ chimneys=(1 + (w > wr[1] * 0.8)) if chimneys else 0, aerials=0.6, ground=None,
+ roof_col='tile' if r.random() < tiles else 'slate', stones=2 if light and r.random() < 0.5 else 0,
+ bands=r.random() < 0.7, seed=int(r.integers(1 << 30)),
+ top_window=('round', 'round', 'std', 'arch')[r.integers(0, 4)])
+ x += w
+
+ def far(self):
+ t = self.t
+ with t.depth(0.42):
+ t.lw = 0.8
+ self.row(300, 600, 905, (62, 92), (140, 200), 34, seed=201, boxes=0.3)
+ self.row(600, 1190, 830, (80, 115), (220, 300), 36, seed=202, slope=-0.2, boxes=0.3)
+ t.lw = 1.25
+ with t.depth(0.12):
+ self.tower = t.clock_tower(432, 960, 112, 660, time=(9, 4), seed=5, dome='verdigris')
+ with t.depth(0.3):
+ t.lw = 0.95
+ self.row(300, 520, 1010, (82, 112), (170, 230), 48, seed=207, boxes=0.45, pointy=0.0, tower=0.0)
+ self.row(520, 1190, 975, (82, 122), (230, 330), 48, seed=203, slope=-0.14, boxes=0.45)
+ t.bunting((470, 760), (905, 690), sag=40, size=11, seed=3)
+ t.bunting((600, 860), (1180, 780), sag=46, size=11, seed=4)
+
+ # ------------------------------------------------------------------ the upper rows and the trees
+ def upper(self):
+ t = self.t
+ with t.depth(0.16):
+ t.lw = 1.1
+ self.row(300, 1190, 1150, (100, 148), (280, 440), 60, seed=204, slope=-0.08, boxes=0.55)
+ with t.depth(0.06):
+ t.lw = 1.25
+ self.row(300, 562, 1305, (118, 145), (320, 400), 70, seed=205, boxes=0.6, tower=0.0)
+ self.row(858, 1190, 1295, (125, 175), (340, 440), 70, seed=206, boxes=0.6, tower=0.0)
+ t.lw = 1.4
+ t.tree(396, 1330, 520, 138, seed=22, clumps=13, lean=0.02)
+ t.tree(1108, 1300, 525, 112, seed=21, clumps=11, lean=-0.02)
+ t.lw = 1.25
+ t.bunting((310, 1010), (1180, 930), sag=70, size=17, seed=6)
+
+ # ------------------------------------------------------------------ the bridge-house, the steps, the square
+ def steps(self):
+ t = self.t
+ # the glimpse through the archway: more steps going on up, a sunny wall, a pot, someone climbing
+ t.lw = 1.0
+ t.fill([(640, 1270), (780, 1270), (780, 1420), (640, 1420)], 'butter', tex=0.9)
+ t.flush()
+ t.stairs((648, 772, 1412), (686, 734, 1330), n=9, seed=31)
+ t.pot(752, 1372, 14, 12, plant='flowers', flowers='red', seed=32)
+ t.person(700, 1352, 26, coat='tomato', reflect=False, seed=33)
+ # the bridge-house over the lane
+ t.lw = 1.4
+ self.bridge = t.house(560, 1412, 300, 400, 'mint', roof='mansard', roof_h=78, floors=5, cols=4, win_w=0.34,
+ boxes=0.7, flowers='red', shutters=None, ground='arch', arch_w=0.42, chimneys=2,
+ aerials=1.0, seed=34, frame='white', balconies=[(2, 1), (2, 2)])
+ # the side walls of the houses flanking the lane, receding toward the vanishing point
+ for (xa, xb, ya, yb, c) in ((600, 648, 1180, 1412, 'tomato'), (820, 772, 1150, 1412, 'yellow')):
+ t.fill([(xa, ya), (xb, ya + (xb - xa) * 0.1), (xb, yb), (xa, PLAZA)], c, tex=0.9)
+ t.fill([(xa, ya), (xb, ya + (xb - xa) * 0.1), (xb, yb), (xa, PLAZA)], '#2a2a40', alpha=0.25, tex=0)
+ t.ink([(xb, ya + (xb - xa) * 0.1), (xb, yb)], 1.2)
+ t.flush()
+ t.lw = 1.5
+ t.stairs((602, 818, PLAZA), (648, 772, 1412), n=15, seed=35, ratio=1.07)
+ # low stone parapets along the steps, with iron rails on top
+ t.parapet([(588, 1572), (640, 1370)], [(600, PLAZA), (648, 1412)], seed=36, course=10)
+ t.parapet([(780, 1370), (832, 1572)], [(772, 1412), (820, PLAZA)], seed=37, course=10)
+ t.railing([(594, 1566), (644, 1368)], 34, seed=38)
+ t.railing([(776, 1368), (826, 1566)], 34, seed=39)
+ t.cat(806, 1556, 26, seed=40)
+ # the houses on the square
+ t.lw = 1.6
+ t.house(298, PLAZA, 158, 560, 'teal', roof='mansard', roof_h=72, floors=5, cols=2, win_w=0.46, boxes=0.6,
+ ground='shop', shop='cream', sign='FLEURS', letters='teal_deep', awning=('teal_deep', 'ivory'), shutters=None, frame='cream',
+ chimneys=1, seed=41, balconies=[(2, 0)])
+ t.house(456, PLAZA, 146, 440, 'tomato', roof='gable', roof_h=130, floors=4, cols=2, win_w=0.44, boxes=0.6,
+ ground='door', door_col='teal', shutters='mint', chimneys=1, seed=42, top_window='round')
+ t.house(820, PLAZA, 156, 470, 'yellow', roof='hip', roof_h=66, floors=4, cols=2, win_w=0.44, boxes=0.65,
+ ground='door', door_col='cobalt', shutters='cobalt', chimneys=1, seed=43, frame='white')
+ t.house(976, PLAZA, 230, 600, 'coral', roof='mansard', roof_h=84, floors=5, cols=3, win_w=0.42, boxes=0.6,
+ ground='shop', shop='cobalt', sign='PAIN', awning=('tomato', 'cream'), chimneys=2, seed=44,
+ balconies=[(3, -1)], frame='cream')
+ t.lw = 1.4
+ t.bunting((456, 1170), (976, 1110), sag=78, size=24, seed=7)
+ t.bunting((300, 1320), (600, 1395), sag=30, size=20, seed=8)
+
+ # ------------------------------------------------------------------ the canyon walls
+ def canyon(self):
+ t = self.t
+ t.lw = 2.0
+ with t.plane(CANYON_SRC, CANYON_DST):
+ t.house(0, 2200, 345, 2070, 'blush', roof=None, floors=8, cols=2, win_w=0.42, boxes=0.6, shutters=None,
+ ground='door', door_col='teal', stones=5, chimneys=0, aerials=0, seed=51, balconies=[(3, 0), (5, 1)])
+ t.house(345, 2200, 300, 1880, 'white', roof='mansard', roof_h=170, floors=7, cols=2, win_w=0.44,
+ boxes=0.6, shutters='jade', ground='door', door_col='tomato', chimneys=2, aerials=1.0, seed=52,
+ dormers=1, chimney_col='brick', stones=4)
+ t.house(645, 2200, 255, 1760, 'pale_yellow', roof='mansard', roof_h=170, floors=7, cols=2, win_w=0.44, boxes=0.55,
+ ground='shop', shop='teal_deep', chimneys=1, aerials=1.0, seed=53, dormers=1, chimney_col='cream')
+ for i, (sx, sy, c) in enumerate(((150, 1930, 'butter'), (215, 1965, 'tomato'), (420, 1950, 'mint'),
+ (470, 1915, 'pink'), (560, 1975, 'cerulean'))):
+ t.poster(sx, sy, sx + 48, sy + 66, c, seed=55 + i)
+ # the near house on the right, close to us
+ t.lw = 2.1
+ self.right = t.house(1180, NEAR_R, 380, 1830, 'ivory', roof='mansard', roof_h=150, floors=8, cols=3,
+ win_w=0.42, boxes=0.65, shutters='powder', shutter_p=0.3, ground='shop', shop='teal_deep', sign='CAFÉ',
+ awning=('teal', 'ivory'), stones=6, chimneys=1, seed=61, balconies=[(2, 0), (2, 1), (5, 0)],
+ curtains=0.5)
+
+ # ------------------------------------------------------------------ roses, flowers, signs
+ def flowers(self):
+ t = self.t
+ t.lw = 1.6
+ # roses climbing the canyon wall, the corner by the steps, the near house and the bridge-house
+ P = [canyon(x, y) for x, y in ((250, 2190), (268, 1900), (240, 1600), (275, 1300), (250, 1000), (280, 760))]
+ t.roses(P, n=60, size=11, seed=71, colour='rose_pink', dark='rose_pink_dark', light='blossom_white')
+ P = [canyon(x, y) for x, y in ((660, 2190), (680, 1950), (655, 1700), (690, 1500))]
+ t.roses(P, n=30, size=6.5, seed=72, colour='rose_pink', dark='rose_pink_dark', light='blossom_white')
+ t.roses([(826, 1630), (832, 1500), (826, 1380), (836, 1250)], n=34, size=7, seed=73)
+ t.roses([(1196, 1890), (1205, 1700), (1196, 1500), (1210, 1300), (1200, 1120)], n=55, size=11, seed=74)
+ t.roses([(566, 1410), (576, 1300), (566, 1190), (578, 1090)], n=22, size=5.5, seed=75)
+ # the flower shop's buckets and pots along the square
+ for i, x in enumerate((318, 344, 370, 396, 422)):
+ t.pot(x, PLAZA + 6, 22, 20, plant='flowers', flowers=('pink', 'red', 'sunny', 'violet', 'white')[i], seed=80 + i)
+ t.pot(600, PLAZA + 2, 30, 28, plant='bush', seed=86)
+ t.pot(950, PLAZA + 4, 26, 24, plant='tall', seed=87)
+ t.pot(1460, NEAR_R + 6, 34, 32, plant='bush', seed=89)
+ for i, sx in enumerate((150, 320, 470, 600, 780)):
+ x, y = canyon(sx, 2200)
+ t.pot(x + 14, y - 4, 40 - i * 4, 36 - i * 4, plant=('flowers', 'bush', 'tall', 'flowers', 'bush')[i],
+ flowers=('red', 'pink', 'sunny', 'violet', 'red')[i], seed=95 + i)
+ # hanging signs and a wall lamp
+ t.lw = 1.8
+ t.sign(1180, 1560, 30, 'tomato', icon='cup', side=-1, seed=90)
+ x, y = canyon(330, 1700)
+ t.sign(x, y, 26, 'jade', icon='key', side=1, seed=91)
+ x, y = canyon(640, 1830)
+ t.sign(x, y, 20, 'mustard', icon='loaf', side=1, seed=92)
+ x, y = canyon(345, 1400)
+ t.lamp(x + 46, y + 10, 40, wall=x, seed=93)
+
+ # ------------------------------------------------------------------ the near bunting
+ def bunting(self):
+ t = self.t
+ t.lw = 2.0
+ t.bunting(canyon(250, 1000), (1190, 760), sag=170, size=40, seed=11)
+ t.bunting(canyon(120, 760), (1190, 380), sag=200, size=50, seed=12)
+ t.bunting(canyon(500, 1500), (1190, 1330), sag=90, size=32, seed=13)
+ t.bunting(canyon(20, 1500), (1180, 1500), sag=150, size=56, seed=14)
+
+ # ------------------------------------------------------------------ the wet square
+ def street(self):
+ t = self.t
+ src = t.C.copy()
+ poly = np.array([(1, 2000), (300, 1650), (300, PLAZA), (1180, PLAZA), (1180, NEAR_R), (1500, NEAR_R),
+ (1500, 2000)], np.float32)
+ t.street(PLAZA, VP, poly=poly, seed=101)
+ region = t.mask(poly, soft=0.8)
+ t.reflect(src, base_line(), PLAZA, strength=0.58, region=region, seed=102)
+ t.joints(alpha=0.28, seed=104)
+ t.glints(PLAZA + 10, 2000, n=45, seed=103, region=region)
+
+ # ------------------------------------------------------------------ people and the lamp post
+ def people(self):
+ t = self.t
+ t.lw = 1.5
+ with t.mirror(1800, 1080, 1160, 1430, strength=0.5):
+ t.lamp(1120, 1800, 300, seed=110)
+ with t.mirror(PLAZA + 30, 980, 1060, 1580, strength=0.45):
+ t.bistro(1020, PLAZA + 30, 40, seed=115)
+ for bx in (1240, 1450):
+ t.bistro(bx, 1988, 60, seed=int(bx))
+ with t.mirror(1700, 520, 640, 1600, strength=0.4):
+ t.person(560, 1700, 82, coat='tomato', seed=116, facing=1, legs='#33384a')
+ t.person(590, 1702, 76, coat='cream', seed=117, facing=1, hair='hair_light')
+ with t.mirror(1830, 400, 560, 1580, strength=0.4):
+ t.person(470, 1830, 104, coat='mustard', legs='#2f3c55', balloon='rose', seed=111, facing=1)
+ with t.mirror(1760, 800, 980, 1600, strength=0.4):
+ t.person(890, 1760, 120, coat='cobalt', umbrella='tomato', seed=112, facing=-1)
+ with t.mirror(1958, 1260, 1440, 1780, strength=0.35):
+ t.person(1348, 1958, 140, coat='jade', basket='red', seed=113, facing=-1, legs='#3a3340')
+ t.person(690, 1610, 62, coat='coral', seed=114, facing=1)
+
+
+PHASES = (('sky', 'sky'), ('far', 'far'), ('upper', 'upper'), ('steps', 'steps'), ('canyon', 'canyon'),
+ ('flowers', 'flowers'), ('bunting', 'bunting'), ('street', 'street'), ('people', 'people'))
+
+
+def main():
+ out = sys.argv[1] if len(sys.argv) > 1 and not sys.argv[1].startswith('--') else 'colortown_festival_steps.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:10s} {time.time() - T0:5.1f}s')) if os.environ.get('CT_TIMING') else (lambda n: None)
+ t = ColorTown(W, H, seed=12, keep_stages=bool(stages), stages_dir=stages)
+ t.finish()
+ t.paper()
+ t.stage('paper')
+ sc = Scene(t)
+ tick('setup')
+ for name, ph in PHASES[:-1]:
+ getattr(sc, ph)()
+ tick(name)
+ t.stage(name)
+ getattr(sc, PHASES[-1][1])()
+ tick(PHASES[-1][0])
+ t.save(out, stages_dir=stages)
+ print('saved', out, f'{time.time() - T0:.1f}s', t.n_fills, 'fills', t.n_lines, 'lines')
+
+
+if __name__ == '__main__':
+ main()
diff --git a/examples/drawing_colortown_festival_steps.gif b/examples/drawing_colortown_festival_steps.gif
new file mode 100644
index 0000000..453eb9e
Binary files /dev/null and b/examples/drawing_colortown_festival_steps.gif differ
diff --git a/lib/colortown.py b/lib/colortown.py
new file mode 100644
index 0000000..02e2d94
--- /dev/null
+++ b/lib/colortown.py
@@ -0,0 +1,2002 @@
+"""colortown — 彩色小镇 / Colour Town: a dense, cheerful European hill town in gouache and fine ink (numpy + Pillow only).
+
+The look: a storybook street of tall, narrow, brightly painted townhouses piled up a hillside -- tomato red, mustard,
+teal, mint, coral, cream -- under blue-grey slate mansard roofs with dormers, chimney pots, TV aerials and weather
+vanes; a white clock tower above them against a pale sky with creamy clouds; strings of triangular bunting
+criss-crossing the street at several depths; climbing red roses, window boxes, iron balconies, stone steps with
+railings, lamps, hanging signs, shopfronts and painted doors; and a wet street in front that mirrors all of it.
+Painted the way an illustrator paints it in gouache: flat opaque colour with a little brush texture, then a fine,
+slightly shaky dark-brown ink line around almost everything. Soft light, almost no cast shadows, and more small
+things than the eye can finish looking at.
+
+Physical model
+ paper A warm white sheet with a fine tooth (`paper()`); it shows only where nothing is painted and, very
+ faintly, through everything as a grain at the end.
+ gouache Gouache is opaque and dries matte: a coat replaces what is under it. A fill is a polygon; thousands of
+ them are rasterised in one go: Pillow fills each polygon with its own integer id into a 2x
+ supersampled id map (painter's order = id order, later fills cover earlier ones), numpy looks every
+ id up in a table (colour, alpha, texture weights) and box-averages back to 1x, so every edge is
+ anti-aliased and a fill costs a few microseconds. A coat is never perfectly even: three texture fields
+ precomputed for the whole canvas -- vertical brush streaks, horizontal brush streaks and an isotropic
+ scumble -- plus a low-frequency mottle modulate its value by a few percent, each fill choosing how much
+ of which (walls: vertical streaks; sky, bands and street: horizontal; roofs and foliage: scumble).
+ Polygon edges are resampled every few px and pushed sideways by a smooth random wobble, so long edges
+ are hand-straight, not ruler-straight, and the colour never registers exactly with its ink line.
+ ink A fineliner / dip-pen line in dark warm brown, drawn after the colour of the same group (`flush()`):
+ each line is its own id in a 3x id map (Pillow lines with round joints), so crossings do not bead;
+ long lines are split into pieces of slightly different width, every line is resampled and wobbled by
+ a low-frequency hand tremor, and the corners of boxes are separate strokes that sometimes overshoot.
+ Ink is half transparent: on cream it reads dark brown, on red a deep red-brown, on glass nearly black.
+ depth `far` (0 near .. 1 very far, a context or an argument) pulls colours toward the pale blue haze of the
+ sky and makes lines thinner and lighter; scale does the rest (near houses have big windows, the far
+ ones tiny), with overlap from painting back to front.
+ planes Everything is drawn in canvas px. `plane(src, dst)` sets a homography that maps a rectangle onto a
+ quad, so a whole facade can be laid out flat and then receded in one-point perspective (a canyon wall
+ down the side of the street); line widths follow the local scale.
+ houses `house()` builds a whole townhouse from a few numbers: wall (plaster with bare-stone patches, painted
+ boards, string courses, a cornice), ground floor (door, shopfront with fascia lettering and awning, or
+ an archway), a grid of windows that are each a little different (cream frames, dark teal glass with a
+ light reflection, glazing bars, sills, shutters with slats, curtains, round and arched variants), window
+ boxes overflowing with flowers, iron balconies with pots, then the roof: slate laid tile by tile in
+ staggered courses (each slate its own blue-grey, clipped to the roof, joints inked), mansard / hip /
+ gable / side-gable shapes, dormers, chimneys with pots, aerials. The returned dict gives the windows,
+ the roof line and anchor points for bunting and roses.
+ plants Climbing roses: a wandering stem up a wall, pairs of small dark leaves along it, red (or pink) roses as
+ discs with a darker spiral of petals and a light lip, buds, clustered toward the top. Trees: a trunk
+ and branches in ink, a crown of clumps, each a dark base and many small leaf dabs coloured by a dome
+ light (light from the upper left). Window boxes and pots: leaves first, then flower dabs.
+ bunting A string sagging between two points (a parabola), pennants hanging from it at even spacing, each a
+ triangle following the string's slope with a darker fold on one half, colours from a cheerful cycle,
+ inked; strings are painted at several depths (small far ones between far houses, big near ones last).
+ street Paving in perspective (rows of rounded stones whose joints run toward the vanishing point), then the
+ wet look: the picture above the street is mirrored about each column's base line, pushed sideways by
+ ripples, smeared vertically (more the further from the base), darkened and mixed into the stone colour
+ with vertical brush streaks; joints and light glints go on top.
+ shading Almost none, as in the look: a wall gets a thin multiply glaze that deepens toward its foot and a soft
+ band of shade under its cornice (`glaze()`); light colours carry less brush texture than strong ones,
+ so a white wall stays clean instead of looking grubby.
+ finish `finish()` records a slight softening, the paper grain and a gentle warm light (applied in render, so
+ every stage snapshot matches the final look).
+
+API (canvas px; colours are names in PAINTS or '#rrggbb'; `lw` is the ink line width in px, `t.lw` the default)
+ surface ColorTown(W, H, seed, keep_stages, stages_dir); paper(tone); finish(soft, grain, warmth, vignette)
+ low level fill(pts, colour, tex, dir, mot, hand, alpha, vary) -- dir 0 / 1 / 2 or a weight triple (PLASTER);
+ ink(pts, width, closed, alpha, colour, hand, corners, over); box(x0, y0, x1, y1, colour); flush(clip);
+ depth(far) and plane(src, dst) contexts; dab(x, y, r, colour); leaf(x, y, length, width, angle, colour);
+ glaze(P, colour, top, bottom); mask(P, soft); paint_mask(mask, colour, alpha, tex, dir, sl); text(cx, cy, s, size)
+ shapes rect(), arch(), ellipse_pts(), leaf_pts() (module functions returning point arrays)
+ sky sky(top, mid, bottom, y1); clouds([(cx, cy, w, h)]); birds(region, n)
+ buildings house(x, base, w, h, wall, roof, roof_h, roof_col, floors, cols, frame, shutters, shutter_p, curtains,
+ boxes, flowers, balconies, ground ('door' | 'shop' | 'arch' | None), shop, sign, letters, awning, stones,
+ boards, bands, chimneys, dormers, aerials, top_window, ...) -> info (windows, roof, ridge, chimneys);
+ window(x0, y0, x1, y1, kind, frame, glass, panes, shutters, curtains, lintel); door(...); shopfront(...);
+ awning(...); balcony(...); flowerbox(...); roof(kind, x0, x1, y, h, colour, dormers); dormer(...);
+ slates(P, tile, ramp); chimney(...); aerial(...); vane(...); patches(...);
+ clock_tower(cx, base, w, h, dome, time, flag); stairs(bottom, top, n); parapet(top, bottom); railing(path, h)
+ street street(y0, vp, poly); reflect(src, base, y0, strength, smear, ripple, region); joints(alpha);
+ mirror(base, x0, x1, top, strength) context (reflect what is painted inside it); glints(y0, y1, n)
+ plants roses(path, n, colour, dark, light, size); tree(x, base, h, rad, clumps, leaf); pot(x, base, w, h, plant)
+ props bunting(p0, p1, sag, size, colours); lamp(x, base, h, wall); sign(wall_x, y, r, colour, icon, side);
+ person(x, base, h, coat, umbrella, balloon, basket, facing); cat(x, base, s); bistro(x, base, s);
+ poster(x0, y0, x1, y1, colour)
+ 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 colortown import ColorTown
+ t = ColorTown(1500, 2000, seed=3); t.finish(); t.paper()
+ t.sky(); t.clouds([(1000, 260, 420, 160)])
+ t.house(200, 1500, 300, 700, 'tomato', roof='mansard', floors=4, cols=3)
+ t.bunting((0, 600), (1500, 700), sag=80, size=40)
+ t.save('town.jpg')
+"""
+import io
+import os
+from contextlib import contextmanager
+import numpy as np
+from PIL import Image, ImageDraw
+from core import blur, fbm1d, spline, noise2d, smoothstep, load_font
+
+PAINTS = {
+ # paper and ink
+ 'paper': '#f5f0e4', 'ink': '#2a1f1b', 'ink_soft': '#5a4a40', 'iron': '#25252b',
+ # sky
+ 'sky_top': '#8ec6d6', 'sky': '#a6d3dd', 'sky_low': '#d3e9e5', 'haze': '#cfe2e0',
+ 'cloud': '#fcf8ee', 'cloud_shade': '#e9e1d4', 'cloud_warm': '#f8e8d6',
+ # walls -- saturated but soft gouache
+ 'tomato': '#d9493a', 'red': '#c93a30', 'brick': '#b9563d', 'coral': '#e9806a', 'salmon': '#ef9f87',
+ 'pink': '#eda7a0', 'rose_wall': '#e48d8c', 'mustard': '#e2b03f', 'ochre': '#d99b43', 'yellow': '#efc65a',
+ 'butter': '#f3d98e', 'orange': '#e9813d', 'apricot': '#f0a35e', 'teal': '#3f998e', 'teal_deep': '#2e7a74',
+ 'jade': '#58ae9f', 'mint': '#9cd2bd', 'aqua': '#7fc5c3', 'turquoise': '#4bb0ad', 'blue': '#4d7fb3',
+ 'cobalt': '#3d679f', 'powder': '#a8c7dc', 'cerulean': '#5aa2c8', 'green': '#5e9a5c', 'sage': '#a6c193',
+ 'cream': '#f5ead2', 'ivory': '#faf3e3', 'blush': '#f3c9bd', 'pale_yellow': '#f5e2a8', 'pale_mint': '#cfe7d8', 'white': '#fbf8f0', 'stone': '#d9cfbe', 'stone_mid': '#c2b5a2',
+ 'stone_dark': '#a39482', 'warmgrey': '#bdb1a2', 'lavender': '#b9a8cf',
+ # roofs
+ 'slate': '#3f536b', 'slate_dark': '#2c3a4d', 'slate_light': '#60788f', 'slate_blue': '#4b6585',
+ 'tile': '#c4613e', 'tile_dark': '#9d4a33', 'verdigris': '#5c9c8a', 'copper': '#b7703f',
+ # glass, wood, metal
+ 'glass': '#30515a', 'glass_light': '#5f8a8f', 'glass_dark': '#1f363d', 'curtain': '#f4ead8',
+ 'wood': '#9b6b46', 'wood_dark': '#6e4a32', 'gold': '#d9a83c',
+ # plants
+ 'leaf_dark': '#2c5a36', 'leaf': '#4b8645', 'leaf_mid': '#679f4f', 'leaf_light': '#9cc263', 'leaf_pale': '#c8dc8a',
+ 'trunk': '#7a5a44', 'rose': '#d8312d', 'rose_dark': '#951d22', 'rose_light': '#f06a5c',
+ 'rose_pink': '#ef8fa0', 'rose_pink_dark': '#c4566e', 'blossom_white': '#fbf4ee', 'blossom_yellow': '#f3cf4f',
+ 'blossom_orange': '#f08c3c', 'blossom_purple': '#a77fc6', 'blossom_pink': '#f2a2b4',
+ 'terracotta': '#c2643f', 'pot_dark': '#93492f',
+ # street
+ 'street': '#a7adab', 'street_far': '#c3c3ba', 'cobble': '#b8b2a6', 'cobble_dark': '#8f8d88', 'wet': '#7d8c95',
+ # people
+ 'skin': '#efc4a0', 'hair': '#3b2a22', 'hair_light': '#a5683a',
+}
+
+BUNTING = ('#e24b3b', '#f08a3a', '#f3c84a', '#3fa597', '#4a85c1', '#7bb65a', '#ec8b9b', '#f5f0e2')
+PLASTER = (0.5, 0.0, 0.7) # walls: a little vertical brushwork in a scumbled coat
+SLATE_RAMP = ('#34475e', '#3b5069', '#425873', '#4a617c', '#3f536b', '#3b5069', '#526b86')
+TILE_RAMP = ('#b65438', '#c4613e', '#cf7048', '#a94a33', '#d77f55')
+FLOWER_SETS = {
+ 'pink': ('#f2a2b4', '#e8607c', '#fbf4ee', '#f7c6d0'),
+ 'red': ('#d8312d', '#f06a5c', '#fbf4ee', '#f2a2b4'),
+ 'sunny': ('#f3cf4f', '#f08c3c', '#fbf4ee', '#e8607c'),
+ 'violet': ('#a77fc6', '#f2a2b4', '#fbf4ee', '#d8312d'),
+ 'white': ('#fbf4ee', '#f7e3c8', '#f2a2b4', '#f3cf4f'),
+}
+
+
+def hexc(c):
+ """'#rrggbb', a PAINTS name or an rgb triple -> float32 rgb 0..1"""
+ if isinstance(c, str):
+ c = PAINTS.get(c, c).lstrip('#')
+ return np.array([int(c[i:i + 2], 16) for i in (0, 2, 4)], np.float32) / 255
+ return np.asarray(c, np.float32)
+
+
+def mix(a, b, t):
+ return hexc(a) * (1 - t) + hexc(b) * t
+
+
+def deepen(c, d=0.25):
+ """a darker, slightly richer version of a colour (gouache shadow mixing, not grey)"""
+ c = hexc(c)
+ return np.clip(c ** (1 + 0.9 * d) * (1 - 0.35 * d), 0, 1)
+
+
+def lighten(c, d=0.3, to='#fff7e6'):
+ return mix(c, to, d)
+
+
+def rect(x0, y0, x1, y1):
+ return np.array([(x0, y0), (x1, y0), (x1, y1), (x0, y1)], np.float32)
+
+
+def ellipse_pts(cx, cy, rx, ry=None, n=24, rot=0.0, a0=0.0, a1=2 * np.pi):
+ ry = rx if ry is None else ry
+ t = np.linspace(a0, a1, n, endpoint=(a1 - a0) < 2 * np.pi - 1e-6)
+ x, y = np.cos(t) * rx, np.sin(t) * ry
+ c, s = np.cos(rot), np.sin(rot)
+ return np.stack([cx + x * c - y * s, cy + x * s + y * c], 1).astype(np.float32)
+
+
+def arch(x0, y0, x1, y1, rise=None, n=18):
+ """rectangle with a round (or segmental, rise < half width) top; y0 is the crown of the arch"""
+ w = x1 - x0
+ rise = w / 2 if rise is None else min(rise, w / 2)
+ cx = (x0 + x1) / 2
+ if rise >= w / 2 - 1e-3:
+ top = ellipse_pts(cx, y0 + rise, w / 2, rise, n, 0, np.pi, 2 * np.pi)
+ else:
+ R = (rise ** 2 + (w / 2) ** 2) / (2 * rise)
+ a = np.arcsin((w / 2) / R)
+ t = np.linspace(-np.pi / 2 - a, -np.pi / 2 + a, n)
+ top = np.stack([cx + R * np.cos(t), y0 + R + R * np.sin(t)], 1)
+ return np.vstack([[(x0, y1)], top, [(x1, y1)]]).astype(np.float32)
+
+
+def leaf_pts(cx, cy, L, Wd, ang):
+ T = np.array([(-0.5, 0), (-0.25, -0.42), (0.1, -0.5), (0.5, 0), (0.1, 0.5), (-0.25, 0.42)], np.float32)
+ x, y = T[:, 0] * L, T[:, 1] * Wd
+ c, s = np.cos(ang), np.sin(ang)
+ return np.stack([cx + x * c - y * s, cy + x * s + y * c], 1).astype(np.float32)
+
+
+def _resample_edges(P, step, closed):
+ """resample a polyline keeping its vertices (so corners stay sharp)"""
+ P = np.asarray(P, np.float32)
+ if closed: P = np.vstack([P, P[:1]])
+ out = [P[:1]]
+ for a, b in zip(P[:-1], P[1:]):
+ L = float(np.hypot(*(b - a)))
+ n = max(1, int(np.ceil(L / step)))
+ t = (np.arange(1, n + 1, dtype=np.float32) / n)[:, None]
+ out.append(a + (b - a) * t)
+ return np.vstack(out)
+
+
+def _hand(P, closed=False, amp=0.6, wl=42.0, step=5.0, r=None):
+ """push a polyline sideways by a smooth random wobble (hand-drawn, not ruler-drawn)"""
+ P = np.asarray(P, np.float32)
+ if amp <= 0 or len(P) < 2: return P
+ r = r if r is not None else np.random.default_rng()
+ Q = _resample_edges(P, step, closed)
+ d = np.diff(Q, axis=0)
+ s = np.concatenate([[0], np.cumsum(np.hypot(d[:, 0], d[:, 1]))])
+ Lt = float(s[-1])
+ if Lt < 1: return P
+ k = max(2, int(Lt / wl) + 2)
+ nz = np.interp(s, np.linspace(0, Lt, k), r.normal(0, 1, k))
+ nz += 0.3 * np.interp(s, np.linspace(0, Lt, 3 * k), r.normal(0, 1, 3 * k))
+ if closed: nz -= (nz[-1] - nz[0]) * s / Lt
+ tx = np.gradient(Q[:, 0]); ty = np.gradient(Q[:, 1])
+ tl = np.hypot(tx, ty) + 1e-6
+ Q = Q + np.stack([-ty / tl, tx / tl], 1) * (nz * amp)[:, None]
+ return Q[:-1] if closed else Q
+
+
+def _homography(src, dst):
+ A = []
+ for (x, y), (u, v) in zip(src, dst):
+ A.append([x, y, 1, 0, 0, 0, -u * x, -u * y, -u])
+ A.append([0, 0, 0, x, y, 1, -v * x, -v * y, -v])
+ _, _, Vt = np.linalg.svd(np.asarray(A, np.float64))
+ Hm = Vt[-1].reshape(3, 3)
+ return Hm / Hm[2, 2]
+
+
+def _streaks(H, W, along, across, axis, seed, scales=((14, 1.2, 0.65), (48, 6.0, 0.75))):
+ """anisotropic noise: brush streaks running along `axis` (0 vertical, 1 horizontal), zero mean, unit std"""
+ r = np.random.default_rng(seed)
+ out = np.zeros((H, W), np.float32)
+ for al, ac, wgt in scales:
+ n = r.random((H, W)).astype(np.float32)
+ n = _box(_box(n, int(al * along), axis), int(al * along), axis)
+ n = _box(n, max(0, int(ac * across)), 1 - axis)
+ n = (n - n.mean()) / (n.std() + 1e-6)
+ out += wgt * n
+ return (out - out.mean()) / (out.std() + 1e-6)
+
+
+def _box(a, r, axis):
+ if r < 1: return a
+ w = 2 * r + 1
+ pad = [(0, 0), (0, 0)]; pad[axis] = (r + 1, r)
+ c = np.cumsum(np.pad(a, pad, mode='reflect'), axis=axis, dtype=np.float64)
+ hi = np.take(c, np.arange(w, c.shape[axis]), axis=axis)
+ lo = np.take(c, np.arange(0, c.shape[axis] - w), axis=axis)
+ return ((hi - lo) / w).astype(np.float32)
+
+
+class ColorTown:
+ PAINTS = PAINTS
+
+ def __init__(self, W=1500, H=2000, 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.C = np.empty((H, W, 3), np.float32); self.C[:] = hexc('paper')
+ # texture fields: vertical streaks, horizontal streaks, isotropic scumble, low-frequency mottle
+ self.TV = _streaks(H, W, 1.0, 1.0, 0, seed + 11)
+ self.TH = _streaks(H, W, 1.0, 1.0, 1, seed + 12)
+ r = np.random.default_rng(seed + 13)
+ s1 = blur(r.random((H, W)).astype(np.float32), 1.2); s2 = blur(r.random((H, W)).astype(np.float32), 4.0)
+ s = 0.55 * (s1 - s1.mean()) / (s1.std() + 1e-6) + 0.75 * (s2 - s2.mean()) / (s2.std() + 1e-6)
+ self.TS = (s / (s.std() + 1e-6)).astype(np.float32)
+ m = noise2d(H, W, 110, 3, seed + 14)
+ self.MOT = ((m - m.mean()) / (m.std() + 1e-6)).astype(np.float32)
+ self._F, self._L = [], []
+ self._far = 0.0
+ self._T = None
+ self.lw = 1.6
+ self.ss_fill, self.ss_ink = 2, 3
+ self.fin = None
+ self.n_fills = self.n_lines = 0
+
+ def _r(self, seed=None):
+ return np.random.default_rng(int(self.rng.integers(1 << 30)) if seed is None else seed)
+
+ # ================================================================== paper, contexts
+ def paper(self, tone='paper'):
+ """the warm white sheet with a faint tooth"""
+ r = self._r()
+ t = blur(r.random((self.H, self.W)).astype(np.float32), 0.7)
+ t = (t - t.mean()) / (t.std() + 1e-6)
+ self.C[:] = hexc(tone) * (1 + 0.012 * t[..., None] + 0.01 * self.MOT[..., None])
+ return self
+
+ @contextmanager
+ def depth(self, far):
+ """everything inside is `far` away (0 near .. 1 very far): hazier colour, finer and lighter lines"""
+ old = self._far
+ self._far = float(far)
+ try: yield
+ finally: self._far = old
+
+ @contextmanager
+ def plane(self, src, dst):
+ """draw a flat layout (src rectangle x0, y0, x1, y1) onto a quad dst [(x, y) x4: tl, tr, br, bl]"""
+ x0, y0, x1, y1 = src
+ old = self._T
+ self._T = _homography([(x0, y0), (x1, y0), (x1, y1), (x0, y1)], dst)
+ try: yield
+ finally:
+ self.flush()
+ self._T = old
+
+ def _tf(self, P):
+ P = np.asarray(P, np.float32)
+ if self._T is None: return P
+ Hm = self._T
+ q = P @ Hm[:2, :2].T + Hm[:2, 2]
+ w = P @ Hm[2, :2] + Hm[2, 2]
+ return (q / w[:, None]).astype(np.float32)
+
+ def _scale_at(self, p):
+ """local linear scale of the current plane at point p"""
+ if self._T is None: return 1.0
+ p = np.asarray(p, np.float32)
+ a = self._tf(np.array([p, p + (4, 0), p + (0, 4)], np.float32))
+ dx, dy = (a[1] - a[0]) / 4, (a[2] - a[0]) / 4
+ return float(np.sqrt(abs(dx[0] * dy[1] - dx[1] * dy[0])))
+
+ def _haze(self, col, far=None):
+ far = self._far if far is None else far
+ if far <= 0: return col
+ a = 0.62 * far
+ lum = col.mean(-1, keepdims=True)
+ col = lum + (col - lum) * (1 - 0.3 * far)
+ return col * (1 - a) + hexc('haze') * a
+
+ # ================================================================== low level: queue fills and ink
+ def fill(self, pts, colour, tex=None, dir=0, mot=0.5, hand=0.55, alpha=1.0, far=None, vary=0.0, r=None):
+ """queue an opaque gouache polygon. tex: texture strength (0..1.5); dir 0 vertical streaks, 1 horizontal,
+ 2 scumble; vary: random value jitter of the colour"""
+ P = self._tf(pts)
+ if hand and len(P) >= 3: P = _hand(P, True, hand, r=r if r is not None else self.rng)
+ col = hexc(colour).copy()
+ if vary:
+ rr = r if r is not None else self.rng
+ col = np.clip(col * (1 + vary * rr.normal(0, 1)) + vary * 0.35 * rr.normal(0, 1, 3), 0, 1)
+ col = self._haze(col, far)
+ tex = 0.6 if tex is None else tex
+ lum = float(col @ np.array([0.3, 0.55, 0.15], np.float32))
+ k = 1 - 0.55 * float(smoothstep(0.72, 0.95, lum))
+ tex *= k; mot *= k
+ if np.ndim(dir): w = tex * np.asarray(dir, np.float32)
+ else: w = np.zeros(3, np.float32); w[dir] = tex
+ self._F.append((P, col, float(alpha), w, float(mot)))
+ return P
+
+ def dab(self, x, y, r, colour, n=8, far=None, vary=0.0, rr=None):
+ """a small round dab (flowers, berries, pots seen from above)"""
+ return self.fill(ellipse_pts(x, y, r, r * 0.92, n, (rr or self.rng).uniform(0, 3)), colour, tex=0.25, dir=2,
+ hand=0, far=far, vary=vary, r=rr)
+
+ def leaf(self, x, y, length, width, angle, colour, far=None, vary=0.0, r=None):
+ return self.fill(leaf_pts(x, y, length, width, angle), colour, tex=0.3, dir=2, hand=0, far=far, vary=vary, r=r)
+
+ def ink(self, pts, width=None, closed=False, alpha=0.9, colour='ink', hand=0.6, corners=False, over=(0.3, 1.3),
+ far=None, split=70.0, r=None):
+ """queue a hand-inked line. corners=True draws each edge as its own stroke (and lets some overshoot)"""
+ r = r if r is not None else self.rng
+ far = self._far if far is None else far
+ width = self.lw if width is None else width
+ P0 = np.asarray(pts, np.float32)
+ if len(P0) < 2: return
+ width = width * (1 - 0.35 * far)
+ if self._T is not None: width *= float(np.clip(self._scale_at(P0[0]) ** 0.7, 0.45, 1.3))
+ alpha = alpha * (1 - 0.45 * far)
+ col = hexc(colour)
+ if far: col = col * (1 - 0.45 * far) + hexc('haze') * 0.36 * far
+ if corners:
+ Q = np.vstack([P0, P0[:1]]) if closed else P0
+ for a, b in zip(Q[:-1], Q[1:]):
+ d = b - a; L = float(np.hypot(*d)) + 1e-6
+ e0 = r.uniform(*over) if r.random() < 0.28 else r.uniform(-0.4, 0.3)
+ e1 = r.uniform(*over) if r.random() < 0.28 else r.uniform(-0.4, 0.3)
+ self._line(np.array([a - d / L * e0, b + d / L * e1]), width, alpha, col, hand, False, split, r)
+ return
+ self._line(P0, width, alpha, col, hand, closed, split, r)
+
+ def _line(self, P, width, alpha, col, hand, closed, split, r):
+ P = self._tf(P)
+ if hand: P = _hand(P, closed, hand * min(1.0, 0.5 + width / 3), r=r)
+ elif closed: P = np.vstack([P, P[:1]])
+ if closed and hand: P = np.vstack([P, P[:1]])
+ d = np.diff(P, axis=0)
+ s = np.concatenate([[0], np.cumsum(np.hypot(d[:, 0], d[:, 1]))])
+ Lt = float(s[-1])
+ if Lt < 0.5: return
+ npc = max(1, int(Lt / split))
+ cuts = np.linspace(0, Lt, npc + 1)
+ for i in range(npc):
+ m = (s >= cuts[i] - 1e-3) & (s <= cuts[i + 1] + 1e-3)
+ seg = P[m]
+ if len(seg) < 2:
+ seg = np.array([np.interp(cuts[i], s, P[:, 0]), np.interp(cuts[i], s, P[:, 1]),
+ np.interp(cuts[i + 1], s, P[:, 0]), np.interp(cuts[i + 1], s, P[:, 1])],
+ np.float32).reshape(2, 2)
+ wv = width * (1 + 0.12 * r.normal(0, 1)) if npc > 1 else width
+ av = float(np.clip(alpha * (1 + 0.08 * r.normal(0, 1)), 0, 1))
+ self._L.append((seg, max(0.35, wv), av, col))
+
+ def box(self, x0, y0, x1, y1, colour, line=True, lw=None, tex=0.5, dir=0, hand=0.5, alpha=0.9, vary=0.0, r=None):
+ P = rect(x0, y0, x1, y1)
+ self.fill(P, colour, tex=tex, dir=dir, hand=hand, vary=vary, r=r)
+ if line: self.ink(P, lw, closed=True, corners=True, alpha=alpha, r=r)
+ return P
+
+ def flush(self, clip=None):
+ """rasterise everything queued: the colour first, then its ink. clip: polygon (in the current plane)"""
+ cl = None if clip is None else self._tf(clip)
+ if self._F:
+ self._raster_fills(self._F, cl); self.n_fills += len(self._F); self._F = []
+ if self._L:
+ self._raster_ink(self._L, cl); self.n_lines += len(self._L); self._L = []
+
+ def _bbox(self, items, pad):
+ lo = np.array([1e9, 1e9], np.float32); hi = -lo
+ for it in items:
+ lo = np.minimum(lo, it[0].min(0)); hi = np.maximum(hi, it[0].max(0))
+ x0, y0 = max(0, int(np.floor(lo[0] - pad))), max(0, int(np.floor(lo[1] - pad)))
+ x1, y1 = min(self.W, int(np.ceil(hi[0] + pad))), min(self.H, int(np.ceil(hi[1] + pad)))
+ return x0, y0, x1, y1
+
+ def _clipmask(self, cl, x0, y0, x1, y1, ss=2):
+ if cl is None: return None
+ im = Image.new('L', ((x1 - x0) * ss, (y1 - y0) * ss), 0)
+ ImageDraw.Draw(im).polygon(((cl - (x0, y0)) * ss).ravel().tolist(), fill=255)
+ im = im.resize((x1 - x0, y1 - y0), Image.BOX)
+ return np.asarray(im, np.float32) / 255
+
+ def _raster_fills(self, items, cl):
+ ss = self.ss_fill
+ x0, y0, x1, y1 = self._bbox(items, 2)
+ if x1 <= x0 or y1 <= y0: return
+ w, h = x1 - x0, y1 - y0
+ im = Image.new('I', (w * ss, h * ss), 0)
+ d = ImageDraw.Draw(im)
+ pal = np.zeros((len(items) + 1, 8), np.float32)
+ off = np.array([x0, y0], np.float32)
+ for i, (P, col, a, tw, mot) in enumerate(items, 1):
+ if len(P) < 3: continue
+ d.polygon(((P - off) * ss).ravel().tolist(), fill=i)
+ pal[i, :3] = col * a; pal[i, 3] = a; pal[i, 4:7] = tw * a; pal[i, 7] = mot * a
+ ids = np.asarray(im)
+ clip = self._clipmask(cl, x0, y0, x1, y1)
+ Cs = self.C[y0:y1, x0:x1]
+ step = max(8, int(2_000_000 // max(1, w * ss * ss * 8)))
+ for r0 in range(0, h, step):
+ r1 = min(h, r0 + step)
+ look = pal[ids[r0 * ss:r1 * ss]].reshape(r1 - r0, ss, w, ss, 8).mean((1, 3))
+ A = look[..., 3]
+ if not A.any(): continue
+ sl = (slice(y0 + r0, y0 + r1), slice(x0, x1))
+ tx = (look[..., 4] * self.TV[sl] + look[..., 5] * self.TH[sl] + look[..., 6] * self.TS[sl]) * 0.045 \
+ + look[..., 7] * self.MOT[sl] * 0.03
+ Pm = look[..., :3] * (1 + tx / np.maximum(A, 1e-4))[..., None]
+ if clip is not None:
+ c = clip[r0:r1]; A = A * c; Pm = Pm * c[..., None]
+ Cs[r0:r1] = Cs[r0:r1] * (1 - A[..., None]) + Pm
+
+ def _raster_ink(self, items, cl):
+ ss = self.ss_ink
+ x0, y0, x1, y1 = self._bbox(items, 4)
+ if x1 <= x0 or y1 <= y0: return
+ w, h = x1 - x0, y1 - y0
+ im = Image.new('I', (w * ss, h * ss), 0)
+ d = ImageDraw.Draw(im)
+ pal = np.zeros((len(items) + 1, 4), np.float32)
+ off = np.array([x0, y0], np.float32)
+ for i, (P, wd, a, col) in enumerate(items, 1):
+ q = ((P - off) * ss).ravel().tolist()
+ wpx = max(1, int(round(wd * ss)))
+ d.line(q, fill=i, width=wpx, joint='curve' if wpx > 2 else None)
+ if wpx > 3: # round caps
+ rr = wpx / 2
+ for px, py in (q[:2], q[-2:]):
+ d.ellipse([px - rr, py - rr, px + rr, py + rr], fill=i)
+ pal[i, :3] = col * a; pal[i, 3] = a
+ ids = np.asarray(im)
+ clip = self._clipmask(cl, x0, y0, x1, y1)
+ Cs = self.C[y0:y1, x0:x1]
+ step = max(8, int(2_000_000 // max(1, w * ss * ss * 4)))
+ for r0 in range(0, h, step):
+ r1 = min(h, r0 + step)
+ look = pal[ids[r0 * ss:r1 * ss]].reshape(r1 - r0, ss, w, ss, 4).mean((1, 3))
+ A = look[..., 3]
+ if not A.any(): continue
+ col = look[..., :3] / np.maximum(A, 1e-4)[..., None]
+ if clip is not None: A = A * clip[r0:r1]
+ base = Cs[r0:r1]
+ eff = 0.6 * col + 0.4 * np.minimum(base * col * 2.2, 1)
+ Cs[r0:r1] = base * (1 - A[..., None]) + eff * A[..., None]
+
+ # ================================================================== direct (soft) painting
+ def paint_mask(self, mask, colour, alpha=1.0, tex=0.6, dir=1, sl=None):
+ """paint a soft float mask straight into the canvas (sky, clouds, glazes)"""
+ sl = sl or (slice(None), slice(None))
+ A = (mask * alpha)[..., None]
+ col = colour if np.ndim(colour) == 3 else hexc(colour)
+ T = (self.TV, self.TH, self.TS)[dir][sl]
+ col = col * (1 + 0.045 * tex * T + 0.03 * 0.5 * self.MOT[sl])[..., None]
+ self.C[sl] = self.C[sl] * (1 - A) + col * A
+
+ def glaze(self, P, colour='#5a5470', top=0.0, bottom=0.12, y0=None, y1=None, soft=0.0):
+ """a thin transparent wash over polygon P (multiply), its strength ramping from `top` at y0 to `bottom` at y1"""
+ P = self._tf(P)
+ x0_, y0_ = np.floor(P.min(0)).astype(int); x1_, y1_ = np.ceil(P.max(0)).astype(int)
+ x0_, y0_ = max(0, x0_ - 2), max(0, y0_ - 2); x1_, y1_ = min(self.W, x1_ + 2), min(self.H, y1_ + 2)
+ if x1_ <= x0_ or y1_ <= y0_: return
+ m = self._mask(P, (y0_, y1_, x0_, x1_), soft=soft)
+ ya = P[:, 1].min() if y0 is None else self._tf([(P[0, 0], y0)])[0, 1] if self._T is not None else y0
+ yb = P[:, 1].max() if y1 is None else self._tf([(P[0, 0], y1)])[0, 1] if self._T is not None else y1
+ yy = np.arange(y0_, y1_, dtype=np.float32)[:, None]
+ t = np.clip((yy - ya) / max(1.0, yb - ya), 0, 1)
+ a = (top + (bottom - top) * t) * m * (1 - 0.6 * self._far)
+ sl = (slice(y0_, y1_), slice(x0_, x1_))
+ C = self.C[sl]
+ self.C[sl] = C * (1 - a[..., None]) + C * hexc(colour) * a[..., None]
+
+ def mask(self, P, soft=0.0):
+ """polygon -> anti-aliased float mask over the canvas (optionally softened by `soft` px)"""
+ return self._mask(self._tf(P), soft=soft)
+
+ def _mask(self, P, sl=None, ss=2, soft=0.0):
+ """polygon -> float mask over the canvas (or the slice sl = (y0, y1, x0, x1))"""
+ y0, y1, x0, x1 = sl if sl else (0, self.H, 0, self.W)
+ im = Image.new('L', ((x1 - x0) * ss, (y1 - y0) * ss), 0)
+ ImageDraw.Draw(im).polygon(((np.asarray(P, np.float32) - (x0, y0)) * ss).ravel().tolist(), fill=255)
+ m = np.asarray(im.resize((x1 - x0, y1 - y0), Image.BOX), np.float32) / 255
+ return blur(m, soft) if soft else m
+
+ # ================================================================== sky
+ def sky(self, top='sky_top', mid='sky', bottom='sky_low', y1=None, mask=None):
+ """pale blue gouache sky, a little lighter toward the horizon, laid in horizontal strokes"""
+ y1 = self.H * 0.55 if y1 is None else y1
+ yy = np.arange(self.H, dtype=np.float32)[:, None, None]
+ t = np.clip(yy / y1, 0, 1)
+ col = np.where(t < 0.5, hexc(top) * (1 - 2 * t) + hexc(mid) * 2 * t,
+ hexc(mid) * (2 - 2 * t) + hexc(bottom) * (2 * t - 1))
+ col = np.broadcast_to(col, (self.H, self.W, 3)) * (1 + 0.012 * self.MOT[..., None])
+ m = np.ones((self.H, self.W), np.float32) if mask is None else mask
+ self.paint_mask(m, col, tex=0.35, dir=2)
+ self.paint_mask(m, col, tex=0.25, dir=1, alpha=0.5)
+
+ def clouds(self, specs, colour='cloud', shade='cloud_shade', warm=None, seed=None):
+ """creamy gouache clouds: (cx, cy, w, h) each -- bumps on top, flatter bottom, a soft cooler underside"""
+ r = self._r(seed)
+ for cx, cy, w, h in specs:
+ pad = 30
+ x0, x1 = max(0, int(cx - w / 2 - pad)), min(self.W, int(cx + w / 2 + pad))
+ y0, y1 = max(0, int(cy - h - pad)), min(self.H, int(cy + h * 0.5 + pad))
+ if x1 <= x0 or y1 <= y0: continue
+ YY, XX = np.mgrid[y0:y1, x0:x1].astype(np.float32)
+ m = np.zeros(YY.shape, np.float32)
+ nb = int(r.integers(5, 9))
+ xs = np.linspace(cx - w * 0.4, cx + w * 0.4, nb) + r.normal(0, w * 0.03, nb)
+ for i, bx in enumerate(xs):
+ edge = 1 - abs(i - (nb - 1) / 2) / ((nb - 1) / 2 + 1e-6)
+ rad = h * (0.32 + 0.42 * edge) * r.uniform(0.85, 1.15)
+ by = cy - rad * 0.55
+ m = np.maximum(m, ((XX - bx) ** 2 + (YY - by) ** 2 < rad ** 2).astype(np.float32))
+ m *= (YY < cy + h * 0.12)
+ m = np.clip(blur(m, 1.6) * 1.5 - 0.25, 0, 1)
+ sl = (slice(y0, y1), slice(x0, x1))
+ under = smoothstep(cy - h * 0.55, cy + h * 0.1, YY)
+ col = hexc(colour)[None, None] * (1 - 0.6 * under[..., None]) + hexc(shade) * 0.6 * under[..., None]
+ if warm: col = col * 0.85 + hexc(warm) * 0.15
+ self.paint_mask(m, col, tex=0.22, dir=2, sl=sl)
+
+ def birds(self, region, n=5, size=(7, 12), seed=None):
+ r = self._r(seed)
+ x0, y0, x1, y1 = region
+ for _ in range(n):
+ x, y, s = r.uniform(x0, x1), r.uniform(y0, y1), r.uniform(*size)
+ self.ink([(x - s, y - s * 0.25), (x - s * 0.45, y - s * 0.5), (x, y)], 1.2, hand=0.2, r=r)
+ self.ink([(x, y), (x + s * 0.45, y - s * 0.55), (x + s, y - s * 0.3)], 1.2, hand=0.2, r=r)
+ self.flush()
+
+ # ================================================================== building parts
+ def patches(self, x0, y0, x1, y1, wall, n=3, size=(30, 70), seed=None):
+ """bare stone showing through flaking plaster: soft blobs with a few bricks outlined"""
+ r = self._r(seed)
+ for _ in range(n):
+ w = r.uniform(*size); h = w * r.uniform(0.45, 0.8)
+ cx, cy = r.uniform(x0 + w / 2, max(x0 + w / 2 + 1, x1 - w / 2)), r.uniform(y0 + h / 2, max(y0 + h / 2 + 1, y1 - h / 2))
+ P = ellipse_pts(cx, cy, w / 2, h / 2, 14) + r.normal(0, w * 0.06, (14, 2))
+ self.fill(P, mix(deepen(wall, 0.12), 'stone', 0.35), tex=0.9, dir=2, hand=1.0, r=r)
+ bh = max(4.0, h / 3.2)
+ rows = int(h / bh)
+ for k in range(rows):
+ yy = cy - h / 2 + (k + 0.5) * bh
+ xs = cx - w / 2 + (r.uniform(0, 1) + np.arange(0, w / (bh * 2) + 1)) * bh * 2
+ for xb in xs:
+ if abs(xb - cx) / (w / 2) + abs(yy - cy) / (h / 2) < 0.9 and r.random() < 0.7:
+ self.ink(rect(xb - bh * 0.9, yy - bh * 0.42, xb + bh * 0.9, yy + bh * 0.42), 0.8,
+ closed=True, alpha=0.35, colour='ink_soft', hand=0.4, r=r)
+
+ def window(self, x0, y0, x1, y1, kind='std', frame='cream', glass='glass', panes=None, shutters=None,
+ curtains=None, sill=True, lintel=None, open_=False, lw=None, r=None):
+ """a window: frame, glass with a light reflection, glazing bars, sill, optional shutters / curtains"""
+ r = r or self.rng
+ lw = self.lw if lw is None else lw
+ ww, wh = x1 - x0, y1 - y0
+ small = ww < 16
+ fw = max(1.5, ww * 0.085)
+ fr = hexc(frame) * (1 + 0.03 * r.normal())
+ if shutters:
+ sw = ww * 0.5 + fw
+ for sx0, sx1 in ((x0 - fw - sw, x0 - fw), (x1 + fw, x1 + fw + sw)):
+ self.fill(rect(sx0, y0 - fw, sx1, y1 + fw), shutters, tex=0.7, dir=0, vary=0.03, r=r)
+ self.ink(rect(sx0, y0 - fw, sx1, y1 + fw), lw * 0.85, closed=True, corners=True, r=r)
+ if not small:
+ for yy in np.arange(y0 + 2.5 * lw, y1 + fw - 2 * lw, max(4.0, 3.6 * lw)):
+ self.ink([(sx0 + lw * 1.4, yy), (sx1 - lw * 1.4, yy)], lw * 0.42, alpha=0.32, hand=0.2, r=r)
+ if lintel == 'cap':
+ self.fill(rect(x0 - fw * 2.2, y0 - fw * 3.2, x1 + fw * 2.2, y0 - fw * 1.4), frame, tex=0.4, r=r)
+ self.ink(rect(x0 - fw * 2.2, y0 - fw * 3.2, x1 + fw * 2.2, y0 - fw * 1.4), lw * 0.8, closed=True, corners=True, r=r)
+ elif lintel == 'pediment':
+ P = np.array([(x0 - fw * 2.4, y0 - fw * 1.4), ((x0 + x1) / 2, y0 - fw * 1.4 - ww * 0.32), (x1 + fw * 2.4, y0 - fw * 1.4)], np.float32)
+ self.fill(P, frame, tex=0.4, r=r)
+ self.ink(P, lw * 0.8, closed=True, r=r)
+ if kind == 'round':
+ cx, cy, rr = (x0 + x1) / 2, (y0 + y1) / 2, ww / 2
+ self.fill(ellipse_pts(cx, cy, rr + fw * 1.4, rr + fw * 1.4, 28), fr, tex=0.4, r=r, hand=0.3)
+ self.fill(ellipse_pts(cx, cy, rr, rr, 28), glass, tex=0.3, dir=2, vary=0.05, r=r, hand=0.3)
+ self.fill(ellipse_pts(cx - rr * 0.25, cy - rr * 0.25, rr * 0.45, rr * 0.3, 16, -0.7), lighten(glass, 0.28, '#e8f2ee'), tex=0.2, r=r, hand=0)
+ self.ink(ellipse_pts(cx, cy, rr + fw * 1.4, rr + fw * 1.4, 28), lw, closed=True, r=r)
+ self.ink(ellipse_pts(cx, cy, rr, rr, 28), lw * 0.8, closed=True, r=r)
+ if not small:
+ self.ink([(cx - rr, cy), (cx + rr, cy)], lw * 0.6, r=r)
+ self.ink([(cx, cy - rr), (cx, cy + rr)], lw * 0.6, r=r)
+ return
+ outer = arch(x0 - fw, y0 - fw, x1 + fw, y1 + fw) if kind == 'arch' else rect(x0 - fw, y0 - fw, x1 + fw, y1 + fw)
+ inner = arch(x0, y0, x1, y1) if kind == 'arch' else rect(x0, y0, x1, y1)
+ self.fill(outer, fr, tex=0.4, r=r)
+ gcol = hexc(glass) * (1 + 0.07 * r.normal()) + 0.02 * r.normal(0, 1, 3)
+ if open_:
+ gcol = deepen(gcol, 0.5)
+ self.fill(inner, gcol, tex=0.5, dir=0, r=r, hand=0.3)
+ gy0 = y0 + (ww / 2 if kind == 'arch' else 0)
+ # light reflection: a pale slanted band across the upper-left of the glass
+ if not open_ and r.random() < 0.85:
+ t0, t1 = r.uniform(0.15, 0.35), r.uniform(0.45, 0.7)
+ lc = lighten(gcol, r.uniform(0.18, 0.32), '#dfeeea')
+ P = np.array([(x0 + ww * t0, gy0), (x0 + ww * t1, gy0), (x0, gy0 + wh * (t1 - 0.05) * 0.9),
+ (x0, gy0 + wh * (t0 - 0.05) * 0.9)], np.float32)
+ P[:, 0] = np.clip(P[:, 0], x0, x1); P[:, 1] = np.clip(P[:, 1], gy0, y1)
+ self.fill(P, lc, tex=0.3, r=r, hand=0)
+ if curtains and not small:
+ cw = ww * r.uniform(0.22, 0.32)
+ cc = hexc(curtains)
+ for side in (0, 1):
+ if side == 0:
+ P = [(x0, gy0), (x0 + cw, gy0), (x0 + cw * 0.55, y0 + wh * 0.55), (x0 + cw * 0.35, y1), (x0, y1)]
+ else:
+ P = [(x1, gy0), (x1 - cw, gy0), (x1 - cw * 0.55, y0 + wh * 0.55), (x1 - cw * 0.35, y1), (x1, y1)]
+ self.fill(np.array(P, np.float32), cc, tex=0.6, dir=0, r=r, hand=0.3)
+ self.ink(np.array(P[1:4], np.float32), lw * 0.5, alpha=0.5, r=r)
+ # glazing bars
+ if panes is None: panes = (2, 2) if wh > ww * 1.15 else (2, 1)
+ nx, ny = panes
+ bw = max(1.0, fw * 0.55)
+ if not small or nx * ny <= 4:
+ for i in range(1, nx):
+ xx = x0 + ww * i / nx
+ self.fill(rect(xx - bw / 2, gy0 if kind != 'arch' else y0, xx + bw / 2, y1), fr, tex=0.2, hand=0.2, r=r)
+ for j in range(1, ny):
+ yy = gy0 + (y1 - gy0) * j / ny
+ self.fill(rect(x0, yy - bw / 2, x1, yy + bw / 2), fr, tex=0.2, hand=0.2, r=r)
+ if sill:
+ self.fill(rect(x0 - fw * 1.9, y1 + fw * 0.6, x1 + fw * 1.9, y1 + fw * 2.0), fr, tex=0.3, r=r)
+ self.ink(rect(x0 - fw * 1.9, y1 + fw * 0.6, x1 + fw * 1.9, y1 + fw * 2.0), lw * 0.75, closed=True, corners=True, r=r)
+ self.ink(outer, lw, closed=True, corners=kind != 'arch', r=r)
+ self.ink(inner, lw * 0.7, closed=True, corners=kind != 'arch', alpha=0.8, r=r)
+ if not small:
+ for i in range(1, nx):
+ xx = x0 + ww * i / nx
+ self.ink([(xx - bw / 2, gy0), (xx - bw / 2, y1)], lw * 0.45, alpha=0.6, r=r)
+ self.ink([(xx + bw / 2, gy0), (xx + bw / 2, y1)], lw * 0.45, alpha=0.6, r=r)
+ for j in range(1, ny):
+ yy = gy0 + (y1 - gy0) * j / ny
+ self.ink([(x0, yy - bw / 2), (x1, yy - bw / 2)], lw * 0.45, alpha=0.6, r=r)
+ self.ink([(x0, yy + bw / 2), (x1, yy + bw / 2)], lw * 0.45, alpha=0.6, r=r)
+
+ def flowerbox(self, x0, x1, y, h, box='terracotta', flowers='pink', density=1.0, trail=0.6, mound=2.4, lw=None, r=None):
+ """a window box (top edge at y, h tall) overflowing with a mound of leaves, flowers and trailing stems"""
+ r = r or self.rng
+ lw = self.lw if lw is None else lw
+ w = x1 - x0
+ cols = FLOWER_SETS.get(flowers, flowers) if isinstance(flowers, str) else flowers
+ s = max(1.5, h * 0.32)
+ mx, my, rx, ry = (x0 + x1) / 2, y + h * 0.15, w * 0.56, h * mound
+ def in_mound(m):
+ a = r.uniform(np.pi * 1.02, np.pi * 1.98, m); d = np.sqrt(r.random(m))
+ return mx + np.cos(a) * d * rx, my + np.sin(a) * d * ry, d
+ nl = int(rx * ry / (s * s) * 1.5 * density) + 4
+ lx, ly, d = in_mound(nl)
+ order = np.argsort(-d)
+ for i in order:
+ c = ('leaf_dark', 'leaf', 'leaf_mid', 'leaf_light')[min(3, int((1 - d[i]) * 2.2 + r.random() * 1.6))]
+ self.leaf(lx[i], ly[i], s * r.uniform(1.6, 2.5), s * r.uniform(0.8, 1.1), r.uniform(-2.7, -0.4), c, r=r)
+ P = rect(x0, y, x1, y + h)
+ self.fill(P, box, tex=0.6, dir=1, vary=0.05, r=r)
+ for _ in range(int(w / s * trail * 0.5)):
+ tx_ = r.uniform(x0 + s, x1 - s); L = h * r.uniform(0.8, 2.6)
+ for k in range(int(L / (s * 1.3)) + 1):
+ self.leaf(tx_ + r.normal(0, s * 0.4), y + h * 0.7 + k * s * 1.3, s * r.uniform(1.3, 2.0), s * 0.8,
+ r.uniform(1.0, 2.1), ('leaf_dark', 'leaf', 'leaf_mid')[r.integers(0, 3)], r=r)
+ if r.random() < 0.5:
+ self.dab(tx_, y + h * 0.7 + L, s * 0.7, cols[0], rr=r)
+ nf = int(rx * ry / (s * s) * 0.55 * density) + 2
+ fx, fy, d = in_mound(nf)
+ for i in np.argsort(-d):
+ c = cols[min(len(cols) - 1, int(abs(r.normal(0, 1.1))))]
+ rr_ = s * r.uniform(0.6, 1.0)
+ self.dab(fx[i], fy[i], rr_, c, vary=0.04, rr=r)
+ if rr_ > 2.2 and r.random() < 0.5:
+ self.dab(fx[i] - rr_ * 0.2, fy[i] - rr_ * 0.25, rr_ * 0.35, lighten(c, 0.45), rr=r)
+ self.ink(P, lw * 0.8, closed=True, corners=True, r=r)
+
+ def balcony(self, x0, x1, y, h, slab='cream', iron='iron', pots=True, lw=None, r=None, style='bars'):
+ """a small iron balcony: a stone slab at y, an iron railing of height h above it, pots behind the bars"""
+ r = r or self.rng
+ lw = self.lw if lw is None else lw
+ ext = (x1 - x0) * 0.06
+ th = max(2.5, h * 0.18)
+ if pots:
+ for px in np.arange(x0 + h * 0.4, x1 - h * 0.2, h * r.uniform(0.6, 0.95)):
+ ph = h * r.uniform(0.3, 0.42)
+ self.fill(np.array([(px - ph * 0.45, y - ph), (px + ph * 0.45, y - ph), (px + ph * 0.33, y), (px - ph * 0.33, y)], np.float32),
+ 'terracotta', tex=0.4, vary=0.05, r=r, hand=0)
+ for _ in range(7):
+ self.leaf(px + r.normal(0, ph * 0.4), y - ph - abs(r.normal(0, ph * 0.5)), ph * 0.6, ph * 0.3,
+ r.uniform(-2.8, -0.3), ('leaf_dark', 'leaf', 'leaf_mid')[r.integers(0, 3)], r=r)
+ if r.random() < 0.6:
+ fc = FLOWER_SETS[('pink', 'red', 'sunny', 'violet')[r.integers(0, 4)]]
+ for _ in range(4):
+ self.dab(px + r.normal(0, ph * 0.35), y - ph - abs(r.normal(0, ph * 0.4)), ph * 0.16, fc[r.integers(0, 3)], rr=r)
+ S = rect(x0 - ext, y, x1 + ext, y + th)
+ self.fill(S, slab, tex=0.4, dir=1, r=r)
+ self.ink(S, lw * 0.8, closed=True, corners=True, r=r)
+ for bx in (x0 + ext, x1 - ext):
+ B = np.array([(bx - th * 0.6, y + th), (bx + th * 0.6, y + th), (bx, y + th * 2.6)], np.float32)
+ self.fill(B, slab, tex=0.3, r=r, hand=0)
+ self.ink(B, lw * 0.6, closed=True, alpha=0.7, r=r)
+ ic = iron
+ self.ink([(x0, y - h), (x1, y - h)], lw * 1.25, colour=ic, r=r)
+ self.ink([(x0, y - h * 0.12), (x1, y - h * 0.12)], lw * 0.8, colour=ic, r=r)
+ for xx in (x0, x1):
+ self.ink([(xx, y - h), (xx, y)], lw, colour=ic, r=r)
+ sp = max(3.0, h * 0.16)
+ for xx in np.arange(x0 + sp, x1 - sp * 0.4, sp):
+ self.ink([(xx, y - h), (xx, y)], lw * 0.55, colour=ic, alpha=0.85, hand=0.2, r=r)
+ if style == 'scroll' and h > 14:
+ for xx in np.arange(x0 + sp * 1.5, x1 - sp, sp * 2):
+ self.ink(ellipse_pts(xx, y - h * 0.55, sp * 0.45, h * 0.22, 12), lw * 0.5, closed=True, colour=ic, alpha=0.8, hand=0, r=r)
+
+ def door(self, x0, y0, x1, y1, colour='teal', kind='arch', frame='stone', panels=True, fanlight=True, step=True,
+ lw=None, r=None):
+ """a painted front door in a stone surround, with panels, a fanlight, a knob and a step"""
+ r = r or self.rng
+ lw = self.lw if lw is None else lw
+ w = x1 - x0
+ fw = max(2.0, w * 0.12)
+ outer = arch(x0 - fw, y0 - fw, x1 + fw, y1) if kind == 'arch' else rect(x0 - fw, y0 - fw, x1 + fw, y1)
+ inner = arch(x0, y0, x1, y1) if kind == 'arch' else rect(x0, y0, x1, y1)
+ self.fill(outer, frame, tex=0.6, dir=2, vary=0.03, r=r)
+ self.fill(inner, colour, tex=0.8, dir=0, vary=0.04, r=r)
+ top = y0 + (w / 2 if kind == 'arch' else 0)
+ if fanlight:
+ fh = w * 0.38 if kind != 'arch' else 0
+ if kind == 'arch':
+ fan = arch(x0 + w * 0.08, y0 + w * 0.08, x1 - w * 0.08, top + w * 0.08)
+ self.fill(fan, 'glass', tex=0.3, r=r, hand=0.2)
+ self.ink(fan, lw * 0.7, closed=True, r=r)
+ for a in np.linspace(0.2, np.pi - 0.2, 4):
+ cx = (x0 + x1) / 2
+ self.ink([(cx, top + w * 0.08), (cx - np.cos(a) * w * 0.42, top + w * 0.08 - np.sin(a) * w * 0.42)], lw * 0.45, alpha=0.6, r=r)
+ top = top + w * 0.12
+ else:
+ F = rect(x0 + w * 0.08, y0 + w * 0.08, x1 - w * 0.08, y0 + fh)
+ self.fill(F, 'glass', tex=0.3, r=r, hand=0.2)
+ self.ink(F, lw * 0.7, closed=True, corners=True, r=r)
+ top = y0 + fh + w * 0.06
+ if panels and w > 18:
+ leaves = 2 if w > 34 else 1
+ lw_ = w / leaves
+ for k in range(leaves):
+ lx0 = x0 + k * lw_
+ for (a, b) in ((0.08, 0.46), (0.54, 0.9)):
+ py0 = top + (y1 - top) * a; py1 = top + (y1 - top) * b
+ self.ink(rect(lx0 + lw_ * 0.18, py0, lx0 + lw_ * 0.82, py1), lw * 0.6, closed=True, corners=True, alpha=0.65, r=r)
+ if leaves == 2: self.ink([((x0 + x1) / 2, top), ((x0 + x1) / 2, y1)], lw * 0.7, r=r)
+ kx = x1 - w * 0.18 if w <= 34 else (x0 + x1) / 2 + w * 0.08
+ self.dab(kx, y0 + (y1 - y0) * 0.6, max(1.2, w * 0.035), 'gold', rr=r)
+ self.ink(outer, lw, closed=True, corners=kind != 'arch', r=r)
+ self.ink(inner, lw * 0.8, closed=True, corners=kind != 'arch', r=r)
+ if step:
+ S = rect(x0 - fw * 1.6, y1 - max(3, w * 0.1), x1 + fw * 1.6, y1)
+ self.fill(S, 'stone_mid', tex=0.5, dir=1, r=r)
+ self.ink(S, lw * 0.8, closed=True, corners=True, r=r)
+
+ def awning(self, x0, x1, y, depth, colours=('tomato', 'cream'), stripes=None, lw=None, r=None):
+ """a striped shop awning sloping out from the wall at y, with a scalloped valance"""
+ r = r or self.rng
+ lw = self.lw if lw is None else lw
+ w = x1 - x0
+ ext = depth * 0.35
+ P = np.array([(x0, y), (x1, y), (x1 + ext, y + depth), (x0 - ext, y + depth)], np.float32)
+ n = stripes or max(3, int(w / max(8, depth * 0.45)))
+ for i in range(n):
+ a, b = i / n, (i + 1) / n
+ Q = np.array([(x0 + w * a, y), (x0 + w * b, y), (x0 - ext + (w + 2 * ext) * b, y + depth),
+ (x0 - ext + (w + 2 * ext) * a, y + depth)], np.float32)
+ self.fill(Q, colours[i % len(colours)], tex=0.8, dir=0, r=r, hand=0.3)
+ vh = depth * 0.28
+ xs = np.linspace(x0 - ext, x1 + ext, n + 1)
+ for i in range(n):
+ V = np.vstack([[(xs[i], y + depth)], ellipse_pts((xs[i] + xs[i + 1]) / 2, y + depth, (xs[i + 1] - xs[i]) / 2, vh, 10, 0, np.pi, 0)[::-1]])
+ col = deepen(colours[i % len(colours)], 0.12)
+ self.fill(V, col, tex=0.5, r=r, hand=0)
+ self.ink(V[1:], lw * 0.6, r=r, hand=0.2)
+ self.ink(P, lw, closed=True, r=r)
+ for i in range(1, n):
+ self.ink([(x0 + w * i / n, y), (x0 - ext + (w + 2 * ext) * i / n, y + depth)], lw * 0.5, alpha=0.55, r=r)
+
+ def shopfront(self, x0, y0, x1, y1, colour='teal_deep', text=None, letters='cream', door='center', goods=True,
+ awning=None, lw=None, r=None):
+ """a painted wooden shopfront: fascia with lettering, pilasters, small-paned display windows, a door"""
+ r = r or self.rng
+ lw = self.lw if lw is None else lw
+ w, h = x1 - x0, y1 - y0
+ P = rect(x0, y0, x1, y1)
+ self.fill(P, colour, tex=0.7, dir=0, vary=0.03, r=r)
+ fh = h * 0.17
+ self.fill(rect(x0 - 2, y0, x1 + 2, y0 + fh), deepen(colour, 0.15), tex=0.6, dir=1, r=r)
+ self.ink(rect(x0 - 2, y0, x1 + 2, y0 + fh), lw, closed=True, corners=True, r=r)
+ pw = max(3.0, w * 0.04)
+ dw = w * 0.22
+ dx0 = (x0 + x1) / 2 - dw / 2 if door == 'center' else (x1 - pw * 1.5 - dw if door == 'right' else x0 + pw * 1.5)
+ gy0, gy1 = y0 + fh + h * 0.07, y1 - h * 0.2
+ spans = [(x0 + pw * 1.6, dx0 - pw), (dx0 + dw + pw, x1 - pw * 1.6)]
+ for sx0, sx1 in spans:
+ if sx1 - sx0 < 8: continue
+ G = rect(sx0, gy0, sx1, gy1)
+ self.fill(G, 'glass', tex=0.5, vary=0.05, r=r)
+ if goods:
+ for k in range(int((sx1 - sx0) / 7)):
+ gx = r.uniform(sx0 + 3, sx1 - 3); gy = r.uniform(gy0 + (gy1 - gy0) * 0.45, gy1 - 3)
+ self.dab(gx, gy, r.uniform(1.5, 3.2), ('gold', 'cream', 'tomato', 'apricot', 'blossom_pink', 'mint')[r.integers(0, 6)], rr=r)
+ self.fill(rect(sx0, gy1 - (gy1 - gy0) * 0.06, sx1, gy1), deepen(colour, 0.3), tex=0.3, r=r, hand=0.2)
+ t0 = r.uniform(0.1, 0.3)
+ self.fill(np.array([(sx0 + (sx1 - sx0) * t0, gy0), (sx0 + (sx1 - sx0) * (t0 + 0.18), gy0),
+ (sx0, gy0 + (gy1 - gy0) * 0.5), (sx0, gy0 + (gy1 - gy0) * 0.3)], np.float32),
+ lighten('glass', 0.22, '#dfeeea'), tex=0.2, hand=0, r=r)
+ nx = max(1, int((sx1 - sx0) / max(14, h * 0.2)))
+ for i in range(1, nx):
+ xx = sx0 + (sx1 - sx0) * i / nx
+ self.fill(rect(xx - 1.2, gy0, xx + 1.2, gy1), colour, tex=0.2, hand=0.2, r=r)
+ self.ink([(xx, gy0), (xx, gy1)], lw * 0.5, alpha=0.6, r=r)
+ yy = gy0 + (gy1 - gy0) * 0.32
+ self.fill(rect(sx0, yy - 1.2, sx1, yy + 1.2), colour, tex=0.2, hand=0.2, r=r)
+ self.ink(G, lw * 0.8, closed=True, corners=True, r=r)
+ self.ink(rect(sx0 + 3, gy1 + h * 0.04, sx1 - 3, y1 - h * 0.04), lw * 0.55, closed=True, corners=True, alpha=0.6, r=r)
+ self.door(dx0, gy0 - h * 0.02, dx0 + dw, y1, colour=deepen(colour, 0.12), kind='rect', frame=colour, panels=True,
+ fanlight=True, step=False, lw=lw, r=r)
+ for px in (x0, x1 - pw):
+ self.fill(rect(px, y0 + fh, px + pw, y1), lighten(colour, 0.12), tex=0.4, r=r)
+ self.ink(rect(px, y0 + fh, px + pw, y1), lw * 0.7, closed=True, corners=True, r=r)
+ self.ink(P, lw, closed=True, corners=True, r=r)
+ if text:
+ self._text_queue = getattr(self, '_text_queue', [])
+ self._text_queue.append(((x0 + x1) / 2, y0 + fh / 2, text, fh * 0.62, letters))
+ if awning:
+ self.flush(); self._flush_text()
+ self.awning(x0 + pw, x1 - pw, y0 + fh + 1, h * 0.2, awning, lw=lw, r=r)
+
+ def _flush_text(self):
+ q = getattr(self, '_text_queue', [])
+ for cx, cy, s, size, col in q:
+ self.text(cx, cy, s, size, col)
+ self._text_queue = []
+
+ def text(self, cx, cy, s, size, colour='cream', style='serif', anchor='mm'):
+ """small painted lettering (signs); drawn at 2x and laid in opaque"""
+ f = load_font(style, max(6, int(size * 2)))
+ pad = int(size * 2 * len(s)) + 8
+ im = Image.new('L', (pad * 2, int(size * 4) + 8), 0)
+ ImageDraw.Draw(im).text((pad, im.height / 2), s, font=f, fill=255, anchor=anchor)
+ bb = im.getbbox()
+ if not bb: return
+ im = im.resize((im.width // 2, im.height // 2), Image.BOX)
+ m = np.asarray(im, np.float32) / 255
+ x0 = int(round(cx - pad / 2)); y0 = int(round(cy - im.height / 2))
+ if self._T is not None:
+ return
+ ys, xs = slice(max(0, y0), min(self.H, y0 + m.shape[0])), slice(max(0, x0), min(self.W, x0 + m.shape[1]))
+ m = m[ys.start - y0:ys.stop - y0, xs.start - x0:xs.stop - x0]
+ self.paint_mask(m * 0.95, self._haze(hexc(colour)), tex=0.4, dir=2, sl=(ys, xs))
+
+ def chimney(self, x, y, w, h, colour='cream', pots=2, lw=None, r=None):
+ """a chimney stack standing on the roof at y (its foot), with a cap and terracotta pots"""
+ r = r or self.rng
+ lw = self.lw if lw is None else lw
+ P = rect(x - w / 2, y - h, x + w / 2, y + h * 0.15)
+ self.fill(P, colour, tex=0.7, dir=0, vary=0.04, r=r)
+ cap = rect(x - w * 0.62, y - h - h * 0.12, x + w * 0.62, y - h + h * 0.03)
+ self.fill(cap, deepen(colour, 0.08), tex=0.4, r=r)
+ if w > 10 and r.random() < 0.6:
+ for k in range(int(h / max(4, w * 0.35))):
+ yy = y - h + h * 0.08 + k * max(4, w * 0.35)
+ self.ink([(x - w / 2, yy), (x + w / 2, yy)], lw * 0.4, alpha=0.3, hand=0.2, r=r)
+ self.ink(P, lw * 0.85, closed=True, corners=True, r=r)
+ self.ink(cap, lw * 0.85, closed=True, corners=True, r=r)
+ top = y - h - h * 0.12
+ if pots:
+ pw = w * 0.22
+ xs = np.linspace(x - w * 0.3, x + w * 0.3, pots) if pots > 1 else [x]
+ for px in xs:
+ ph = pw * r.uniform(1.4, 2.0)
+ Q = np.array([(px - pw / 2, top - ph), (px + pw / 2, top - ph), (px + pw * 0.62, top), (px - pw * 0.62, top)], np.float32)
+ self.fill(Q, 'terracotta', tex=0.4, vary=0.06, r=r, hand=0)
+ self.fill(rect(px - pw * 0.6, top - ph - pw * 0.3, px + pw * 0.6, top - ph), 'pot_dark', tex=0.3, r=r, hand=0)
+ self.ink(Q, lw * 0.6, closed=True, alpha=0.8, r=r)
+ top -= pw * 1.8
+ return top
+
+ def aerial(self, x, y, h, bars=3, lw=None, r=None):
+ """a TV aerial: a mast and a few crossbars with little elements"""
+ r = r or self.rng
+ lw = (self.lw if lw is None else lw) * 0.7
+ lean = r.normal(0, 0.03)
+ self.ink([(x, y), (x + lean * h, y - h)], lw * 1.1, hand=0.15, r=r)
+ for k in range(bars):
+ yy = y - h * (0.55 + 0.42 * k / max(1, bars - 1)) if bars > 1 else y - h * 0.9
+ xx = x + lean * (y - yy)
+ half = h * r.uniform(0.18, 0.32) * (1 - 0.25 * k / max(1, bars))
+ self.ink([(xx - half, yy), (xx + half, yy + r.normal(0, 0.8))], lw, hand=0.1, r=r)
+ for t in np.linspace(-0.85, 0.85, 4):
+ self.ink([(xx + half * t, yy - h * 0.035), (xx + half * t, yy + h * 0.035)], lw * 0.7, hand=0, r=r)
+ if r.random() < 0.5:
+ self.ink([(x + lean * h * 0.5, y - h * 0.5), (x + lean * h * 0.5 + h * 0.18, y - h * 0.38)], lw * 0.7, hand=0, r=r)
+
+ def vane(self, x, y, h, flag=None, lw=None, r=None):
+ """a weather vane (or a little flag) on a spire tip at (x, y)"""
+ r = r or self.rng
+ lw = (self.lw if lw is None else lw) * 0.8
+ self.ink([(x, y), (x, y - h)], lw, hand=0.1, r=r)
+ self.dab(x, y - h * 0.35, h * 0.06, 'gold', rr=r)
+ if flag:
+ F = np.array([(x, y - h), (x + h * 0.55, y - h * 0.9), (x + h * 0.45, y - h * 0.82), (x + h * 0.58, y - h * 0.7), (x, y - h * 0.72)], np.float32)
+ self.fill(F, flag, tex=0.4, r=r, hand=0)
+ self.ink(F, lw * 0.7, closed=True, r=r)
+ else:
+ self.ink([(x - h * 0.3, y - h * 0.8), (x + h * 0.3, y - h * 0.8)], lw, hand=0, r=r)
+ self.fill(np.array([(x + h * 0.3, y - h * 0.86), (x + h * 0.42, y - h * 0.8), (x + h * 0.3, y - h * 0.74)], np.float32), 'ink', hand=0, r=r)
+ self.fill(np.array([(x - h * 0.3, y - h * 0.88), (x - h * 0.22, y - h * 0.8), (x - h * 0.3, y - h * 0.72), (x - h * 0.4, y - h * 0.8)], np.float32), 'ink', hand=0, r=r)
+
+ def slates(self, P, tile=(9, 6), ramp=SLATE_RAMP, lw=None, r=None, scallop=False):
+ """lay slates tile by tile over polygon P (staggered courses), clip to P, ink the joints"""
+ r = r or self.rng
+ lw = self.lw if lw is None else lw
+ P = np.asarray(P, np.float32)
+ x0, y0 = P.min(0); x1, y1 = P.max(0)
+ tw, th = tile
+ ramp = [hexc(c) for c in ramp]
+ rows = int(np.ceil((y1 - y0) / th)) + 1
+ for j in range(rows):
+ yy = y0 + j * th
+ off = (j % 2) * tw * 0.5 + r.uniform(-tw * 0.1, tw * 0.1)
+ xs = np.arange(x0 - tw + off, x1 + tw, tw)
+ for xx in xs:
+ c = ramp[r.integers(0, len(ramp))] * (1 + 0.04 * r.normal())
+ if r.random() < 0.05: c = lighten(c, 0.22, '#c9d6e0')
+ ww = tw * r.uniform(0.9, 1.05)
+ if scallop:
+ T = np.vstack([[(xx, yy - th * 0.1), (xx + ww, yy - th * 0.1)],
+ ellipse_pts(xx + ww / 2, yy + th * 0.55, ww / 2, th * 0.6, 8, 0, 0, np.pi)])
+ else:
+ T = rect(xx, yy, xx + ww, yy + th * 1.08)
+ T[2:, 1] += r.normal(0, th * 0.06, 2)
+ self.fill(T, c, tex=0.6, dir=2, hand=0, r=r)
+ for j in range(1, rows):
+ yy = y0 + j * th
+ self.ink([(x0 - 2, yy), (x1 + 2, yy)], max(0.55, lw * 0.55), alpha=0.7, colour='#1f2a38', hand=0.35, split=1e9, r=r)
+ off = (j % 2) * tw * 0.5
+ for xx in np.arange(x0 - tw + off, x1 + tw, tw):
+ if r.random() < 0.75:
+ self.ink([(xx, yy - th), (xx, yy)], max(0.5, lw * 0.5), alpha=0.6, colour='#1f2a38', hand=0, r=r)
+ self.flush(clip=P)
+
+ def roof(self, kind, x0, x1, y, h, colour='slate', overhang=None, tile=None, lw=None, r=None, dormers=0,
+ dormer_frame='cream', wall=None):
+ """a roof standing on the cornice line y between x0 and x1, h tall.
+ kind: 'mansard' (steep slate face, curved sides), 'hip', 'side' (side gable, vertical ends),
+ 'gable' (front gable: the wall continues into a triangle and the roof shows as two slate verges),
+ 'pyramid', 'flat' (a parapet)."""
+ r = r or self.rng
+ lw = self.lw if lw is None else lw
+ w = x1 - x0
+ ov = w * 0.035 if overhang is None else overhang
+ ramp = TILE_RAMP if colour == 'tile' else SLATE_RAMP
+ if tile is None:
+ th = float(np.clip(h * 0.1, 3.5, 13.0)); tile = (th * 1.5, th)
+ cx = (x0 + x1) / 2
+ if kind == 'mansard':
+ ins = h * 0.16
+ L = spline([(x0 - ov, y), (x0 - ov + ins * 0.35, y - h * 0.55), (x0 - ov + ins, y - h)], 6)
+ R = spline([(x1 + ov - ins, y - h), (x1 + ov - ins * 0.35, y - h * 0.55), (x1 + ov, y)], 6)
+ P = np.vstack([L, R])
+ elif kind == 'hip':
+ P = np.array([(x0 - ov, y), (x0 - ov + h * 0.75, y - h), (x1 + ov - h * 0.75, y - h), (x1 + ov, y)], np.float32)
+ elif kind == 'side':
+ P = np.array([(x0 - ov, y), (x0 - ov * 0.5, y - h), (x1 + ov * 0.5, y - h), (x1 + ov, y)], np.float32)
+ elif kind == 'pyramid':
+ P = np.array([(x0 - ov, y), (cx, y - h), (x1 + ov, y)], np.float32)
+ elif kind == 'gable':
+ apex = (cx, y - h)
+ G = np.array([(x0, y), apex, (x1, y)], np.float32)
+ self.fill(G, wall or 'cream', tex=0.7, dir=0, r=r)
+ self.flush()
+ vw = max(4.0, w * 0.07)
+ for side in (-1, 1):
+ ex = x0 - ov if side < 0 else x1 + ov
+ Vp = np.array([(cx, y - h - vw * 0.9), (ex, y + vw * 0.2), (ex - side * vw * 0.0, y + vw * 0.2 + vw * 0.9),
+ (cx, y - h + vw * 0.4)], np.float32)
+ self.slates(Vp, (tile[0] * 0.8, tile[1] * 0.8), ramp, lw, r)
+ self.ink(Vp, lw, closed=True, r=r)
+ self.ink(G[[0, 1, 2]], lw * 0.8, r=r)
+ self.flush()
+ return np.array([(x0 - ov, y), (cx, y - h - vw), (x1 + ov, y)], np.float32)
+ elif kind == 'flat':
+ P = rect(x0 - ov, y - h, x1 + ov, y)
+ self.fill(P, colour, tex=0.5, dir=1, r=r)
+ self.ink(P, lw, closed=True, corners=True, r=r)
+ self.flush()
+ return P
+ else:
+ raise ValueError(kind)
+ self.slates(P, tile, ramp, lw, r)
+ # a light ridge on top of the slate, the outline, a soft shadow line under the eave
+ self.ink(P, lw, closed=True, r=r)
+ if kind in ('mansard', 'hip', 'side'):
+ ty = P[:, 1].min()
+ top = P[np.abs(P[:, 1] - ty) < 0.5]
+ if len(top) >= 2:
+ R_ = rect(top[:, 0].min(), ty - max(2.0, tile[1] * 0.45), top[:, 0].max(), ty + 0.5)
+ self.fill(R_, 'slate_dark' if colour != 'tile' else 'tile_dark', tex=0.3, r=r)
+ self.ink(R_, lw * 0.7, closed=True, corners=True, r=r)
+ self.flush()
+ if dormers and kind in ('mansard', 'hip', 'side'):
+ n = dormers
+ dw = min(w * 0.6 / n, h * 0.62)
+ for k in range(n):
+ dx = x0 + w * (k + 0.5) / n
+ self.dormer(dx, y - h * 0.08, dw, h * 0.62, frame=dormer_frame, lw=lw, r=r, roof_col=colour)
+ self.flush()
+ return P
+
+ def dormer(self, cx, y, w, h, frame='cream', lw=None, r=None, roof_col='slate', kind=None):
+ """a dormer window on a roof face (foot at y): cheeks, a little pediment or slate gable, a window"""
+ r = r or self.rng
+ lw = self.lw if lw is None else lw
+ kind = kind or ('gable', 'round', 'gable', 'flat')[r.integers(0, 4)]
+ bh = h * 0.62
+ body = rect(cx - w / 2, y - bh, cx + w / 2, y)
+ self.fill(body, frame, tex=0.5, dir=0, r=r)
+ self.ink(body, lw * 0.85, closed=True, corners=True, r=r)
+ ww = w * 0.58
+ self.window(cx - ww / 2, y - bh + bh * 0.16, cx + ww / 2, y - bh * 0.1, kind='std', frame=frame, sill=False,
+ panes=(2, 2), lw=lw * 0.85, r=r, curtains='curtain' if r.random() < 0.3 else None)
+ if kind == 'gable':
+ T = np.array([(cx - w * 0.62, y - bh + 1), (cx, y - bh - h * 0.42), (cx + w * 0.62, y - bh + 1)], np.float32)
+ self.fill(T, deepen(roof_col if roof_col != 'tile' else 'tile', 0.05), tex=0.5, dir=2, r=r)
+ self.ink(T, lw * 0.9, closed=True, r=r)
+ Ti = np.array([(cx - w * 0.42, y - bh + 1), (cx, y - bh - h * 0.28), (cx + w * 0.42, y - bh + 1)], np.float32)
+ self.fill(Ti, frame, tex=0.4, r=r, hand=0.2)
+ self.ink(Ti, lw * 0.6, closed=True, alpha=0.7, r=r)
+ elif kind == 'round':
+ A = np.vstack([ellipse_pts(cx, y - bh + 1, w * 0.6, h * 0.36, 16, 0, np.pi, 2 * np.pi)])
+ self.fill(A, roof_col if roof_col != 'tile' else 'tile', tex=0.5, dir=2, r=r)
+ self.ink(A, lw * 0.9, closed=True, r=r)
+ else:
+ T = rect(cx - w * 0.6, y - bh - h * 0.1, cx + w * 0.6, y - bh + 1)
+ self.fill(T, deepen(roof_col if roof_col != 'tile' else 'tile', 0.1), tex=0.4, r=r)
+ self.ink(T, lw * 0.8, closed=True, corners=True, r=r)
+
+ # ================================================================== a whole townhouse
+ def house(self, x, base, w, h, wall='tomato', roof='mansard', roof_h=None, roof_col='slate', floors=4, cols=3,
+ frame='cream', glass='glass', shutters=None, curtains=0.25, boxes=0.45, flowers=None, balconies=(),
+ ground='door', door_col=None, shop=None, sign=None, awning=None, stones=0, boards=False, bands=True,
+ chimneys=1, chimney_col=None, dormers=None, aerials=0.5, win_kind='std', win_w=0.5, win_h=0.56,
+ arch_top=False, lw=None, far=None, seed=None, top_window=None, cornice='cream', arch_w=0.5, shutter_p=0.9,
+ letters='cream'):
+ """a tall narrow townhouse: wall x..x+w from `base` up h px, then its roof. Returns geometry."""
+ r = self._r(seed)
+ lw = self.lw if lw is None else lw
+ if far is not None:
+ with self.depth(far):
+ return self.house(x, base, w, h, wall, roof, roof_h, roof_col, floors, cols, frame, glass, shutters,
+ curtains, boxes, flowers, balconies, ground, door_col, shop, sign, awning, stones,
+ boards, bands, chimneys, chimney_col, dormers, aerials, win_kind, win_w, win_h,
+ arch_top, lw, None, seed, top_window, cornice, arch_w, shutter_p, letters)
+ x0, x1, yb, yt = x, x + w, base, base - h
+ info = dict(x0=x0, x1=x1, base=yb, top=yt, windows=[], wall=wall)
+ gh = h / (floors + 0.2) * 1.2 if floors > 1 else h
+ fh = (h - gh) / max(1, floors - 1)
+ # wall
+ WP = rect(x0, yt, x1, yb)
+ if ground == 'arch':
+ aw = w * arch_w; ah = gh * 0.92
+ ax0, ax1 = x0 + (w - aw) / 2, x1 - (w - aw) / 2
+ A = arch(ax0, yb - ah, ax1, yb)
+ WP = np.vstack([[(x0, yb), (x0, yt), (x1, yt), (x1, yb)], A[::-1]])
+ self.fill(WP, wall, tex=1.0, dir=PLASTER, mot=1.2, vary=0.02, r=r)
+ self.flush()
+ self.glaze(WP, top=0.0, bottom=0.1)
+ gh_ = (h / (floors + 0.2) * 1.2 if floors > 1 else h)
+ self.glaze(rect(x0, yt, x1, yt + min(h * 0.25, (h - gh_) / max(1, floors - 1) * 0.7)), top=0.2, bottom=0.0)
+ if boards:
+ for bx in np.arange(x0 + w * 0.04, x1, max(4.0, w * 0.055)):
+ self.ink([(bx, yt + 2), (bx, yb - (gh if ground == 'shop' else 0))], lw * 0.45, alpha=0.4, hand=0.4, r=r)
+ if stones:
+ self.patches(x0 + 4, yt + fh * 0.3, x1 - 4, yb - 4, wall, n=stones, size=(w * 0.12, w * 0.3), seed=int(r.integers(1 << 30)))
+ # string courses at each floor
+ if bands:
+ for k in range(1, floors):
+ yy = yb - gh - (k - 1) * fh
+ bh = max(2.0, fh * 0.05)
+ B = rect(x0, yy - bh, x1, yy + bh * 0.5)
+ self.fill(B, lighten(wall, 0.18) if bands is True else bands, tex=0.4, dir=1, r=r)
+ self.ink([(x0, yy - bh), (x1, yy - bh)], lw * 0.6, alpha=0.7, r=r)
+ self.ink([(x0, yy + bh * 0.5), (x1, yy + bh * 0.5)], lw * 0.5, alpha=0.55, r=r)
+ # cornice
+ ch = max(3.0, fh * 0.12)
+ Cn = rect(x0 - w * 0.025, yt - ch * 0.2, x1 + w * 0.025, yt + ch)
+ self.fill(Cn, cornice, tex=0.4, dir=1, r=r)
+ # windows on the upper floors
+ pitch = w / cols
+ ww0 = pitch * win_w
+ wh0 = fh * win_h
+ later = []
+ for k in range(1, floors):
+ fy1 = yb - gh - (k - 1) * fh
+ fy0 = fy1 - fh
+ for c in range(cols):
+ ww = ww0 * (1 + 0.025 * r.normal()); wh = wh0 * (1 + 0.025 * r.normal())
+ cx = x0 + pitch * (c + 0.5) + r.normal(0, 0.6)
+ wy0 = fy0 + fh * 0.2 + r.normal(0, 0.5)
+ wx0, wx1, wy1 = cx - ww / 2, cx + ww / 2, wy0 + wh
+ kind = win_kind
+ if arch_top and k == floors - 1: kind = 'arch'
+ is_bal = (k, c) in balconies or (k, -1) in balconies
+ if is_bal: wy1 = fy1 - fh * 0.04
+ sh = shutters if (shutters and r.random() < shutter_p) else None
+ cur = 'curtain' if r.random() < curtains else None
+ self.window(wx0, wy0, wx1, wy1, kind=kind, frame=frame, glass=glass, shutters=sh, curtains=cur,
+ sill=not is_bal, open_=r.random() < 0.05, lw=lw, r=r,
+ lintel='cap' if (k == 1 and h > 300 and not sh) else None)
+ info['windows'].append((wx0, wy0, wx1, wy1))
+ if is_bal:
+ later.append(('bal', wx0, wx1, wy1, ww))
+ elif r.random() < boxes:
+ later.append(('box', wx0, wx1, wy1, ww))
+ # ground floor
+ gy0 = yb - gh
+ if ground == 'shop':
+ self.shopfront(x0 + w * 0.04, gy0 + gh * 0.08, x1 - w * 0.04, yb, colour=shop or 'teal_deep', text=sign,
+ letters=letters, awning=None, lw=lw, r=r)
+ if awning: later.append(('awning',))
+ elif ground == 'door':
+ dc = door_col or ('teal', 'tomato', 'cobalt', 'green', 'mustard', 'wood')[r.integers(0, 6)]
+ pos = int(r.integers(0, cols))
+ for c in range(cols):
+ cx = x0 + pitch * (c + 0.5)
+ if c == pos:
+ dw = min(pitch * 0.62, gh * 0.48)
+ self.door(cx - dw / 2, yb - gh * 0.8, cx + dw / 2, yb, colour=dc, kind='arch' if r.random() < 0.6 else 'rect', lw=lw, r=r)
+ info['door'] = (cx - dw / 2, yb - gh * 0.8, cx + dw / 2, yb)
+ else:
+ ww, wh = ww0, gh * 0.48
+ self.window(cx - ww / 2, yb - gh * 0.72, cx + ww / 2, yb - gh * 0.72 + wh, kind=win_kind, frame=frame,
+ glass=glass, shutters=shutters, lw=lw, r=r)
+ info['windows'].append((cx - ww / 2, yb - gh * 0.72, cx + ww / 2, yb - gh * 0.72 + wh))
+ if r.random() < boxes: later.append(('box', cx - ww / 2, cx + ww / 2, yb - gh * 0.72 + wh, ww))
+ elif ground == 'arch':
+ # soffit (inner face of the archway) and voussoirs
+ A = arch(ax0, yb - ah, ax1, yb)
+ In = arch(ax0 + aw * 0.07, yb - ah + aw * 0.07, ax1 - aw * 0.07, yb)
+ info['arch'] = (ax0, yb - ah, ax1, yb)
+ n = 11
+ for i in range(n):
+ a0, a1 = np.pi + np.pi * i / n, np.pi + np.pi * (i + 1) / n
+ rr0, rr1 = aw / 2, aw / 2 + max(6, aw * 0.1)
+ cxa, cya = (ax0 + ax1) / 2, yb - ah + aw / 2
+ V = np.array([(cxa + rr0 * np.cos(a0), cya + rr0 * np.sin(a0)), (cxa + rr1 * np.cos(a0), cya + rr1 * np.sin(a0)),
+ (cxa + rr1 * np.cos(a1), cya + rr1 * np.sin(a1)), (cxa + rr0 * np.cos(a1), cya + rr0 * np.sin(a1))], np.float32)
+ self.fill(V, 'stone', tex=0.6, dir=2, vary=0.04, r=r, hand=0.2)
+ self.ink(V, lw * 0.6, closed=True, alpha=0.7, r=r)
+ self.ink(A[1:-1], lw, r=r)
+ self.ink([(ax0, yb - ah + aw / 2), (ax0, yb)], lw, r=r)
+ self.ink([(ax1, yb - ah + aw / 2), (ax1, yb)], lw, r=r)
+ # top window in a gable
+ self.ink([(x0, yt), (x0, yb)], lw, r=r)
+ self.ink([(x1, yt), (x1, yb)], lw, r=r)
+ if ground != 'arch': self.ink([(x0 - 1, yb), (x1 + 1, yb)], lw, r=r)
+ self.ink(Cn, lw, closed=True, corners=True, r=r)
+ self.flush()
+ self._flush_text()
+ # balconies, boxes, awning
+ fl = flowers
+ for it in later:
+ if it[0] == 'box':
+ _, a, b, y1, ww = it
+ fw = max(1.5, ww * 0.085)
+ self.flowerbox(a - fw * 1.6, b + fw * 1.6, y1 + fw * 2.0, max(4.0, ww * 0.2),
+ box=('terracotta', 'wood', 'teal_deep', 'cream', 'terracotta')[r.integers(0, 5)],
+ flowers=fl or ('pink', 'red', 'sunny', 'violet', 'red', 'white')[r.integers(0, 6)], lw=lw, r=r)
+ elif it[0] == 'bal':
+ _, a, b, y1, ww = it
+ self.balcony(a - ww * 0.35, b + ww * 0.35, y1, ww * 0.62, lw=lw, r=r, style='scroll' if r.random() < 0.5 else 'bars')
+ elif it[0] == 'awning':
+ self.awning(x0 + w * 0.06, x1 - w * 0.06, gy0 + gh * 0.08 + gh * 0.92 * 0.17 + 1, gh * 0.18, awning, lw=lw, r=r)
+ self.flush()
+ # roof
+ rh = roof_h if roof_h is not None else w * 0.42
+ if roof:
+ nd = dormers if dormers is not None else (max(1, cols - 1) if roof == 'mansard' else 0)
+ if roof == 'gable':
+ RP = self.roof('gable', x0 - w * 0.025, x1 + w * 0.025, yt - ch * 0.2, rh, roof_col, lw=lw, r=r, wall=wall)
+ if top_window != 'none':
+ tw_ = min(w * 0.22, rh * 0.32)
+ self.window(x0 + w / 2 - tw_ / 2, yt - rh * 0.5 - tw_ / 2, x0 + w / 2 + tw_ / 2, yt - rh * 0.5 + tw_ / 2,
+ kind=top_window or 'round', frame=frame, lw=lw * 0.9, r=r, sill=False)
+ self.flush()
+ else:
+ RP = self.roof(roof, x0 - w * 0.025, x1 + w * 0.025, yt - ch * 0.2, rh, roof_col, lw=lw, r=r,
+ dormers=nd, dormer_frame=frame)
+ info['roof'] = RP
+ ytop = float(RP[:, 1].min())
+ else:
+ ytop = yt
+ info['roof'] = rect(x0, yt, x1, yt)
+ info['ridge'] = ytop
+ # chimneys and aerials
+ tops = []
+ for k in range(chimneys):
+ cxk = x0 + w * (0.18 + 0.64 * (k + r.uniform(0.0, 1.0)) / max(1, chimneys)) if chimneys > 1 else x0 + w * r.uniform(0.2, 0.8)
+ cwk = max(6.0, w * r.uniform(0.08, 0.12))
+ chh = max(12.0, rh * r.uniform(0.35, 0.6)) if roof else w * 0.2
+ foot = ytop + (rh * 0.15 if roof in ('mansard', 'hip', 'side') else 0)
+ if roof == 'gable':
+ foot = yt - rh * (1 - abs(cxk - (x0 + w / 2)) / (w / 2)) * 0.9
+ tp = self.chimney(cxk, foot, cwk, chh, chimney_col or ('cream', 'brick', 'stone', wall)[r.integers(0, 4)],
+ pots=int(r.integers(1, 4)), lw=lw, r=r)
+ tops.append((cxk, tp))
+ if r.random() < aerials and tops:
+ cxk, tp = tops[int(r.integers(0, len(tops)))]
+ self.aerial(cxk, tp, max(26.0, w * r.uniform(0.35, 0.6)), bars=int(r.integers(2, 4)), lw=lw, r=r)
+ self.flush()
+ info['chimneys'] = tops
+ return info
+
+ # ================================================================== the clock tower
+ def clock_tower(self, cx, base, w, h, body='ivory', quoins='stone', dome='slate', time=(9, 5), flag='tomato',
+ lw=None, seed=None):
+ """a white clock tower: a shaft with tall arched windows and quoins, a clock stage, a belfry with three
+ louvred arched openings, an onion dome (dome='slate' or 'verdigris') with a lantern, a spire and a flag"""
+ r = self._r(seed)
+ lw = self.lw if lw is None else lw
+ x0, x1 = cx - w / 2, cx + w / 2
+ hs = h * 0.5 # shaft
+ hc = w * 1.05 # clock stage
+ y_shaft = base - hs
+ y_clock = y_shaft - hc
+ bw = w * 0.86
+ hb = w * 0.8 # belfry
+ y_bel = y_clock - hb
+ # shaft
+ S = rect(x0, y_shaft, x1, base)
+ self.fill(S, body, tex=0.8, dir=0, r=r)
+ qh = max(6.0, w * 0.1)
+ for side in (0, 1):
+ for k, yy in enumerate(np.arange(y_shaft + 4, base, qh)):
+ qw = w * (0.16 if k % 2 == 0 else 0.1)
+ qx0 = x0 if side == 0 else x1 - qw
+ Q = rect(qx0, yy, qx0 + qw, yy + qh - 1)
+ self.fill(Q, quoins, tex=0.6, dir=2, vary=0.03, r=r, hand=0.2)
+ self.ink(Q, lw * 0.5, closed=True, alpha=0.55, r=r)
+ ww = w * 0.2
+ for yy in (y_shaft + hs * 0.12, y_shaft + hs * 0.55):
+ self.window(cx - ww / 2, yy, cx + ww / 2, yy + hs * 0.3, kind='arch', frame='stone', panes=(2, 3), lw=lw * 0.9, r=r, sill=True)
+ self.ink(S, lw, closed=True, corners=True, r=r)
+ # cornice under the clock stage
+ Cn = rect(x0 - w * 0.06, y_shaft - w * 0.05, x1 + w * 0.06, y_shaft + w * 0.03)
+ self.fill(Cn, 'stone', tex=0.4, dir=1, r=r)
+ self.ink(Cn, lw, closed=True, corners=True, r=r)
+ # clock stage
+ K = rect(x0 + w * 0.02, y_clock, x1 - w * 0.02, y_shaft - w * 0.05)
+ self.fill(K, body, tex=0.8, dir=0, r=r)
+ self.ink(K, lw, closed=True, corners=True, r=r)
+ ccy = (y_clock + y_shaft) / 2
+ R = w * 0.36
+ self.fill(ellipse_pts(cx, ccy, R * 1.12, R * 1.12, 40), quoins, tex=0.4, r=r, hand=0.2)
+ self.fill(ellipse_pts(cx, ccy, R, R, 40), '#fbf7ec', tex=0.3, dir=2, r=r, hand=0.2)
+ self.ink(ellipse_pts(cx, ccy, R * 1.12, R * 1.12, 40), lw, closed=True, r=r)
+ self.ink(ellipse_pts(cx, ccy, R, R, 40), lw * 1.2, closed=True, r=r)
+ self.ink(ellipse_pts(cx, ccy, R * 0.8, R * 0.8, 40), lw * 0.5, closed=True, alpha=0.6, r=r)
+ for k in range(12):
+ a = k / 12 * 2 * np.pi
+ l0 = 0.82 if k % 3 else 0.7
+ self.ink([(cx + np.sin(a) * R * l0, ccy - np.cos(a) * R * l0), (cx + np.sin(a) * R * 0.93, ccy - np.cos(a) * R * 0.93)],
+ lw * (1.1 if k % 3 == 0 else 0.7), hand=0, r=r)
+ hh, mm = time
+ am = mm / 60 * 2 * np.pi; ah = (hh % 12 + mm / 60) / 12 * 2 * np.pi
+ for a, L, wd in ((ah, 0.5, 0.075), (am, 0.74, 0.05)):
+ d = np.array([np.sin(a), -np.cos(a)]); n = np.array([-d[1], d[0]])
+ P = np.array([(cx, ccy) - d * R * 0.12 + n * R * wd * 0.5, (cx, ccy) + d * R * L, (cx, ccy) - d * R * 0.12 - n * R * wd * 0.5], np.float32)
+ self.fill(P, 'ink', tex=0, hand=0, r=r)
+ self.dab(cx, ccy, R * 0.06, 'ink', rr=r)
+ Cn2 = rect(x0 - w * 0.05, y_clock - w * 0.05, x1 + w * 0.05, y_clock + w * 0.02)
+ self.fill(Cn2, 'stone', tex=0.4, dir=1, r=r)
+ self.ink(Cn2, lw, closed=True, corners=True, r=r)
+ # belfry
+ B = rect(cx - bw / 2, y_bel, cx + bw / 2, y_clock - w * 0.05)
+ self.fill(B, body, tex=0.8, dir=0, r=r)
+ ow = bw * 0.2
+ for ox in (cx - bw * 0.28, cx, cx + bw * 0.28):
+ O = arch(ox - ow / 2, y_bel + hb * 0.16, ox + ow / 2, y_clock - w * 0.16)
+ self.fill(O, '#7a5f4a', tex=0.5, r=r)
+ for yy in np.arange(y_bel + hb * 0.16 + ow * 0.55, y_clock - w * 0.18, max(3.0, ow * 0.2)):
+ self.fill(rect(ox - ow / 2, yy, ox + ow / 2, yy + max(1.2, ow * 0.08)), '#a8876a', tex=0.2, hand=0, r=r)
+ self.ink([(ox - ow / 2, yy + max(1.2, ow * 0.08)), (ox + ow / 2, yy + max(1.2, ow * 0.08))], lw * 0.4, alpha=0.6, hand=0, r=r)
+ self.ink(O, lw * 0.9, closed=True, r=r)
+ self.ink(B, lw, closed=True, corners=True, r=r)
+ Cn3 = rect(cx - bw / 2 - w * 0.06, y_bel - w * 0.06, cx + bw / 2 + w * 0.06, y_bel + w * 0.02)
+ self.fill(Cn3, 'stone', tex=0.4, dir=1, r=r)
+ self.ink(Cn3, lw, closed=True, corners=True, r=r)
+ # small urns on the corners
+ for ux in (cx - bw / 2 - w * 0.02, cx + bw / 2 + w * 0.02):
+ U = ellipse_pts(ux, y_bel - w * 0.12, w * 0.05, w * 0.07, 12)
+ self.fill(U, 'stone', tex=0.3, r=r, hand=0)
+ self.ink(U, lw * 0.7, closed=True, r=r)
+ self.flush()
+ # onion dome
+ dy0 = y_bel - w * 0.06
+ dh = w * 0.95
+ dwid = bw * 0.62
+ t = np.linspace(0, 1, 30)
+ prof = np.sin(np.pi * np.clip(t * 1.1, 0, 1)) ** 0.75 * (1 - 0.15 * t) * (1 - t) ** 0.35
+ prof = prof / prof.max()
+ xs_r = cx + dwid * prof; ys = dy0 - dh * t
+ D = np.vstack([np.stack([xs_r, ys], 1), np.stack([2 * cx - xs_r, ys], 1)[::-1]])
+ self.fill(D, dome, tex=0.6, dir=2, r=r)
+ for k in np.linspace(-0.66, 0.66, 5):
+ rib = np.stack([cx + k * dwid * prof, ys], 1)
+ self.ink(rib, lw * 0.55, alpha=0.6, colour='slate_dark' if dome == 'slate' else deepen(dome, 0.6), r=r)
+ hl = np.stack([cx - 0.45 * dwid * prof[3:22], ys[3:22]], 1)
+ self.ink(hl, lw * 1.6, alpha=0.35, colour='#e8eef0', hand=0.3, r=r)
+ self.ink(D, lw, closed=True, r=r)
+ self.flush()
+ # lantern, cap, spire
+ lt = dy0 - dh * 0.92
+ lwid = dwid * 0.36
+ Lb = rect(cx - lwid, lt - w * 0.32, cx + lwid, lt + 2)
+ self.fill(Lb, body, tex=0.5, r=r)
+ for ox in (cx - lwid * 0.45, cx + lwid * 0.45):
+ O = arch(ox - lwid * 0.25, lt - w * 0.27, ox + lwid * 0.25, lt - w * 0.04)
+ self.fill(O, '#3a4048', tex=0.3, r=r, hand=0.2)
+ self.ink(Lb, lw * 0.9, closed=True, corners=True, r=r)
+ capy = lt - w * 0.32
+ Cp = ellipse_pts(cx, capy, lwid * 1.25, w * 0.16, 20, 0, np.pi, 2 * np.pi)
+ Cp = np.vstack([Cp, [(cx + lwid * 1.25, capy)]])
+ self.fill(Cp, dome, tex=0.5, r=r)
+ self.ink(Cp, lw * 0.9, closed=True, r=r)
+ sp = np.array([(cx - w * 0.05, capy - w * 0.14), (cx, capy - w * 0.62), (cx + w * 0.05, capy - w * 0.14)], np.float32)
+ self.fill(sp, dome, tex=0.4, r=r, hand=0)
+ self.ink(sp, lw * 0.8, closed=True, r=r)
+ self.dab(cx, capy - w * 0.62, w * 0.045, 'gold', rr=r)
+ self.flush()
+ self.vane(cx, capy - w * 0.64, w * 0.5, flag=flag, lw=lw, r=r)
+ self.flush()
+ return dict(top=capy - w * 0.64 - w * 0.5, clock=(cx, ccy, R), belfry=y_bel, x0=x0, x1=x1, shaft=y_shaft)
+
+ # ================================================================== stairs, walls, railings
+ def stairs(self, bottom, top, n=14, tread='stone', riser='stone_mid', lw=None, seed=None, ratio=1.06):
+ """a flight of stone steps going up and away: bottom = (xl, xr, y), top = (xl, xr, y).
+ Steps shrink toward the top (they are further away)."""
+ r = self._r(seed)
+ lw = self.lw if lw is None else lw
+ (bl, br, by), (tl, tr, ty) = bottom, top
+ g = np.array([ratio ** k for k in range(n)], np.float32)[::-1] # bottom steps bigger
+ g = g / g.sum() * (by - ty)
+ ys = ty + np.concatenate([[0], np.cumsum(g[::-1])]) # top -> bottom boundaries
+ def xs(y):
+ t = (y - ty) / (by - ty + 1e-6)
+ return tl + (bl - tl) * t, tr + (br - tr) * t
+ for k in range(n):
+ ya, yb_ = ys[k], ys[k + 1]
+ yn = ya + (yb_ - ya) * 0.38
+ la, ra = xs(ya); lb, rb = xs(yb_); ln, rn = xs(yn)
+ T = np.array([(la, ya), (ra, ya), (rn, yn), (ln, yn)], np.float32)
+ Rr = np.array([(ln, yn), (rn, yn), (rb, yb_), (lb, yb_)], np.float32)
+ self.fill(T, tread, tex=0.6, dir=1, vary=0.03, r=r, hand=0.3)
+ self.fill(Rr, riser, tex=0.7, dir=1, vary=0.04, r=r, hand=0.3)
+ nslab = int(r.integers(2, 4))
+ for j in range(1, nslab):
+ t = j / nslab + r.normal(0, 0.06)
+ self.ink([(ln + (rn - ln) * t, yn), (lb + (rb - lb) * t, yb_)], lw * 0.5, alpha=0.45, hand=0, r=r)
+ self.ink([(ln, yn), (rn, yn)], lw * 0.85, r=r)
+ self.ink([(lb, yb_), (rb, yb_)], lw * 0.55, alpha=0.6, r=r)
+ self.ink([(tl, ty), (bl, by)], lw, r=r)
+ self.ink([(tr, ty), (br, by)], lw, r=r)
+ self.flush()
+ return ys, xs
+
+ def parapet(self, pts_top, pts_bottom, colour='stone', cap=True, lw=None, seed=None, course=12.0):
+ """a stone wall between a top edge and a bottom edge (polylines left->right), stonework inked"""
+ r = self._r(seed)
+ lw = self.lw if lw is None else lw
+ T = np.asarray(pts_top, np.float32); B = np.asarray(pts_bottom, np.float32)
+ P = np.vstack([T, B[::-1]])
+ self.fill(P, colour, tex=0.8, dir=2, vary=0.03, r=r)
+ y0, y1 = P[:, 1].min(), P[:, 1].max()
+ x0, x1 = P[:, 0].min(), P[:, 0].max()
+ for yy in np.arange(y0 + course, y1, course):
+ self.ink([(x0, yy), (x1, yy)], lw * 0.45, alpha=0.4, hand=0.6, split=1e9, r=r)
+ off = r.uniform(0, course * 2.2)
+ for xx in np.arange(x0 + off, x1, course * r.uniform(1.8, 2.6)):
+ self.ink([(xx, yy - course), (xx, yy)], lw * 0.45, alpha=0.4, hand=0, r=r)
+ self.flush(clip=P)
+ if cap:
+ Tc = np.vstack([T + (0, -max(3, course * 0.4)), T[::-1] + (0, max(2, course * 0.25))])
+ self.fill(Tc, lighten(colour, 0.2), tex=0.4, dir=1, r=r)
+ self.ink(Tc, lw * 0.9, closed=True, r=r)
+ self.ink(P, lw, closed=True, r=r)
+ self.flush()
+
+ def railing(self, path, h, spacing=None, lw=None, colour='iron', posts=None, seed=None):
+ """an iron handrail h px above `path` (a polyline along stairs or a terrace), balusters down to it"""
+ r = self._r(seed)
+ lw = self.lw if lw is None else lw
+ P = np.asarray(path, np.float32)
+ top = P - (0, h)
+ self.ink(top, lw * 1.3, colour=colour, r=r)
+ self.ink(P - (0, h * 0.12), lw * 0.7, colour=colour, r=r)
+ d = np.diff(P, axis=0); s = np.concatenate([[0], np.cumsum(np.hypot(d[:, 0], d[:, 1]))])
+ sp = spacing or max(3.5, h * 0.12)
+ for si in np.arange(0, s[-1] + 1e-3, sp):
+ x = np.interp(si, s, P[:, 0]); y = np.interp(si, s, P[:, 1])
+ self.ink([(x, y - h), (x, y)], lw * 0.5, colour=colour, alpha=0.85, hand=0.1, r=r)
+ for si in np.arange(0, s[-1] + 1e-3, posts or sp * 8):
+ x = np.interp(si, s, P[:, 0]); y = np.interp(si, s, P[:, 1])
+ self.ink([(x, y - h - 3), (x, y)], lw * 1.2, colour=colour, r=r)
+ self.dab(x, y - h - 3, lw * 1.3, colour, rr=r)
+ self.flush()
+
+ # ================================================================== plants
+ def roses(self, path, n=40, colour='rose', dark='rose_dark', light='rose_light', size=6.0, leaves=1.0, spread=None,
+ top_heavy=0.6, seed=None, lw=None, clusters=True):
+ """a climbing rose: a wandering stem along `path` (bottom -> top), side shoots, pairs of leaves, and roses
+ in small clusters, more of them toward the top"""
+ r = self._r(seed)
+ lw = self.lw if lw is None else lw
+ P = spline(np.asarray(path, np.float32), 10)
+ d = np.diff(P, axis=0); s = np.concatenate([[0], np.cumsum(np.hypot(d[:, 0], d[:, 1]))]); L = s[-1]
+ spread = size * 2.6 if spread is None else spread
+ stem = '#56603a'
+ P2 = P + np.stack([np.sin(s / (size * 4.5)) * size * 0.8, np.zeros_like(s)], 1)
+ self.ink(P, lw * 1.15, colour=stem, alpha=0.9, hand=0.9, r=r)
+ self.ink(P2, lw * 0.7, colour=stem, alpha=0.75, hand=0.9, r=r)
+ for _ in range(int(L / (size * 6)) + 1):
+ si = r.uniform(0.1, 1) * L
+ bx, by = np.interp(si, s, P[:, 0]), np.interp(si, s, P[:, 1])
+ sd = 1 if r.random() < 0.5 else -1
+ self.ink([(bx, by), (bx + sd * spread * 0.7, by - size * 1.2), (bx + sd * spread * 1.1, by - size * 2.6)],
+ lw * 0.6, colour=stem, alpha=0.7, hand=0.5, r=r)
+ nl = int(L / size * 2.6 * leaves)
+ for _ in range(nl):
+ si = r.uniform(0, L)
+ x = np.interp(si, s, P[:, 0]) + r.normal(0, spread * 0.5); y = np.interp(si, s, P[:, 1]) + r.normal(0, spread * 0.3)
+ ang = r.uniform(-2.7, -0.4)
+ for k in (-1, 1):
+ self.leaf(x + k * size * 0.4, y + k * size * 0.1, size * r.uniform(1.0, 1.5), size * r.uniform(0.55, 0.75),
+ ang + k * 0.7, ('leaf_dark', 'leaf', 'leaf_dark', 'leaf_mid')[r.integers(0, 4)], r=r)
+ self.flush()
+ u = 1 - (1 - r.random(n)) ** (1 + 2 * top_heavy)
+ pts = []
+ for i in range(n):
+ si = u[i] * L
+ x = np.interp(si, s, P[:, 0]) + r.normal(0, spread * 0.55); y = np.interp(si, s, P[:, 1]) + r.normal(0, spread * 0.3)
+ pts.append((x, y))
+ if clusters and r.random() < 0.45:
+ for _ in range(int(r.integers(1, 3))):
+ pts.append((x + r.normal(0, size * 1.3), y + r.normal(0, size * 1.1)))
+ pts.sort(key=lambda p: p[1])
+ for x, y in pts:
+ for _ in range(2):
+ a = r.uniform(0, 2 * np.pi)
+ self.leaf(x + np.cos(a) * size * 0.95, y + np.sin(a) * size * 0.75, size * r.uniform(1.0, 1.4), size * 0.62,
+ a + r.normal(0, 0.4), ('leaf_dark', 'leaf')[r.integers(0, 2)], r=r)
+ for x, y in pts:
+ rr = size * r.uniform(0.75, 1.2)
+ if r.random() < 0.14:
+ self.fill(leaf_pts(x, y, rr * 1.2, rr * 0.8, -np.pi / 2 + r.normal(0, 0.4)), dark, tex=0.3, hand=0, r=r)
+ continue
+ n_ = 16
+ ang = np.linspace(0, 2 * np.pi, n_, endpoint=False) + r.uniform(0, 1)
+ rad = rr * (1 + 0.12 * np.sin(ang * r.integers(4, 6) + r.uniform(0, 6)) + 0.05 * r.normal(0, 1, n_))
+ cup = np.stack([x + np.cos(ang) * rad, y + np.sin(ang) * rad * 0.88], 1).astype(np.float32)
+ self.fill(cup, colour, tex=0.4, dir=2, hand=0, vary=0.05, r=r)
+ self.fill(ellipse_pts(x + rr * 0.08, y + rr * 0.08, rr * 0.5, rr * 0.42, 12, r.uniform(0, 3)), deepen(colour, 0.22),
+ tex=0.3, hand=0, r=r)
+ self.fill(ellipse_pts(x - rr * 0.25, y - rr * 0.42, rr * 0.55, rr * 0.22, 10, -0.25), mix(colour, light, 0.45),
+ tex=0.3, hand=0, r=r)
+ for k in range(3):
+ a0 = r.uniform(0, 2 * np.pi); rk = rr * (0.28 + 0.2 * k)
+ self.ink(ellipse_pts(x, y, rk, rk * 0.85, 10, 0, a0, a0 + r.uniform(1.8, 3.2)), max(0.55, min(lw * 0.6, rr * 0.14)),
+ colour=dark, alpha=0.85, hand=0, r=r)
+ self.ink(cup, max(0.5, lw * 0.45), closed=True, colour=dark, alpha=0.55, hand=0, r=r)
+ self.flush()
+
+ def tree(self, x, base, h, rad, trunk='trunk', ramp=('leaf_dark', '#3a7040', 'leaf', 'leaf_mid', 'leaf_light'),
+ clumps=9, leaf=(7, 12), density=1.0, lean=0.0, seed=None, lw=None):
+ """a rounded street tree: trunk and branches in ink, a crown of clumps of small leaf dabs lit from the upper left"""
+ r = self._r(seed)
+ lw = self.lw if lw is None else lw
+ ccx, ccy = x + lean * h, base - h + rad * 0.85
+ tw = max(4.0, rad * 0.09)
+ T = spline([(x - tw, base), (x - tw * 0.8 + lean * h * 0.4, base - h * 0.4), (ccx - tw * 0.5, ccy + rad * 0.2)], 8)
+ T2 = spline([(ccx + tw * 0.5, ccy + rad * 0.2), (x + tw * 0.8 + lean * h * 0.4, base - h * 0.4), (x + tw, base)], 8)
+ TP = np.vstack([T, T2])
+ self.fill(TP, trunk, tex=0.8, dir=0, r=r)
+ self.ink(T, lw, r=r); self.ink(T2, lw, r=r)
+ for k in range(4):
+ a = -np.pi / 2 + r.uniform(-1.1, 1.1)
+ sx, sy = ccx + r.normal(0, tw), ccy + rad * 0.25
+ ex, ey = sx + np.cos(a) * rad * 0.6, sy + np.sin(a) * rad * 0.55
+ self.ink([(sx, sy), ((sx + ex) / 2 + r.normal(0, 4), (sy + ey) / 2), (ex, ey)], lw * 1.2, colour='trunk', r=r)
+ self.flush()
+ cl = []
+ for k in range(clumps):
+ a = r.uniform(0, 2 * np.pi); d = r.uniform(0.25, 0.66) * (0 if k == 0 else 1)
+ cr = rad * r.uniform(0.32, 0.46)
+ cl.append((ccx + np.cos(a) * rad * d, ccy + np.sin(a) * rad * d * 0.8 - rad * 0.05, cr))
+ cl.sort(key=lambda c: -c[1]) # lower clumps first, the top ones lie over them
+ ramp_c = [hexc(c) for c in ramp]
+ Lx, Ly = -0.6, -0.8
+ for (cx, cy, cr) in cl:
+ self.fill(ellipse_pts(cx, cy + cr * 0.08, cr * 0.9, cr * 0.82, 22), ramp_c[0], tex=0.8, dir=2, hand=1.4, r=r)
+ for (cx, cy, cr) in cl:
+ m = int(cr * cr / (leaf[0] * leaf[1]) * 3.4 * density)
+ ang = r.uniform(0, 2 * np.pi, m); rd = np.sqrt(r.random(m)) * cr * 1.06
+ px, py = cx + np.cos(ang) * rd, cy + np.sin(ang) * rd * 0.9
+ nx, ny = (px - cx) / cr, (py - cy) / cr
+ nz = np.sqrt(np.clip(1 - nx * nx - ny * ny, 0, 1))
+ dome = nx * Lx * 0.7 + ny * Ly * 0.7 + nz * 0.45
+ glob_ = -0.25 * (cy - ccy) / rad - 0.12 * (cx - ccx) / rad
+ lit = np.clip(0.18 + 0.7 * dome + glob_ + 0.12 * r.normal(0, 1, m), 0, 0.999)
+ order = np.argsort(lit)
+ for i in order:
+ c = ramp_c[min(len(ramp_c) - 1, int(lit[i] ** 1.25 * len(ramp_c)))]
+ self.leaf(px[i], py[i], r.uniform(*leaf), r.uniform(*leaf) * 0.55, np.arctan2(ny[i], nx[i]) * 0.6 - 0.9 + r.normal(0, 0.7),
+ c, vary=0.03, r=r)
+ self.flush()
+
+ def pot(self, x, base, w, h, plant='bush', colour='terracotta', flowers='red', lw=None, seed=None):
+ """a terracotta pot on the ground with a bush, a tall plant or flowers"""
+ r = self._r(seed)
+ lw = self.lw if lw is None else lw
+ P = np.array([(x - w / 2, base - h), (x + w / 2, base - h), (x + w * 0.38, base), (x - w * 0.38, base)], np.float32)
+ rim = rect(x - w * 0.56, base - h - h * 0.16, x + w * 0.56, base - h + h * 0.05)
+ if plant == 'tall':
+ for _ in range(int(14 * max(1, w / 20))):
+ a = -np.pi / 2 + r.normal(0, 0.5)
+ L = h * r.uniform(1.2, 2.6)
+ self.leaf(x + np.cos(a) * L * 0.5, base - h + np.sin(a) * L * 0.5, L, w * 0.18, a, ('leaf_dark', 'leaf', 'leaf_mid')[r.integers(0, 3)], r=r)
+ else:
+ cr = w * 0.75
+ for _ in range(int(cr * cr / 8)):
+ a = r.uniform(np.pi, 2 * np.pi); d = np.sqrt(r.random()) * cr
+ lx, ly = x + np.cos(a) * d, base - h - h * 0.1 + np.sin(a) * d * 0.85
+ lit = np.clip(0.5 - 0.5 * (np.cos(a) * 0.6 + np.sin(a) * 0.8) * d / cr + 0.15 * r.normal(), 0, 0.99)
+ self.leaf(lx, ly, cr * 0.32, cr * 0.18, a + r.normal(0, 0.5), ('leaf_dark', 'leaf', 'leaf_mid', 'leaf_light')[int(lit * 4)], r=r)
+ if plant == 'flowers':
+ fc = FLOWER_SETS.get(flowers, flowers)
+ for _ in range(int(cr * 0.9)):
+ a = r.uniform(np.pi, 2 * np.pi); d = np.sqrt(r.random()) * cr * 0.9
+ self.dab(x + np.cos(a) * d, base - h - h * 0.1 + np.sin(a) * d * 0.85, cr * r.uniform(0.09, 0.14), fc[r.integers(0, 3)], rr=r)
+ self.fill(P, colour, tex=0.6, dir=0, vary=0.05, r=r)
+ self.fill(rim, deepen(colour, 0.08), tex=0.4, r=r)
+ self.ink(P, lw * 0.9, closed=True, r=r)
+ self.ink(rim, lw * 0.8, closed=True, corners=True, r=r)
+ self.flush()
+
+ # ================================================================== bunting, lamps, signs, people
+ def bunting(self, p0, p1, sag=40.0, size=24.0, gap=0.25, colours=BUNTING, seed=None, lw=None, start=None):
+ """a string of triangular pennants sagging from p0 to p1; size = pennant width in px"""
+ r = self._r(seed)
+ lw = self.lw if lw is None else lw
+ (ax, ay), (bx, by) = p0, p1
+ n = 200
+ t = np.linspace(0, 1, n)
+ X = ax + (bx - ax) * t; Y = ay + (by - ay) * t + sag * 4 * t * (1 - t)
+ S = np.stack([X, Y], 1)
+ d = np.diff(S, axis=0); s = np.concatenate([[0], np.cumsum(np.hypot(d[:, 0], d[:, 1]))]); L = s[-1]
+ step = size * (1 + gap)
+ ci = int(r.integers(0, len(colours))) if start is None else start
+ lw_s = max(0.6, min(lw, size * 0.06))
+ for si in np.arange(step * 0.4, L - size, step):
+ p = np.array([np.interp(si, s, X), np.interp(si, s, Y)])
+ q = np.array([np.interp(si + size, s, X), np.interp(si + size, s, Y)])
+ dv = q - p; dl = np.hypot(*dv) + 1e-6
+ nv = np.array([-dv[1], dv[0]]) / dl
+ if nv[1] < 0: nv = -nv
+ # pennants hang more vertically than the string's normal
+ hang = nv * 0.55 + np.array([0, 1]) * 0.45; hang /= np.hypot(*hang)
+ hang = hang + r.normal(0, 0.05, 2)
+ tip = (p + q) / 2 + hang * size * r.uniform(1.0, 1.15)
+ col = hexc(colours[ci % len(colours)]); ci += 1 + (r.random() < 0.12)
+ self.fill(np.array([p, q, tip], np.float32), col, tex=0.6, dir=2, hand=0, vary=0.03, r=r)
+ mid = (p + q) / 2
+ self.fill(np.array([mid, q, tip], np.float32), deepen(col, 0.13), tex=0.6, dir=2, hand=0, r=r)
+ self.ink(np.array([p, tip, q], np.float32), lw_s, alpha=0.75, hand=0.15 if size > 20 else 0, r=r)
+ self.ink(S, lw_s * 1.1, alpha=0.85, hand=0.2, r=r)
+ self.flush()
+
+ def lamp(self, x, base, h, wall=None, lw=None, seed=None, colour='iron'):
+ """an iron street lamp on a post (or on a wall bracket, wall=x of the wall)"""
+ r = self._r(seed)
+ lw = self.lw if lw is None else lw
+ lh = h * 0.16; lwid = lh * 0.42
+ if wall is None:
+ pw = max(2.5, h * 0.025)
+ self.fill(rect(x - pw, base - h, x + pw, base), colour, tex=0.2, hand=0.2, r=r)
+ self.fill(np.array([(x - pw * 3, base), (x + pw * 3, base), (x + pw * 1.6, base - h * 0.08), (x - pw * 1.6, base - h * 0.08)], np.float32), colour, tex=0.2, hand=0, r=r)
+ top = (x, base - h)
+ else:
+ dirx = 1 if x > wall else -1
+ arm = spline([(wall, base - h), (wall + dirx * abs(x - wall) * 0.5, base - h - lh * 0.4), (x, base - h - lh * 0.1)], 8)
+ self.ink(arm, lw * 1.5, colour=colour, r=r)
+ self.ink(ellipse_pts(wall + dirx * abs(x - wall) * 0.35, base - h + lh * 0.25, lh * 0.25, lh * 0.25, 12, 0, 0, 5), lw, colour=colour, r=r)
+ top = (x, base - h + lh * 0.2)
+ tx, ty = top
+ G = np.array([(tx - lwid, ty - lh), (tx + lwid, ty - lh), (tx + lwid * 0.7, ty), (tx - lwid * 0.7, ty)], np.float32)
+ self.fill(G, '#f6e2a8', tex=0.3, r=r, hand=0)
+ self.ink(G, lw, closed=True, colour=colour, r=r)
+ self.ink([(tx, ty - lh), (tx, ty)], lw * 0.6, colour=colour, r=r)
+ Cp = np.array([(tx - lwid * 1.3, ty - lh), (tx, ty - lh - lh * 0.45), (tx + lwid * 1.3, ty - lh)], np.float32)
+ self.fill(Cp, colour, tex=0.2, hand=0, r=r)
+ self.dab(tx, ty - lh - lh * 0.5, lwid * 0.25, colour, rr=r)
+ self.flush()
+
+ def sign(self, wall_x, y, r_, colour='tomato', icon='cup', side=1, lw=None, seed=None, text=None):
+ """a hanging shop sign on a curly iron bracket sticking out from a wall"""
+ r = self._r(seed)
+ lw = self.lw if lw is None else lw
+ L = r_ * 2.6
+ x1 = wall_x + side * L
+ self.ink([(wall_x, y), (x1, y)], lw * 1.3, colour='iron', r=r)
+ self.ink(spline([(wall_x, y + r_ * 0.9), (wall_x + side * L * 0.45, y + r_ * 0.15), (wall_x + side * L * 0.8, y)], 8), lw, colour='iron', r=r)
+ self.ink(ellipse_pts(wall_x + side * L * 0.3, y - r_ * 0.28, r_ * 0.25, r_ * 0.25, 14, 0, 0, 5.2), lw * 0.8, colour='iron', r=r)
+ cx, cy = wall_x + side * L * 0.62, y + r_ * 1.25
+ self.ink([(cx - r_ * 0.4, y), (cx - r_ * 0.4, cy - r_)], lw * 0.6, colour='iron', r=r)
+ self.ink([(cx + r_ * 0.4, y), (cx + r_ * 0.4, cy - r_)], lw * 0.6, colour='iron', r=r)
+ D = ellipse_pts(cx, cy, r_, r_, 30)
+ self.fill(D, colour, tex=0.6, dir=2, r=r)
+ self.fill(ellipse_pts(cx, cy, r_ * 0.8, r_ * 0.8, 30), lighten(colour, 0.12), tex=0.5, r=r)
+ if icon == 'cup':
+ C = np.array([(cx - r_ * 0.38, cy - r_ * 0.22), (cx + r_ * 0.3, cy - r_ * 0.22), (cx + r_ * 0.22, cy + r_ * 0.32), (cx - r_ * 0.3, cy + r_ * 0.32)], np.float32)
+ self.fill(C, 'cream', tex=0.3, hand=0, r=r)
+ self.ink(ellipse_pts(cx + r_ * 0.36, cy, r_ * 0.13, r_ * 0.16, 12, 0, -1.6, 1.6), lw * 0.9, colour='cream', alpha=1, r=r)
+ for k in (-1, 0, 1):
+ self.ink([(cx + k * r_ * 0.15, cy - r_ * 0.35), (cx + k * r_ * 0.15 + r_ * 0.06, cy - r_ * 0.55)], lw * 0.6, colour='cream', alpha=0.9, r=r)
+ elif icon == 'key':
+ self.ink(ellipse_pts(cx - r_ * 0.3, cy, r_ * 0.2, r_ * 0.2, 14), lw * 1.2, closed=True, colour='gold', alpha=1, r=r)
+ self.ink([(cx - r_ * 0.1, cy), (cx + r_ * 0.45, cy)], lw * 1.2, colour='gold', alpha=1, r=r)
+ self.ink([(cx + r_ * 0.3, cy), (cx + r_ * 0.3, cy + r_ * 0.18)], lw * 1.1, colour='gold', alpha=1, r=r)
+ elif icon == 'loaf':
+ Lf = ellipse_pts(cx, cy, r_ * 0.48, r_ * 0.28, 20)
+ self.fill(Lf, 'apricot', tex=0.3, hand=0, r=r)
+ for k in (-1, 0, 1):
+ self.ink([(cx + k * r_ * 0.18 - r_ * 0.06, cy - r_ * 0.12), (cx + k * r_ * 0.18 + r_ * 0.06, cy + r_ * 0.1)], lw * 0.7, r=r)
+ elif icon == 'flower':
+ for k in range(5):
+ a = k / 5 * 2 * np.pi
+ self.dab(cx + np.cos(a) * r_ * 0.25, cy + np.sin(a) * r_ * 0.25, r_ * 0.2, 'blossom_pink', rr=r)
+ self.dab(cx, cy, r_ * 0.15, 'blossom_yellow', rr=r)
+ self.ink(D, lw, closed=True, r=r)
+ self.flush()
+
+ def person(self, x, base, h, coat='cobalt', legs='#3b3b46', hair='hair', umbrella=None, bag=None, facing=1,
+ reflect=False, lw=None, seed=None, stride=0.3, balloon=None, basket=None):
+ """a small, very simple passer-by seen from behind / three-quarter (no face), optional umbrella"""
+ r = self._r(seed)
+ lw = self.lw if lw is None else lw
+ hr = h * 0.085
+ def parts(sgn):
+ # sgn = -1 draws the reflection upside down about the base line
+ def P(pts):
+ a = np.asarray(pts, np.float32).copy()
+ if sgn < 0: a[:, 1] = 2 * base - a[:, 1]
+ return a
+ out = []
+ hip = base - h * 0.44
+ for k, st in ((-1, stride), (1, -stride)):
+ lx = x + k * h * 0.05
+ out.append((P([(lx - h * 0.035, hip), (lx + h * 0.035, hip), (lx + st * h * 0.18 + h * 0.03, base), (lx + st * h * 0.18 - h * 0.03, base)]), legs))
+ out.append((P([(lx + st * h * 0.18 - h * 0.045, base - h * 0.03), (lx + st * h * 0.18 + h * 0.06 * facing, base - h * 0.03),
+ (lx + st * h * 0.18 + h * 0.06 * facing, base), (lx + st * h * 0.18 - h * 0.045, base)]), '#2a2420'))
+ out.append((P([(x - h * 0.12, base - h * 0.82), (x + h * 0.12, base - h * 0.82), (x + h * 0.17, hip + h * 0.06), (x - h * 0.17, hip + h * 0.06)]), coat))
+ out.append((P(ellipse_pts(x, base - h * 0.89, hr * 0.95, hr * 1.05, 16)), 'skin'))
+ out.append((P(ellipse_pts(x - facing * hr * 0.25, base - h * 0.91, hr * 1.0, hr * 0.95, 16)), hair))
+ return out
+ if reflect:
+ for Pp, c in parts(-1):
+ self.fill(Pp, mix(mix(c, 'wet', 0.45), '#000000', 0.15), tex=0.6, dir=0, hand=0, alpha=0.55, r=r)
+ self.flush()
+ for Pp, c in parts(1):
+ self.fill(Pp, c, tex=0.4, dir=0, hand=0, r=r)
+ self.ink(Pp, lw * 0.6, closed=True, alpha=0.7, hand=0, r=r)
+ if bag:
+ B = rect(x + facing * h * 0.13, base - h * 0.6, x + facing * h * 0.24, base - h * 0.48)
+ self.fill(B, bag, tex=0.3, hand=0, r=r); self.ink(B, lw * 0.6, closed=True, r=r)
+ if balloon:
+ hx, hy = x + facing * h * 0.16, base - h * 0.58
+ bx, by = x + facing * h * 0.34, base - h * 1.55
+ self.ink(spline([(hx, hy), (hx + facing * h * 0.12, base - h * 1.0), (bx, by + h * 0.16)], 8), lw * 0.5, alpha=0.8, r=r)
+ Bl = ellipse_pts(bx, by, h * 0.13, h * 0.155, 24)
+ self.fill(Bl, balloon, tex=0.3, hand=0, r=r)
+ self.fill(ellipse_pts(bx - h * 0.045, by - h * 0.06, h * 0.035, h * 0.05, 10, -0.5), lighten(balloon, 0.55), tex=0.1, hand=0, r=r)
+ self.fill(np.array([(bx - h * 0.02, by + h * 0.15), (bx + h * 0.02, by + h * 0.15), (bx, by + h * 0.18)], np.float32), deepen(balloon, 0.2), hand=0, r=r)
+ self.ink(Bl, lw * 0.7, closed=True, r=r)
+ if basket:
+ bx0 = x + facing * h * 0.12
+ Bk = np.array([(bx0 - h * 0.07, base - h * 0.55), (bx0 + h * 0.15, base - h * 0.55), (bx0 + h * 0.12, base - h * 0.43), (bx0 - h * 0.04, base - h * 0.43)], np.float32)
+ if facing < 0: Bk[:, 0] = 2 * bx0 - Bk[:, 0]
+ for k in range(6):
+ self.dab(Bk[:, 0].mean() + r.normal(0, h * 0.04), base - h * 0.57 + r.normal(0, h * 0.015), h * 0.03, FLOWER_SETS[basket][k % 3], rr=r)
+ self.fill(Bk, 'ochre', tex=0.4, hand=0, r=r)
+ self.ink(Bk, lw * 0.6, closed=True, r=r)
+ if umbrella:
+ ux, uy = x + facing * h * 0.08, base - h * 1.08
+ U = np.vstack([ellipse_pts(ux, uy, h * 0.36, h * 0.2, 20, 0, np.pi, 2 * np.pi), [(ux + h * 0.36, uy)]])
+ self.ink([(ux, uy), (x + facing * h * 0.1, base - h * 0.62)], lw * 0.8, r=r)
+ self.fill(U, umbrella, tex=0.4, hand=0, r=r)
+ self.ink(U, lw * 0.8, closed=True, r=r)
+ for k in (-0.5, 0, 0.5):
+ self.ink([(ux, uy - h * 0.2), (ux + k * h * 0.36, uy)], lw * 0.5, alpha=0.6, r=r)
+ self.flush()
+
+ def bistro(self, x, base, s, top='ivory', iron='iron', chairs=2, cups=True, lw=None, seed=None):
+ """a little cafe table (round top on a pedestal) with iron chairs either side; s = table height"""
+ r = self._r(seed)
+ lw = self.lw if lw is None else lw
+ for k in range(chairs):
+ sd = -1 if k % 2 == 0 else 1
+ cx = x + sd * s * 0.62
+ seat = base - s * 0.48
+ self.ink([(cx - s * 0.18, seat), (cx + s * 0.18, seat)], lw * 1.4, colour=iron, r=r)
+ self.ink([(cx - sd * s * 0.16, seat), (cx - sd * s * 0.2, base)], lw, colour=iron, r=r)
+ self.ink([(cx + sd * s * 0.16, seat), (cx + sd * s * 0.22, base)], lw, colour=iron, r=r)
+ back = cx + sd * s * 0.16
+ self.ink([(back, seat), (back + sd * s * 0.04, seat - s * 0.5)], lw, colour=iron, r=r)
+ self.ink(ellipse_pts(back + sd * s * 0.02, seat - s * 0.42, s * 0.07, s * 0.1, 12), lw * 0.7, closed=True, colour=iron, r=r)
+ self.ink([(x, base - s * 0.9), (x, base)], lw * 1.6, colour=iron, r=r)
+ self.ink([(x - s * 0.2, base), (x + s * 0.2, base)], lw * 1.4, colour=iron, r=r)
+ T = ellipse_pts(x, base - s * 0.92, s * 0.36, s * 0.07, 20)
+ self.fill(T, top, tex=0.4, hand=0, r=r)
+ self.ink(T, lw * 0.8, closed=True, r=r)
+ if cups:
+ for dx in (-0.14, 0.12):
+ C = rect(x + dx * s - s * 0.05, base - s * 1.04, x + dx * s + s * 0.05, base - s * 0.95)
+ self.fill(C, ('tomato', 'cream', 'cerulean')[r.integers(0, 3)], tex=0.2, hand=0, r=r)
+ self.ink(C, lw * 0.5, closed=True, r=r)
+ self.flush()
+
+ def poster(self, x0, y0, x1, y1, colour='butter', seed=None, lw=None):
+ """a small painted notice or poster on a wall: a coloured sheet with a few blocks of 'type'"""
+ r = self._r(seed)
+ lw = self.lw if lw is None else lw
+ P = rect(x0, y0, x1, y1)
+ self.fill(P, colour, tex=0.5, dir=2, vary=0.04, r=r)
+ w, h = x1 - x0, y1 - y0
+ self.fill(rect(x0 + w * 0.15, y0 + h * 0.12, x1 - w * 0.15, y0 + h * 0.3), deepen(colour, 0.35), tex=0.2, hand=0.2, r=r)
+ if r.random() < 0.6:
+ self.fill(ellipse_pts((x0 + x1) / 2, y0 + h * 0.58, w * 0.22, w * 0.22, 14), ('tomato', 'teal', 'cobalt', 'mustard')[r.integers(0, 4)], tex=0.3, hand=0, r=r)
+ for k in range(3):
+ yy = y0 + h * (0.78 + 0.07 * k)
+ self.ink([(x0 + w * 0.18, yy), (x1 - w * (0.18 + 0.15 * (k == 2)), yy)], lw * 0.5, alpha=0.6, hand=0.2, r=r)
+ self.ink(P, lw * 0.8, closed=True, corners=True, r=r)
+ self.flush()
+
+ def cat(self, x, base, s, colour='#e9a65a', seed=None, lw=None):
+ """a small sitting cat seen from behind"""
+ r = self._r(seed)
+ lw = self.lw if lw is None else lw
+ B = ellipse_pts(x, base - s * 0.35, s * 0.32, s * 0.36, 20)
+ Hd = ellipse_pts(x, base - s * 0.8, s * 0.2, s * 0.18, 16)
+ E1 = np.array([(x - s * 0.18, base - s * 0.86), (x - s * 0.13, base - s * 1.02), (x - s * 0.04, base - s * 0.93)], np.float32)
+ E2 = E1 * (-1, 1) + (2 * x, 0)
+ Tl = spline([(x + s * 0.25, base - s * 0.08), (x + s * 0.5, base - s * 0.1), (x + s * 0.55, base - s * 0.35)], 8)
+ for Pp in (B, Hd, E1, E2):
+ self.fill(Pp, colour, tex=0.5, hand=0, r=r)
+ self.ink(Tl, lw * 2.2, colour=colour, alpha=1, hand=0, r=r)
+ for Pp in (B, Hd, E1, E2):
+ self.ink(Pp, lw * 0.7, closed=True, alpha=0.8, hand=0, r=r)
+ for k in range(3):
+ self.ink([(x - s * 0.1 + k * s * 0.1, base - s * 0.55), (x - s * 0.12 + k * s * 0.1, base - s * 0.4)], lw * 0.5, alpha=0.4, colour='#9a5a2a', hand=0, r=r)
+ self.flush()
+
+ # ================================================================== street and the wet reflection
+ def street(self, y0, vp, colour='cobble', dark='#a29f98', rows=None, seed=None, lw=None, x_range=None, poly=None):
+ """cobbled paving from y0 (far edge) to the bottom of the canvas, joints running toward the vanishing point"""
+ r = self._r(seed)
+ lw = self.lw if lw is None else lw
+ vx, vy = vp
+ H = self.H
+ P = poly if poly is not None else rect(-5, y0, self.W + 5, H + 5)
+ self.fill(P, dark, tex=0.5, dir=2, hand=0, r=r)
+ self.flush()
+ # rows: their height grows toward the viewer (perspective)
+ ys = [y0]
+ while ys[-1] < H:
+ ys.append(ys[-1] + max(4.0, (ys[-1] - vy) * 0.075))
+ col = hexc(colour)
+ for a, b in zip(ys[:-1], ys[1:]):
+ hrow = b - a
+ sw = hrow * 2.3
+ off = r.uniform(0, sw)
+ # stone widths in screen space follow the row; place stones from left to right
+ xs = np.arange(-sw + off, self.W + sw, sw)
+ for xx in xs:
+ ww = sw * r.uniform(0.82, 0.95)
+ c = col * (1 + 0.025 * r.normal()) + 0.006 * r.normal(0, 1, 3)
+ # slant the stone toward the vanishing point
+ k = (xx - vx) / max(1.0, (a - vy))
+ Q = np.array([(xx, a + hrow * 0.08), (xx + ww, a + hrow * 0.08), (xx + ww + k * hrow * 0.85, b - hrow * 0.08),
+ (xx + k * hrow * 0.85, b - hrow * 0.08)], np.float32)
+ cxq, cyq = Q.mean(0)
+ Q = (Q - (cxq, cyq)) * 0.94 + (cxq, cyq)
+ self.fill(Q, c, tex=0.6, dir=2, hand=0.25, r=r)
+ self.flush(clip=P)
+ self._street = (ys, P, vp)
+ return ys
+
+ def joints(self, alpha=0.3, seed=None, lw=None):
+ """re-ink the paving joints faintly over the wet reflection so the stones still read"""
+ r = self._r(seed)
+ lw = self.lw if lw is None else lw
+ ys, P, (vx, vy) = self._street
+ for a, b in zip(ys[:-1], ys[1:]):
+ self.ink([(-5, a), (self.W + 5, a)], lw * 0.6, alpha=alpha, colour='#4a5258', hand=0.6, split=1e9, r=r)
+ hrow = b - a; sw = hrow * 2.3
+ for xx in np.arange(-sw + r.uniform(0, sw), self.W + sw, sw * r.uniform(0.9, 1.1)):
+ k = (xx - vx) / max(1.0, (a - vy))
+ self.ink([(xx, a), (xx + k * hrow, b)], lw * 0.5, alpha=alpha * 0.8, colour='#4a5258', hand=0, r=r)
+ self.flush(clip=P)
+
+ def reflect(self, src, base, y0, y1=None, strength=0.62, smear=(2.0, 22.0), ripple=2.5, darken=0.86, tint='wet',
+ region=None, seed=None, fade=0.55):
+ """the wet street: mirror `src` (the canvas before the street was painted) about each column's base line
+ `base` (array over x, or a number), smeared vertically, rippled, darkened and mixed into the paving"""
+ r = self._r(seed)
+ y1 = self.H if y1 is None else y1
+ y0 = int(y0); y1 = int(y1)
+ W = self.W
+ base = np.broadcast_to(np.asarray(base, np.float32), (W,))
+ ys = np.arange(y0, y1, dtype=np.float32)[:, None]
+ xs = np.arange(W, dtype=np.float32)[None, :]
+ dist = np.maximum(ys - base[None, :], 0)
+ rip = (fbm1d(y1 - y0, 18, 3, int(r.integers(1 << 30)))[:, None] * ripple * (1 + dist / 260)).astype(np.float32)
+ colj = (fbm1d(W, 9, 2, int(r.integers(1 << 30))) * ripple * 0.8)[None, :]
+ sx = np.clip(xs + rip + colj * np.clip(dist / 80, 0, 1) + 0.35 * self.TH[y0:y1] * ripple, 0, W - 1)
+ sy = np.clip(base[None, :] - dist * 1.0, 0, self.H - 1)
+ ix = sx.astype(np.int32); iy = sy.astype(np.int32)
+ R = src[iy, ix]
+ # vertical smear grows with distance from the base line (two blurs, blended)
+ s0, s1 = smear
+ Rb1 = np.stack([_box(_box(R[..., c], int(s0), 0), 1, 1) for c in range(3)], -1)
+ Rb2 = np.stack([_box(_box(_box(R[..., c], int(s1), 0), int(s1 * 0.6), 0), 3, 1) for c in range(3)], -1)
+ t = np.clip(dist / 260, 0, 1)[..., None]
+ R = Rb1 * (1 - t) + Rb2 * t
+ R = R * darken + hexc(tint) * (1 - darken)
+ k = strength * (1 - fade * np.clip(dist / max(1, (y1 - y0)), 0, 1))
+ k = k * (1 + 0.2 * self.TV[y0:y1]) * (dist > 0)
+ if region is not None: k = k * region[y0:y1]
+ k = np.clip(k, 0, 1)[..., None]
+ C = self.C[y0:y1]
+ R = R * (1 + 0.05 * self.TV[y0:y1, :, None])
+ self.C[y0:y1] = C * (1 - k) + R * k
+
+ @contextmanager
+ def mirror(self, base, x0, x1, top, strength=0.45, smear=10.0, darken=0.85, tint='wet'):
+ """everything painted inside the block is also reflected in the wet ground below `base`"""
+ x0, x1, top = max(0, int(x0)), min(self.W, int(x1)), max(0, int(top))
+ y_end = min(self.H, int(2 * base - top) + 2)
+ before = self.C[top:y_end, x0:x1].copy()
+ try: yield
+ finally:
+ self.flush()
+ after = self.C[top:y_end, x0:x1]
+ m = (np.abs(after - before).max(-1) > 1e-3).astype(np.float32)
+ b = int(round(base)) - top
+ n = min(b, after.shape[0] - b)
+ if n > 2:
+ src = after[b - n:b][::-1]; ms = m[b - n:b][::-1]
+ sm = int(smear)
+ src = np.stack([_box(src[..., c] * ms, sm, 0) for c in range(3)], -1)
+ ms_b = _box(ms, sm, 0)
+ col = src / np.maximum(ms_b, 1e-4)[..., None]
+ col = col * darken + hexc(tint) * (1 - darken)
+ fade = np.linspace(1, 0.2, n, dtype=np.float32)[:, None]
+ a = np.clip(ms_b * strength * fade * (1 - m[b:b + n]), 0, 1)[..., None]
+ after[b:b + n] = after[b:b + n] * (1 - a) + col * a
+
+ def glints(self, y0, y1, n=60, colour='#f4f4ee', seed=None, region=None):
+ """small horizontal light glints on the wet paving"""
+ r = self._r(seed)
+ for _ in range(n):
+ y = r.uniform(y0, y1); x = r.uniform(0, self.W)
+ if region is not None and region[int(min(self.H - 1, y)), int(min(self.W - 1, x))] < 0.5: continue
+ L = r.uniform(6, 26) * (0.5 + (y - y0) / max(1, y1 - y0))
+ self.ink([(x, y), (x + L, y + r.normal(0, 0.4))], r.uniform(0.8, 1.8), colour=colour, alpha=0.5, hand=0.2, r=r)
+ self.flush()
+
+ # ================================================================== finish and output
+ def finish(self, soft=0.25, grain=1.0, warmth=0.5, vignette=0.35):
+ """record the finishing (applied in render, so every stage snapshot matches the final look)"""
+ self.fin = dict(soft=soft, grain=grain, warmth=warmth, vignette=vignette)
+ return self
+
+ def render(self):
+ out = self.C
+ f = self.fin
+ if f:
+ if f['soft']:
+ b = np.stack([blur(out[..., c], 0.6) for c in range(3)], -1)
+ out = out * (1 - f['soft']) + b * f['soft']
+ if f['warmth']:
+ lum = out.mean(-1, keepdims=True)
+ out = out * (1 - 0.04 * f['warmth']) + out * hexc('#fff3e0') * 0.04 * f['warmth'] + 0.004 * f['warmth']
+ out = lum + (out - lum) * (1 + 0.04 * f['warmth'])
+ if f['vignette']:
+ yy = (np.arange(self.H, dtype=np.float32)[:, None] / self.H - 0.5) * 2
+ xx = (np.arange(self.W, dtype=np.float32)[None, :] / self.W - 0.5) * 2
+ v = 1 - f['vignette'] * 0.08 * np.clip(xx * xx + yy * yy - 0.5, 0, None)
+ out = out * v[..., None]
+ if f['grain']:
+ if not hasattr(self, '_grain'):
+ r = np.random.default_rng(self.seed + 99)
+ g = r.normal(0, 1, (self.H, self.W)).astype(np.float32)
+ self._grain = 0.6 * g + 0.6 * blur(g, 0.9) * 2
+ out = out * (1 + 0.016 * f['grain'] * self._grain[..., None])
+ return np.clip(out, 0, 1)
+
+ def composite(self):
+ return Image.fromarray((self.render() * 255 + 0.5).astype(np.uint8))
+
+ def stage(self, name):
+ if not self.keep_stages: return
+ self.flush()
+ 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):
+ self.flush()
+ 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