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 pen & wash style (64 total): fineliner and loose watercolour on sketch cards

cloveric4613c7cab748
diff --git a/README.md b/README.md
index e68de5a..f3dfc64 100644
--- a/README.md
+++ b/README.md
@@ -1,55 +1,55 @@
# Claude Drawing · Claude 绘图
-**Claude paints with code — no image model.** Sixty-three 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 and a lamp-lit shadow-puppet play.
-**不用生图模型,Claude 用代码一笔一笔作画。** 六十三种画风,从水墨、油画到黏土、蓝晒、彩色玻璃花窗、罗马马赛克、代尔夫特蓝瓷砖、赛博朋克、光线追踪的小球海、低多边形 3D、热成像、X 光片、VHS 录像带、Synthwave 落日、产品发布片式的粉彩界面、红笔批改的答题卡和油灯下的皮影戏。
+**Claude paints with code — no image model.** Sixty-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 and pen-and-wash sketch cards.
+**不用生图模型,Claude 用代码一笔一笔作画。** 六十四种画风,从水墨、油画到黏土、蓝晒、彩色玻璃花窗、罗马马赛克、代尔夫特蓝瓷砖、赛博朋克、光线追踪的小球海、低多边形 3D、热成像、X 光片、VHS 录像带、Synthwave 落日、产品发布片式的粉彩界面、红笔批改的答题卡、油灯下的皮影戏和钢笔淡彩的速写小卡。
[English](#english) · [中文](#中文)
<p align="center"><img src="examples/drawing_bawansiqian.gif" width="100%"><br><sub><b>Ink wash · 水墨</b> — every style below is drawn stage by stage like this (the storybook one is a real character animation) · 下面每种画风都是这样一步步画出来的(绘本角色动画是一段真正的角色动画)</sub></p>
-| Watercolour · 水彩 | Watercolour washes · 水彩底纹 | Paper collage · 剪纸拼贴 |
+| Watercolour · 水彩 | Paper collage · 剪纸拼贴 | Coloured pencil · 韩国彩铅 |
|---|---|---|
-| ![watercolour](examples/drawing_watercolor_autumn.gif) | ![washes](examples/drawing_watercolor_washes.gif) | ![collage](examples/drawing_papercut_balloons.gif) |
-| **Coloured pencil · 韩国彩铅** | **Anime · 日本动漫** | **Editorial · 编辑风手绘** |
-| ![pencil](examples/drawing_colorpencil_dessert.gif) | ![anime](examples/drawing_anime_summer.gif) | ![editorial](examples/drawing_editorial_ideas.gif) |
-| **Impasto oil · 油画厚涂** | **Ukiyo-e · 浮世绘木版画** | **Pixel art · 像素风** |
-| ![oil](examples/drawing_oil_wheatfield.gif) | ![ukiyoe](examples/drawing_ukiyoe_fuji.gif) | ![pixel](examples/drawing_pixel_rainy_cafe.gif) |
-| **Stop-motion clay · 黏土定格** | **Cyanotype · 蓝晒** | **Cross-stitch · 十字绣** |
-| ![clay](examples/drawing_clay_lighthouse.gif) | ![cyanotype](examples/drawing_cyanotype_botanicals.gif) | ![stitch](examples/drawing_stitch_sampler.gif) |
-| **Retro panel · 复古仪器面板** | **Sticker collage × receipt · 贴纸拼贴 · 小票** | **Lab notebook × stickers · 实验笔记本 · 贴纸** |
-| ![panel](examples/drawing_panel_radio.gif) | ![sticker](examples/drawing_sticker_market.gif) | ![notebook](examples/drawing_notebook_brewing.gif) |
-| **Chalkboard · 黑板板书** | **Cyberpunk · 赛博朋克** | **Hand-drawn cartoon · 卡通手绘** |
-| ![chalk](examples/drawing_chalk_lesson.gif) | ![cyberpunk](examples/drawing_cyberpunk_neon_street.gif) | ![cartoon](examples/drawing_cartoon_toaster.gif) |
-| **Continuous line art · 单线画** | **Soft 3D · 柔光 3D** | **Shape morph · 形变动画** |
-| ![lineart](examples/drawing_lineart_paper_plane.gif) | ![soft3d](examples/drawing_soft3d_rise.gif) | ![morph](examples/drawing_morph_water_cycle.gif) |
-| **Newspaper collage · 报刊拼贴** | **Aurora glass · 弥散玻璃** | **Bauhaus geometric · 包豪斯几何** |
-| ![newscollage](examples/drawing_newscollage_curiosity.gif) | ![aurora](examples/drawing_aurora_morning.gif) | ![bauhaus](examples/drawing_bauhaus_form_colour.gif) |
-| **Retro synthwave · 复古 Synthwave** | **Isometric 2.5D · 等轴 2.5D** | **Perler beads · 拼豆** |
-| ![synthwave](examples/drawing_synthwave_coastline.gif) | ![isometric](examples/drawing_isometric_weather_island.gif) | ![perler](examples/drawing_perler_strawberry_coaster.gif) |
-| **Petroglyph · 岩画** | **Egyptian tomb painting · 古埃及墓室壁画** | **Roman mosaic · 罗马马赛克** |
-| ![petroglyph](examples/drawing_petroglyph_migration.gif) | ![tomb](examples/drawing_tomb_harvest.gif) | ![mosaic](examples/drawing_mosaic_harbor.gif) |
-| **Stained glass · 彩色玻璃花窗** | **Illuminated manuscript · 泥金手抄本** | **Leonardo codex · 达·芬奇手稿** |
-| ![stainedglass](examples/drawing_stainedglass_seasons.gif) | ![illuminated](examples/drawing_illuminated_starchart.gif) | ![codex](examples/drawing_codex_ornithopter.gif) |
-| **Silhouette · 剪影** | **Letterpress poster · 凸版印刷海报** | **Soviet constructivism · 苏联构成主义** |
-| ![silhouette](examples/drawing_silhouette_family.gif) | ![letterpress](examples/drawing_letterpress_circus.gif) | ![constructivism](examples/drawing_constructivism_radio.gif) |
-| **Art Deco · 装饰艺术** | **Golden-age comic · 黄金时代漫画** | **Pop silkscreen · 波普丝网** |
-| ![artdeco](examples/drawing_artdeco_express.gif) | ![comic](examples/drawing_comic_rocket.gif) | ![popart](examples/drawing_popart_cat_moods.gif) |
-| **ASCII art (line printer) · ASCII 字符画** | **Low poly · 低多边形** | **Stencil graffiti · 喷漆模板涂鸦** |
-| ![lineprinter](examples/drawing_lineprinter_launch.gif) | ![lowpoly](examples/drawing_lowpoly_canyon.gif) | ![stencil](examples/drawing_stencil_kite.gif) |
-| **Embroidered patches · 刺绣徽章** | **Blueprint · 蓝图工程图** | **Children's crayon · 儿童蜡笔画** |
-| ![patch](examples/drawing_patch_camping.gif) | ![blueprint](examples/drawing_blueprint_lighthouse.gif) | ![crayon](examples/drawing_crayon_picnic.gif) |
-| **Green-screen CRT · 绿屏终端** | **Thermal camera · 热成像** | **Delft tiles · 代尔夫特蓝瓷砖** |
-| ![crt](examples/drawing_crt_weather.gif) | ![thermal](examples/drawing_thermal_kitchen.gif) | ![delft](examples/drawing_delft_canal.gif) |
-| **Cave painting · 洞穴壁画** | **1-bit paint program · 1-bit 早期画图软件** | **Greek black-figure vase · 古希腊黑绘陶瓶** |
-| ![cave](examples/drawing_cave_hunt.gif) | ![macpaint](examples/drawing_macpaint_garden.gif) | ![blackfigure](examples/drawing_blackfigure_games.gif) |
-| **Graphite pencil · 铅笔素描** | **X-ray · X 光片** | **1930s rubber hose · 1930 年代黑白橡皮管动画** |
-| ![graphite](examples/drawing_graphite_bicycle.gif) | ![xray](examples/drawing_xray_luggage.gif) | ![rubberhose](examples/drawing_rubberhose_morning.gif) |
-| **Linocut · 黑白麻胶版画** | **VHS home video · VHS 家庭录像** | **Flat vector · 扁平矢量** |
-| ![linocut](examples/drawing_linocut_snowy_village.gif) | ![vhs](examples/drawing_vhs_birthday.gif) | ![flatvector](examples/drawing_flatvector_night_camp.gif) |
-| **Storybook animation · 绘本角色动画** | **Ballpoint doodle · 圆珠笔涂鸦** | **Overlay sheets · 描图纸叠层** |
-| ![storybook](examples/drawing_storybook_acorn.gif) | ![ballpoint](examples/drawing_ballpoint_board_game.gif) | ![overlay](examples/drawing_overlay_city_map.gif) |
-| **Pastel UI · 粉彩界面** | **Exam grading · 阅卷批改** | **Shadow puppetry · 皮影戏** |
-| ![pastelui](examples/drawing_pastelui_packing.gif) | ![grading](examples/drawing_grading_math_quiz.gif) | ![shadowpuppet](examples/drawing_shadowpuppet_cuju.gif) |
+| ![watercolour](examples/drawing_watercolor_autumn.gif) | ![collage](examples/drawing_papercut_balloons.gif) | ![pencil](examples/drawing_colorpencil_dessert.gif) |
+| **Anime · 日本动漫** | **Editorial · 编辑风手绘** | **Impasto oil · 油画厚涂** |
+| ![anime](examples/drawing_anime_summer.gif) | ![editorial](examples/drawing_editorial_ideas.gif) | ![oil](examples/drawing_oil_wheatfield.gif) |
+| **Ukiyo-e · 浮世绘木版画** | **Pixel art · 像素风** | **Stop-motion clay · 黏土定格** |
+| ![ukiyoe](examples/drawing_ukiyoe_fuji.gif) | ![pixel](examples/drawing_pixel_rainy_cafe.gif) | ![clay](examples/drawing_clay_lighthouse.gif) |
+| **Cyanotype · 蓝晒** | **Cross-stitch · 十字绣** | **Retro panel · 复古仪器面板** |
+| ![cyanotype](examples/drawing_cyanotype_botanicals.gif) | ![stitch](examples/drawing_stitch_sampler.gif) | ![panel](examples/drawing_panel_radio.gif) |
+| **Sticker collage × receipt · 贴纸拼贴 · 小票** | **Lab notebook × stickers · 实验笔记本 · 贴纸** | **Chalkboard · 黑板板书** |
+| ![sticker](examples/drawing_sticker_market.gif) | ![notebook](examples/drawing_notebook_brewing.gif) | ![chalk](examples/drawing_chalk_lesson.gif) |
+| **Cyberpunk · 赛博朋克** | **Hand-drawn cartoon · 卡通手绘** | **Continuous line art · 单线画** |
+| ![cyberpunk](examples/drawing_cyberpunk_neon_street.gif) | ![cartoon](examples/drawing_cartoon_toaster.gif) | ![lineart](examples/drawing_lineart_paper_plane.gif) |
+| **Soft 3D · 柔光 3D** | **Shape morph · 形变动画** | **Newspaper collage · 报刊拼贴** |
+| ![soft3d](examples/drawing_soft3d_rise.gif) | ![morph](examples/drawing_morph_water_cycle.gif) | ![newscollage](examples/drawing_newscollage_curiosity.gif) |
+| **Aurora glass · 弥散玻璃** | **Bauhaus geometric · 包豪斯几何** | **Retro synthwave · 复古 Synthwave** |
+| ![aurora](examples/drawing_aurora_morning.gif) | ![bauhaus](examples/drawing_bauhaus_form_colour.gif) | ![synthwave](examples/drawing_synthwave_coastline.gif) |
+| **Isometric 2.5D · 等轴 2.5D** | **Perler beads · 拼豆** | **Petroglyph · 岩画** |
+| ![isometric](examples/drawing_isometric_weather_island.gif) | ![perler](examples/drawing_perler_strawberry_coaster.gif) | ![petroglyph](examples/drawing_petroglyph_migration.gif) |
+| **Egyptian tomb painting · 古埃及墓室壁画** | **Roman mosaic · 罗马马赛克** | **Stained glass · 彩色玻璃花窗** |
+| ![tomb](examples/drawing_tomb_harvest.gif) | ![mosaic](examples/drawing_mosaic_harbor.gif) | ![stainedglass](examples/drawing_stainedglass_seasons.gif) |
+| **Illuminated manuscript · 泥金手抄本** | **Leonardo codex · 达·芬奇手稿** | **Silhouette · 剪影** |
+| ![illuminated](examples/drawing_illuminated_starchart.gif) | ![codex](examples/drawing_codex_ornithopter.gif) | ![silhouette](examples/drawing_silhouette_family.gif) |
+| **Letterpress poster · 凸版印刷海报** | **Soviet constructivism · 苏联构成主义** | **Art Deco · 装饰艺术** |
+| ![letterpress](examples/drawing_letterpress_circus.gif) | ![constructivism](examples/drawing_constructivism_radio.gif) | ![artdeco](examples/drawing_artdeco_express.gif) |
+| **Golden-age comic · 黄金时代漫画** | **Pop silkscreen · 波普丝网** | **ASCII art (line printer) · ASCII 字符画** |
+| ![comic](examples/drawing_comic_rocket.gif) | ![popart](examples/drawing_popart_cat_moods.gif) | ![lineprinter](examples/drawing_lineprinter_launch.gif) |
+| **Low poly · 低多边形** | **Stencil graffiti · 喷漆模板涂鸦** | **Embroidered patches · 刺绣徽章** |
+| ![lowpoly](examples/drawing_lowpoly_canyon.gif) | ![stencil](examples/drawing_stencil_kite.gif) | ![patch](examples/drawing_patch_camping.gif) |
+| **Blueprint · 蓝图工程图** | **Children's crayon · 儿童蜡笔画** | **Green-screen CRT · 绿屏终端** |
+| ![blueprint](examples/drawing_blueprint_lighthouse.gif) | ![crayon](examples/drawing_crayon_picnic.gif) | ![crt](examples/drawing_crt_weather.gif) |
+| **Thermal camera · 热成像** | **Delft tiles · 代尔夫特蓝瓷砖** | **Cave painting · 洞穴壁画** |
+| ![thermal](examples/drawing_thermal_kitchen.gif) | ![delft](examples/drawing_delft_canal.gif) | ![cave](examples/drawing_cave_hunt.gif) |
+| **1-bit paint program · 1-bit 早期画图软件** | **Greek black-figure vase · 古希腊黑绘陶瓶** | **Graphite pencil · 铅笔素描** |
+| ![macpaint](examples/drawing_macpaint_garden.gif) | ![blackfigure](examples/drawing_blackfigure_games.gif) | ![graphite](examples/drawing_graphite_bicycle.gif) |
+| **X-ray · X 光片** | **1930s rubber hose · 1930 年代黑白橡皮管动画** | **Linocut · 黑白麻胶版画** |
+| ![xray](examples/drawing_xray_luggage.gif) | ![rubberhose](examples/drawing_rubberhose_morning.gif) | ![linocut](examples/drawing_linocut_snowy_village.gif) |
+| **VHS home video · VHS 家庭录像** | **Flat vector · 扁平矢量** | **Storybook animation · 绘本角色动画** |
+| ![vhs](examples/drawing_vhs_birthday.gif) | ![flatvector](examples/drawing_flatvector_night_camp.gif) | ![storybook](examples/drawing_storybook_acorn.gif) |
+| **Ballpoint doodle · 圆珠笔涂鸦** | **Overlay sheets · 描图纸叠层** | **Pastel UI · 粉彩界面** |
+| ![ballpoint](examples/drawing_ballpoint_board_game.gif) | ![overlay](examples/drawing_overlay_city_map.gif) | ![pastelui](examples/drawing_pastelui_packing.gif) |
+| **Exam grading · 阅卷批改** | **Shadow puppetry · 皮影戏** | **Pen & wash · 钢笔淡彩** |
+| ![grading](examples/drawing_grading_math_quiz.gif) | ![shadowpuppet](examples/drawing_shadowpuppet_cuju.gif) | ![penwash](examples/drawing_penwash_neighbours.gif) |
### Gallery · 画廊
@@ -57,68 +57,70 @@
|---|---|
| **八万四千法门** · *Many Paths, One Summit*<br><sub>Ink wash · 水墨</sub> | **月印万川** · *One Moon in Ten Thousand Rivers*<br><sub>Ink wash · 水墨</sub> |
| <img src="examples/bawansiqian.jpg" width="100%"> | <img src="examples/moon_river.jpg" width="100%"> |
-| **秋日湖畔** · *Autumn Lake*<br><sub>Watercolour · 水彩</sub> | **热气球小镇** · *Balloon Day*<br><sub>Paper collage · 剪纸拼贴</sub> |
-| <img src="examples/watercolor_autumn.jpg" width="100%"> | <img src="examples/papercut_balloons.jpg" width="100%"> |
-| **午后甜点** · *Afternoon Dessert*<br><sub>Coloured pencil · 韩国彩铅</sub> | **夏空** · *Summer Sky*<br><sub>Anime · 日本动漫</sub> |
-| <img src="examples/colorpencil_dessert.jpg" width="100%"> | <img src="examples/anime_summer.jpg" width="100%"> |
-| **灵感生长** · *Growing Ideas*<br><sub>Editorial · 编辑风手绘</sub> | **麦田星空** · *Swirling Sky over the Wheat Field*<br><sub>Impasto oil · 油画厚涂</sub> |
-| <img src="examples/editorial_ideas.jpg" width="100%"> | <img src="examples/oil_wheatfield.jpg" width="100%"> |
-| **富士曙** · *Fuji at Dawn*<br><sub>Ukiyo-e · 浮世绘</sub> | **雨夜咖啡店** · *Rainy Night Cafe*<br><sub>Pixel art · 像素风</sub> |
-| <img src="examples/ukiyoe_fuji.jpg" width="100%"> | <img src="examples/pixel_rainy_cafe.png" width="100%"> |
-| **灯塔岛** · *Lighthouse Island*<br><sub>Stop-motion clay · 黏土定格</sub> | **蓝晒植物** · *Sun-Print Botanicals*<br><sub>Cyanotype · 蓝晒</sub> |
-| <img src="examples/clay_lighthouse.jpg" width="100%"> | <img src="examples/cyanotype_botanicals.jpg" width="100%"> |
-| **家** · *Home Sampler*<br><sub>Cross-stitch · 十字绣</sub> | **Aurora 64 收音机** · *Aurora 64 Radio*<br><sub>Vintage instrument panel · 复古仪器面板</sub> |
-| <img src="examples/stitch_sampler.jpg" width="100%"> | <img src="examples/panel_radio.jpg" width="100%"> |
-| **周末市集** · *Weekend Market*<br><sub>Sticker collage × receipt · 贴纸拼贴 · 小票</sub> | **咖啡萃取实验** · *Coffee Brewing Experiment*<br><sub>Lab notebook × stickers · 实验笔记本 · 贴纸</sub> |
-| <img src="examples/sticker_market.jpg" width="100%"> | <img src="examples/notebook_brewing.jpg" width="100%"> |
-| **为什么天空是蓝的** · *Why Is the Sky Blue?*<br><sub>Chalkboard · 黑板板书</sub> | **霓虹不夜城** · *Neon District*<br><sub>Cyberpunk · 赛博朋克</sub> |
-| <img src="examples/chalk_lesson.jpg" width="100%"> | <img src="examples/cyberpunk_neon_street.jpg" width="100%"> |
-| **早安吐司** · *Good Morning, Toast*<br><sub>Hand-drawn cartoon · 卡通手绘</sub> | **岛上的气象站** · *Island Weather Station*<br><sub>Isometric 2.5D · 等轴 2.5D</sub> |
-| <img src="examples/cartoon_toaster.jpg" width="100%"> | <img src="examples/isometric_weather_island.jpg" width="100%"> |
-| **从这扇窗到那扇窗** · *From Window to Window*<br><sub>Continuous line art · 单线画</sub> | **浮出** · *Rise*<br><sub>Soft 3D · 柔光 3D</sub> |
-| <img src="examples/lineart_paper_plane.jpg" width="100%"> | <img src="examples/soft3d_rise.jpg" width="100%"> |
-| **一滴水的旅程** · *A Drop's Round Trip*<br><sub>Shape morph · 形变动画</sub> | **好奇心周刊 · 拆开看看** · *Curiosity Weekly · Take It Apart*<br><sub>Newspaper collage · 报刊拼贴</sub> |
-| <img src="examples/morph_water_cycle.jpg" width="100%"> | <img src="examples/newscollage_curiosity.jpg" width="100%"> |
-| **晨间计划** · *Morning Plan*<br><sub>Aurora glassmorphism · 弥散玻璃</sub> | **形与色** · *Form & Colour*<br><sub>Bauhaus geometric · 包豪斯几何</sub> |
-| <img src="examples/aurora_morning.jpg" width="100%"> | <img src="examples/bauhaus_form_colour.jpg" width="100%"> |
-| **海岸线 1987** · *Coastline 1987*<br><sub>Retro synthwave · 复古 Synthwave</sub> | **草莓杯垫** · *Strawberry Coaster*<br><sub>Perler beads · 拼豆</sub> |
-| <img src="examples/synthwave_coastline.jpg" width="100%"> | <img src="examples/perler_strawberry_coaster.jpg" width="100%"> |
-| **迁徙季** · *Migration Season*<br><sub>Petroglyph · 岩画</sub> | **尼罗河丰收** · *Harvest on the Nile*<br><sub>Egyptian tomb painting · 古埃及墓室壁画</sub> |
-| <img src="examples/petroglyph_migration.jpg" width="100%"> | <img src="examples/tomb_harvest.jpg" width="100%"> |
-| **港口渔获** · *The Day's Catch*<br><sub>Roman mosaic · 罗马马赛克</sub> | **四季之窗** · *Window of the Seasons*<br><sub>Stained glass · 彩色玻璃花窗</sub> |
-| <img src="examples/mosaic_harbor.jpg" width="100%"> | <img src="examples/stainedglass_seasons.jpg" width="100%"> |
-| **星辰之书** · *Liber Stellarum*<br><sub>Illuminated manuscript · 泥金手抄本</sub> | **扑翼机** · *The Ornithopter*<br><sub>Leonardo codex · 达·芬奇手稿</sub> |
-| <img src="examples/illuminated_starchart.jpg" width="100%"> | <img src="examples/codex_ornithopter.jpg" width="100%"> |
-| **剪影小像** · *Shades of the Wren Household*<br><sub>Silhouette · 剪影</sub> | **马戏团来了** · *The Circus Is Coming*<br><sub>Letterpress poster · 凸版印刷海报</sub> |
-| <img src="examples/silhouette_family.jpg" width="100%"> | <img src="examples/letterpress_circus.jpg" width="100%"> |
-| **无线电** · *Radio*<br><sub>Soviet constructivism · 苏联构成主义</sub> | **夜行快车** · *Night Express*<br><sub>Art Deco · 装饰艺术</sub> |
-| <img src="examples/constructivism_radio.jpg" width="100%"> | <img src="examples/artdeco_express.jpg" width="100%"> |
-| **火箭小队** · *Rocket Squad*<br><sub>Golden-age comic · 黄金时代漫画</sub> | **猫的六种心情** · *Six Moods of a Cat*<br><sub>Pop silkscreen · 波普丝网</sub> |
-| <img src="examples/comic_rocket.jpg" width="100%"> | <img src="examples/popart_cat_moods.jpg" width="100%"> |
-| **发射记录** · *Liftoff Trace*<br><sub>ASCII art (line printer) · ASCII 字符画(行式打印机)</sub> | **峡谷飞行** · *Canyon Run*<br><sub>Low poly · 低多边形</sub> |
-| <img src="examples/lineprinter_launch.jpg" width="100%"> | <img src="examples/lowpoly_canyon.jpg" width="100%"> |
-| **放风筝** · *Hold On*<br><sub>Stencil graffiti · 喷漆模板涂鸦</sub> | **三晚露营** · *Three Nights Out*<br><sub>Embroidered patches · 刺绣徽章</sub> |
-| <img src="examples/stencil_kite.jpg" width="100%"> | <img src="examples/patch_camping.jpg" width="100%"> |
-| **灯塔剖面** · *Halvard Rock Light*<br><sub>Blueprint · 蓝图工程图</sub> | **我的周末** · *My Weekend*<br><sub>Children's crayon · 儿童蜡笔画</sub> |
-| <img src="examples/blueprint_lighthouse.jpg" width="100%"> | <img src="examples/crayon_picnic.jpg" width="100%"> |
-| **今天带伞吗** · *Bring an Umbrella?*<br><sub>Green-screen CRT terminal · 绿屏终端(荧光字符画)</sub> | **厨房里的温度** · *Kitchen Heat Map*<br><sub>Thermal camera · 热成像</sub> |
-| <img src="examples/crt_weather.jpg" width="100%"> | <img src="examples/thermal_kitchen.jpg" width="100%"> |
-| **一阵风** · *The Gust*<br><sub>Delft tiles · 代尔夫特蓝瓷砖</sub> | **篝火旁的岩洞** · *The Hunt by the Fire*<br><sub>Cave painting · 洞穴壁画</sub> |
-| <img src="examples/delft_canal.jpg" width="100%"> | <img src="examples/cave_hunt.jpg" width="100%"> |
-| **窗台花园** · *Windowsill Garden*<br><sub>1-bit paint program · 1-bit 早期画图软件</sub> | **赛跑与赛车** · *Games on a Vase*<br><sub>Greek black-figure vase · 古希腊黑绘陶瓶</sub> |
-| <img src="examples/macpaint_garden.jpg" width="100%"> | <img src="examples/blackfigure_games.jpg" width="100%"> |
-| **老街角的自行车** · *The Bread Run*<br><sub>Graphite pencil · 铅笔素描</sub> | **行李安检** · *Security Check*<br><sub>X-ray · X 光片</sub> |
-| <img src="examples/graphite_bicycle.jpg" width="100%"> | <img src="examples/xray_luggage.jpg" width="100%"> |
-| **早晨的闹钟** · *Seven O'Clock*<br><sub>1930s rubber hose · 1930 年代黑白橡皮管动画</sub> | **雪夜归途** · *Homeward, First Snow*<br><sub>Linocut · 黑白麻胶版画</sub> |
-| <img src="examples/rubberhose_morning.jpg" width="100%"> | <img src="examples/linocut_snowy_village.jpg" width="100%"> |
-| **吹蜡烛** · *Blow Out the Candles*<br><sub>VHS home video · VHS 家庭录像</sub> | **山间夜营** · *Night Camp*<br><sub>Flat vector · 扁平矢量</sub> |
-| <img src="examples/vhs_birthday.jpg" width="100%"> | <img src="examples/flatvector_night_camp.jpg" width="100%"> |
-| **小橡果的秋天** · *An Acorn's Autumn*<br><sub>Storybook animation · 绘本角色动画</sub> | **蛇梯棋大冒险** · *Snakes & Ladders, Round 7*<br><sub>Ballpoint doodle · 圆珠笔涂鸦</sub> |
-| <img src="examples/storybook_acorn.jpg" width="100%"> | <img src="examples/ballpoint_board_game.jpg" width="100%"> |
-| **海港步行图** · *Larkhaven on Foot*<br><sub>Overlay sheets · 描图纸叠层</sub> | **出发前,再查一遍行李** · *Pack Check*<br><sub>Pastel UI · 粉彩界面</sub> |
-| <img src="examples/overlay_city_map.jpg" width="100%"> | <img src="examples/pastelui_packing.jpg" width="100%"> |
-| **数学单元测验** · *Unit Test, Graded*<br><sub>Exam grading · 阅卷批改</sub> | **蹴鞠** · *Cuju by Lamplight*<br><sub>Shadow puppetry · 皮影戏</sub> |
-| <img src="examples/grading_math_quiz.jpg" width="100%"> | <img src="examples/shadowpuppet_cuju.jpg" width="100%"> |
+| **秋日湖畔** · *Autumn Lake*<br><sub>Watercolour · 水彩</sub> | **水彩底纹** · *Watercolour Washes*<br><sub>Watercolour · 水彩 — a background for explainer videos · 讲解视频的背景</sub> |
+| <img src="examples/watercolor_autumn.jpg" width="100%"> | <img src="examples/watercolor_washes.jpg" width="100%"> |
+| **热气球小镇** · *Balloon Day*<br><sub>Paper collage · 剪纸拼贴</sub> | **午后甜点** · *Afternoon Dessert*<br><sub>Coloured pencil · 韩国彩铅</sub> |
+| <img src="examples/papercut_balloons.jpg" width="100%"> | <img src="examples/colorpencil_dessert.jpg" width="100%"> |
+| **夏空** · *Summer Sky*<br><sub>Anime · 日本动漫</sub> | **灵感生长** · *Growing Ideas*<br><sub>Editorial · 编辑风手绘</sub> |
+| <img src="examples/anime_summer.jpg" width="100%"> | <img src="examples/editorial_ideas.jpg" width="100%"> |
+| **麦田星空** · *Swirling Sky over the Wheat Field*<br><sub>Impasto oil · 油画厚涂</sub> | **富士曙** · *Fuji at Dawn*<br><sub>Ukiyo-e · 浮世绘</sub> |
+| <img src="examples/oil_wheatfield.jpg" width="100%"> | <img src="examples/ukiyoe_fuji.jpg" width="100%"> |
+| **雨夜咖啡店** · *Rainy Night Cafe*<br><sub>Pixel art · 像素风</sub> | **灯塔岛** · *Lighthouse Island*<br><sub>Stop-motion clay · 黏土定格</sub> |
+| <img src="examples/pixel_rainy_cafe.png" width="100%"> | <img src="examples/clay_lighthouse.jpg" width="100%"> |
+| **蓝晒植物** · *Sun-Print Botanicals*<br><sub>Cyanotype · 蓝晒</sub> | **家** · *Home Sampler*<br><sub>Cross-stitch · 十字绣</sub> |
+| <img src="examples/cyanotype_botanicals.jpg" width="100%"> | <img src="examples/stitch_sampler.jpg" width="100%"> |
+| **Aurora 64 收音机** · *Aurora 64 Radio*<br><sub>Vintage instrument panel · 复古仪器面板</sub> | **周末市集** · *Weekend Market*<br><sub>Sticker collage × receipt · 贴纸拼贴 · 小票</sub> |
+| <img src="examples/panel_radio.jpg" width="100%"> | <img src="examples/sticker_market.jpg" width="100%"> |
+| **咖啡萃取实验** · *Coffee Brewing Experiment*<br><sub>Lab notebook × stickers · 实验笔记本 · 贴纸</sub> | **为什么天空是蓝的** · *Why Is the Sky Blue?*<br><sub>Chalkboard · 黑板板书</sub> |
+| <img src="examples/notebook_brewing.jpg" width="100%"> | <img src="examples/chalk_lesson.jpg" width="100%"> |
+| **霓虹不夜城** · *Neon District*<br><sub>Cyberpunk · 赛博朋克</sub> | **早安吐司** · *Good Morning, Toast*<br><sub>Hand-drawn cartoon · 卡通手绘</sub> |
+| <img src="examples/cyberpunk_neon_street.jpg" width="100%"> | <img src="examples/cartoon_toaster.jpg" width="100%"> |
+| **岛上的气象站** · *Island Weather Station*<br><sub>Isometric 2.5D · 等轴 2.5D</sub> | **从这扇窗到那扇窗** · *From Window to Window*<br><sub>Continuous line art · 单线画</sub> |
+| <img src="examples/isometric_weather_island.jpg" width="100%"> | <img src="examples/lineart_paper_plane.jpg" width="100%"> |
+| **浮出** · *Rise*<br><sub>Soft 3D · 柔光 3D</sub> | **一滴水的旅程** · *A Drop's Round Trip*<br><sub>Shape morph · 形变动画</sub> |
+| <img src="examples/soft3d_rise.jpg" width="100%"> | <img src="examples/morph_water_cycle.jpg" width="100%"> |
+| **好奇心周刊 · 拆开看看** · *Curiosity Weekly · Take It Apart*<br><sub>Newspaper collage · 报刊拼贴</sub> | **晨间计划** · *Morning Plan*<br><sub>Aurora glassmorphism · 弥散玻璃</sub> |
+| <img src="examples/newscollage_curiosity.jpg" width="100%"> | <img src="examples/aurora_morning.jpg" width="100%"> |
+| **形与色** · *Form & Colour*<br><sub>Bauhaus geometric · 包豪斯几何</sub> | **海岸线 1987** · *Coastline 1987*<br><sub>Retro synthwave · 复古 Synthwave</sub> |
+| <img src="examples/bauhaus_form_colour.jpg" width="100%"> | <img src="examples/synthwave_coastline.jpg" width="100%"> |
+| **草莓杯垫** · *Strawberry Coaster*<br><sub>Perler beads · 拼豆</sub> | **迁徙季** · *Migration Season*<br><sub>Petroglyph · 岩画</sub> |
+| <img src="examples/perler_strawberry_coaster.jpg" width="100%"> | <img src="examples/petroglyph_migration.jpg" width="100%"> |
+| **尼罗河丰收** · *Harvest on the Nile*<br><sub>Egyptian tomb painting · 古埃及墓室壁画</sub> | **港口渔获** · *The Day's Catch*<br><sub>Roman mosaic · 罗马马赛克</sub> |
+| <img src="examples/tomb_harvest.jpg" width="100%"> | <img src="examples/mosaic_harbor.jpg" width="100%"> |
+| **四季之窗** · *Window of the Seasons*<br><sub>Stained glass · 彩色玻璃花窗</sub> | **星辰之书** · *Liber Stellarum*<br><sub>Illuminated manuscript · 泥金手抄本</sub> |
+| <img src="examples/stainedglass_seasons.jpg" width="100%"> | <img src="examples/illuminated_starchart.jpg" width="100%"> |
+| **扑翼机** · *The Ornithopter*<br><sub>Leonardo codex · 达·芬奇手稿</sub> | **剪影小像** · *Shades of the Wren Household*<br><sub>Silhouette · 剪影</sub> |
+| <img src="examples/codex_ornithopter.jpg" width="100%"> | <img src="examples/silhouette_family.jpg" width="100%"> |
+| **马戏团来了** · *The Circus Is Coming*<br><sub>Letterpress poster · 凸版印刷海报</sub> | **无线电** · *Radio*<br><sub>Soviet constructivism · 苏联构成主义</sub> |
+| <img src="examples/letterpress_circus.jpg" width="100%"> | <img src="examples/constructivism_radio.jpg" width="100%"> |
+| **夜行快车** · *Night Express*<br><sub>Art Deco · 装饰艺术</sub> | **火箭小队** · *Rocket Squad*<br><sub>Golden-age comic · 黄金时代漫画</sub> |
+| <img src="examples/artdeco_express.jpg" width="100%"> | <img src="examples/comic_rocket.jpg" width="100%"> |
+| **猫的六种心情** · *Six Moods of a Cat*<br><sub>Pop silkscreen · 波普丝网</sub> | **发射记录** · *Liftoff Trace*<br><sub>ASCII art (line printer) · ASCII 字符画(行式打印机)</sub> |
+| <img src="examples/popart_cat_moods.jpg" width="100%"> | <img src="examples/lineprinter_launch.jpg" width="100%"> |
+| **峡谷飞行** · *Canyon Run*<br><sub>Low poly · 低多边形</sub> | **放风筝** · *Hold On*<br><sub>Stencil graffiti · 喷漆模板涂鸦</sub> |
+| <img src="examples/lowpoly_canyon.jpg" width="100%"> | <img src="examples/stencil_kite.jpg" width="100%"> |
+| **三晚露营** · *Three Nights Out*<br><sub>Embroidered patches · 刺绣徽章</sub> | **灯塔剖面** · *Halvard Rock Light*<br><sub>Blueprint · 蓝图工程图</sub> |
+| <img src="examples/patch_camping.jpg" width="100%"> | <img src="examples/blueprint_lighthouse.jpg" width="100%"> |
+| **我的周末** · *My Weekend*<br><sub>Children's crayon · 儿童蜡笔画</sub> | **今天带伞吗** · *Bring an Umbrella?*<br><sub>Green-screen CRT terminal · 绿屏终端(荧光字符画)</sub> |
+| <img src="examples/crayon_picnic.jpg" width="100%"> | <img src="examples/crt_weather.jpg" width="100%"> |
+| **厨房里的温度** · *Kitchen Heat Map*<br><sub>Thermal camera · 热成像</sub> | **一阵风** · *The Gust*<br><sub>Delft tiles · 代尔夫特蓝瓷砖</sub> |
+| <img src="examples/thermal_kitchen.jpg" width="100%"> | <img src="examples/delft_canal.jpg" width="100%"> |
+| **篝火旁的岩洞** · *The Hunt by the Fire*<br><sub>Cave painting · 洞穴壁画</sub> | **窗台花园** · *Windowsill Garden*<br><sub>1-bit paint program · 1-bit 早期画图软件</sub> |
+| <img src="examples/cave_hunt.jpg" width="100%"> | <img src="examples/macpaint_garden.jpg" width="100%"> |
+| **赛跑与赛车** · *Games on a Vase*<br><sub>Greek black-figure vase · 古希腊黑绘陶瓶</sub> | **老街角的自行车** · *The Bread Run*<br><sub>Graphite pencil · 铅笔素描</sub> |
+| <img src="examples/blackfigure_games.jpg" width="100%"> | <img src="examples/graphite_bicycle.jpg" width="100%"> |
+| **行李安检** · *Security Check*<br><sub>X-ray · X 光片</sub> | **早晨的闹钟** · *Seven O'Clock*<br><sub>1930s rubber hose · 1930 年代黑白橡皮管动画</sub> |
+| <img src="examples/xray_luggage.jpg" width="100%"> | <img src="examples/rubberhose_morning.jpg" width="100%"> |
+| **雪夜归途** · *Homeward, First Snow*<br><sub>Linocut · 黑白麻胶版画</sub> | **吹蜡烛** · *Blow Out the Candles*<br><sub>VHS home video · VHS 家庭录像</sub> |
+| <img src="examples/linocut_snowy_village.jpg" width="100%"> | <img src="examples/vhs_birthday.jpg" width="100%"> |
+| **山间夜营** · *Night Camp*<br><sub>Flat vector · 扁平矢量</sub> | **小橡果的秋天** · *An Acorn's Autumn*<br><sub>Storybook animation · 绘本角色动画</sub> |
+| <img src="examples/flatvector_night_camp.jpg" width="100%"> | <img src="examples/storybook_acorn.jpg" width="100%"> |
+| **蛇梯棋大冒险** · *Snakes & Ladders, Round 7*<br><sub>Ballpoint doodle · 圆珠笔涂鸦</sub> | **海港步行图** · *Larkhaven on Foot*<br><sub>Overlay sheets · 描图纸叠层</sub> |
+| <img src="examples/ballpoint_board_game.jpg" width="100%"> | <img src="examples/overlay_city_map.jpg" width="100%"> |
+| **出发前,再查一遍行李** · *Pack Check*<br><sub>Pastel UI · 粉彩界面</sub> | **数学单元测验** · *Unit Test, Graded*<br><sub>Exam grading · 阅卷批改</sub> |
+| <img src="examples/pastelui_packing.jpg" width="100%"> | <img src="examples/grading_math_quiz.jpg" width="100%"> |
+| **蹴鞠** · *Cuju by Lamplight*<br><sub>Shadow puppetry · 皮影戏</sub> | **街角速写** · *Sketchbook Neighbours*<br><sub>Pen & wash · 钢笔淡彩</sub> |
+| <img src="examples/shadowpuppet_cuju.jpg" width="100%"> | <img src="examples/penwash_neighbours.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 and dyed donkey hide glowing on a lamp-lit screen. 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.
@@ -128,7 +130,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 sixty-three styles:
+A [Claude Code](https://claude.com/claude-code) skill and a small painting library with sixty-four styles:
| Style | Module | What makes it read as the real medium |
|---|---|---|
@@ -195,6 +197,7 @@ A [Claude Code](https://claude.com/claude-code) skill and a small painting libra
| **Pastel UI (product-film interface)** | `lib/pastelui.py` · `PastelUI` | one frame of a modern product film: a flat pastel field (blue, pink, yellow, lilac, mint, peach) with one big pool of soft light and a few white bokeh discs; macOS window cards with a frosted rim, a white body, the red / yellow / green lights and split panes, side panels, a dot pill and a step strip, a heavy headline with a translucent marker under the key words, status chips, round check / cross badges, text highlights, an inline reference chip and a callout tag; every shape is a signed-distance field with analytic 1 px anti-aliasing, and shadows follow CSS box-shadow (offset, blur, spread; a wide one tinted with the field colour plus a tight neutral one), so cards float without a grey halo; everything is drawn into named layers with a pose (offset, scale, opacity, left-to-right reveal) and a depth, so the same drawing pops a window up, writes a line, pops a badge or lets a companion rise from behind a card; a magnifier that enlarges the real pixels under it; a circular colour wipe between sections; three flat companions peek over the card edges — a starburst in a cream circle, a violet cloud with a >_ prompt, an orange pixel critter |
| **Exam grading (an answer sheet marked in red)** | `lib/grading.py` · `Grading` | an answer sheet on a green felt desk, printed like the real form — timing marks down the edge, a heavy title, fields, a ticket number with its bubbles filled, a score / grader table, numbered sections, ruled answer lines and a hatched grading column — with an answer key held by a black binder clip beside it; every paper has its own frame and pose, so a sheet can come down onto the desk (a little larger with a wide soft shadow while lifted, a thin contact shadow once down); everything written after printing keeps a progress value and a time map, so a stage can show a stroke half drawn: the candidate's blue-black answers, vermilion rubber stamps (ragged edges, clustered pin-holes, one end pressed dry so the thin border breaks, ink pooled at the rims, a wet bleed, a slight tilt, the paper dented round the rubber) and the red pen — a wavy underline, a ring that overshoots its start, a bowed leader, a note set in a bold sans and inked like the pen (no handwriting font), crosses, ticks and a score written stroke by stroke and circled; ink is Beer–Lambert density, so the red deepens where the pen slowed down and where it crosses print; a red pen shaded as a cylinder whose shadow spreads from the tip, and a varnished wooden stamp that comes down, presses and lifts |
| **Shadow puppetry (皮影戏)** | `lib/shadowpuppet.py` · `ShadowPuppet` | a shadow play seen from the audience, where everything on the screen is lamp light that came through it: a cloth screen lit by an oil lamp behind the middle (pale gold at the hot spot, deep amber toward the rim, thread slubs, a fold or two); puppets of scraped donkey hide kept as coverage plus an optical density per channel, so vermilion, teal, ochre and green glow, black dye is almost opaque and pieces darken where they overlap, in any order; pieces are cut, dyed in fields, inked along every cut edge and punched with the craft's hollow patterns (dots, rings, plum blossoms, coins, fish scales, ruyi cloud heads, lattice, ice cracks, stripes), and the hide's uneven thickness leaves no dye flat; a figure is a tree of jointed pieces with thread knots and an angle per joint (a hollow-carved or solid face in profile with one long eye and a long brow, a helmet with barred pheasant plumes or a crown with pompoms, cloud collar, breastplate mirror, scale armour, cuffs, thick-soled boots), with control rods tied to the collar and the hands; a puppet off the cloth grows, blurs and splits into two shadows (the lamp has two wicks), the soft double edge of a figure not quite pressed, and rods are sharp where they are tied and soft lower down; props come from the same leather (a pailou goal with a lattice net and a round eye, a stitched ball, a key-fret floor band, hanging name plaques); in front, a carved proscenium (key-fret lintel, a red lacquer plaque with raised gilt characters, an openwork valance and corner brackets the screen glows through) lit only by the light the screen spills onto its edges, and red paper lanterns lit from inside, with tassels and a warm halo |
+| **Pen & wash (钢笔淡彩)** | `lib/penwash.py` · `PenWash` | small cold-press sketch cards made the way a sketcher makes them — a fineliner line first, loose watercolour after, then the cards photographed on a table. Each card is its own sheet (paper tooth lit by the window, a cut edge that is not quite straight), drawn unturned and laid down at a slight angle. The ink line is near-uniform but hand-made: low-frequency wobble and tremor, width drifting a few per cent, a dot where the tip rested, a flick at some ends; closed shapes are one to three strokes that stop short or run past the join on the tangent, box corners overshoot, a stretch is sometimes gone over twice; parts have a depth, so an outline stops where a part in front covers it. Washes start from the intended region and are then painted loosely: slipped 2–5 px off the line (spilling over on one side, leaving white paper inside the line on the other), an edge re-found on a wandering threshold that follows the tooth, a darker dried rim, granulation in the valleys of the paper, faint flat-brush streaks, density mottle, wet-in-wet drops for cheeks and crust, cockling where the paper got wet — and a gentler slip for small shapes, so a nose never turns into a white ring. A flat background block that does not fill the card is painted around the figure with a white halo; opaque white gouache glints go on last. Ink and pigments are optical densities, so overlaps darken and mix. Helpers for goofy characters: big round glasses, dot eyes, tufts, simple hands, limbs, inked frames, ground lines. The photo: oak planks with cathedral grain and butt joints, soft card shadows and lit cut edges, a fineliner and a water brush shaded as cylinders (the clear barrel refracts what is under it), window fall-off, vignette and grain |
Ask Claude to *"draw it yourself"*, *"paint this with code"*, or *"claude绘图"*, and name a style if you like. Claude then:
@@ -311,6 +314,7 @@ Every style has a complete example: `python3 examples/<name>.py out.png --stages
- **Pastel UI**: one screen, one idea — a headline, one main window, one side panel and a status, with few words set large. Keep the field flat and the cards solid white; colour lives in the accents (the step strip, chips, badges, markers), and green is reserved for a pass, so use a blue field when there are checks and crosses. Put companions on a lower layer than the card they peek over, so the card itself hides the rest of them. Give a magnifier room: centre it on one thing with its labels outside the rim (a lens over a narrow column cuts its label and temperature in half). Draw each state of a thing as its own layer and switch them; for the draw-on GIF, give anything that moves a few in-between poses instead of a cross-fade.
- **Exam grading**: tell one grading story on one sheet — a few answers, one mistake, and every red mark pointing at it: a wave under it, a ring round it, a leader out to the grading column, and the note and the cross on the same row as the error (put that row first in the column so the leader stays short). Keep the words few and large and let the form itself (bubbles, timing marks, hatching) carry the texture. Give a ring room: it needs ~8 px of clear paper on each side, so leave the candidate a wider gap before the wrong figure. Stamps should be uneven but still legible (pressure ~0.64 at the light end). Red ink is Beer–Lambert density and only darkens a little above ~0.8, so light and dark passages come from the density range (about 0.4–1.2), not from the colour. In the GIF, give the pen and the stamps real in-between frames (`~` motion stages) instead of cross-fades.
- **Shadow puppetry**: keep the screen dark at the rim and pale gold only round the lamp, so dyed leather glows instead of looking printed. Leave big fields of solid dye and put the hollow patterns in bands; a pattern cell under ~12 px on the canvas turns a robe into fishnet. In profile the shoulder sits right under the head, so a near arm raised past ~140° crosses the face: raise the far arm up and back and keep the near one forward (130–147°). The classic 亮相 is one arm high behind, one low in front and a knee up. Give each figure room for its plumes, and keep the shoulder guard on the near arm only. A puppet slightly off the cloth (d ≈ 0.05) should read as a sharp shadow with a soft double edge, not as out of focus. In the GIF, everything that moves gets real in-between frames (`~` motion stages): the lamp glow spreading, players sliding in from the wings blurred and doubled until they are pressed sharp, the kick, the 亮相 snap.
+- **Pen & wash**: ink first, paint second, and let the paint miss: slip each wash a few px off its line so one side spills and the other leaves white paper — but shrink the slip for tiny shapes, or a nose or a crumb becomes a white ring. Keep tooth and granulation quiet; at full strength the card looks like stucco and the washes like coloured pencil. Give parts a depth so outlines break where something is in front, and keep the features inside the head (only the nose may bulge past it). Watch for accidental reads: a small circle under a moustache becomes a letter, a red dome with white spots a toadstool, a white oval belly a snowman, and a scooter stem must not cross a face. Paint the background block around the figure with a halo, never out to the card edge. Draw the tools at real scale (a fineliner is longer than the card is tall). In the GIF, give the bare table a small palette share of its own and cut the rest only from pixels that change, or the oak eats the colours of the pale blocks.
### Roadmap
@@ -322,7 +326,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,加上一个小巧的绘图库,内置六十四种画风:
| 画风 | 模块 | 为什么看起来像真的 |
|---|---|---|
@@ -389,6 +393,7 @@ Every style has a complete example: `python3 examples/<name>.py out.png --stages
| **粉彩界面** | `lib/pastelui.py` · `PastelUI` | 产品发布片里的一帧界面:整片纯色粉彩底(蓝 / 粉 / 黄 / 淡紫 / 薄荷 / 桃)加一大片柔光和几颗白色光斑;macOS 窗口卡片(磨砂外框、白色窗体、红黄绿三点、分栏)、侧面板、带圆点的小胶囊和步骤条、粗黑大标题压一条半透明色条、状态标签、圆形 ✓ / ✗ 徽章、文字高亮、嵌在正文里的引用标签和带尖角的小标签;所有形状都是有符号距离场、1 px 解析抗锯齿,阴影按 CSS box-shadow 算(偏移、模糊、扩展;一层染着底色的宽阴影加一层中性的近阴影),卡片浮起来却没有灰边;一切画进带姿态(位移、缩放、不透明度、从左往右揭开)和前后层次的图层,同一套画面既能弹出窗口、逐行写字、弹出徽章,也能让小图标从卡片后面探头;放大镜放大的是它下面真实的像素;节与节之间圆形擦除换底色;三个扁平小图标从卡片边探头——奶油色圆里的橙色星芒、紫色云朵里的 >_、橙色像素小怪 |
| **阅卷批改** | `lib/grading.py` · `Grading` | 绿毛毡桌上的一张答题卡,照真表格印:左边一排定位黑块、粗黑标题、姓名班级栏、考号格和涂好的圆泡、得分 / 阅卷人表格、分节、作答横线、斜纹阅卷栏;旁边是长尾夹夹住的标准答案卡。每张纸有自己的坐标和位姿,能从空中落到桌上(抬着时略大、投一片宽软的影,放下后只剩贴边细影);印刷之后写上去的东西都带「写到第几成」的进度和时间图,阶段快照能画出写到一半的笔画:考生的蓝黑作答、朱红橡皮章(毛边、成簇针孔、一头压得轻而细框断开飞白、边缘积墨、刚盖下的湿晕、轻微歪斜、纸面压出的凹痕),以及红笔的波浪线、越过起点的手画圈、弧形引线、用粗黑体按红墨处理的批注(不用手写字体)、叉、勾、一笔笔写出再圈起来的分数;墨按比尔定律算密度,笔走慢的拐弯处、压在印刷上都会更深;红笔按圆柱打光、投影从笔尖散开,上漆木章落下、压一下、再抬起 |
| **皮影戏** | `lib/shadowpuppet.py` · `ShadowPuppet` | 观众这边看到的一场皮影,幕布上的一切都是透过来的灯光。幕布由一盏油灯从背后照亮:灯后面淡金,往外深琥珀,带纱线粗节和一两道折痕。人偶是刮薄的驴皮,按覆盖率加每个通道的光密度来算,所以朱红、青绿、赭黄、绿色透亮,黑色几乎不透,两块皮相叠处更深,和先后顺序无关;每块皮可以剪、分区染色、沿剪边描黑,打出皮影的各种镂空纹样(圆点、圆环、梅花、铜钱、鱼鳞、如意云头、方格、冰裂、条孔),皮厚不匀让染色不会死平。关节人偶是一棵带线结、每个关节一个角度的皮件树(阳刻空脸或阴刻脸的侧面像,一只长眼一道长眉;带黑横斑的雉翎盔或绒球三叉冠;云肩、护心镜、鱼鳞甲、袖口、厚底靴),操纵杆绑在领口和手上。离开幕布的人偶会变大、变虚,又因为灯有两个灯芯分成两个影,就是没贴紧时那种软的双边;操纵杆绑的地方清楚,往下越来越虚。同一套皮还做道具:牌楼式球门(窗棂网和风流眼)、缝线的鞠、回纹底带、挂在线上的小牌。幕前是雕花戏台(回纹横楣、红漆凸起金字牌匾、透空挂落和花牙子,幕布的光从镂空处透出来),只被幕布溢出的光照亮边缘;还有内有烛光的红纸灯笼,带穗子和一圈暖光 |
+| **钢笔淡彩** | `lib/penwash.py` · `PenWash` | 照速写人的顺序画在冷压水彩小卡上:先针管笔线稿,再松散淡彩,最后把卡片放在桌上拍下来。每张卡是独立的一张纸(窗光照出的纸纹、略不直的切边),不转着画,放下时才带一个小角度。墨线几乎等宽但是手画的:低频手抖加颤动、线宽漂几个百分点、落笔一个小墨点、有的收尾一甩;闭合形状由一到三笔组成,接口停早留缺口或冲过头沿切线出头,方框的角相互出头,偶尔一段描两遍;部件分前后,被前面部件盖住的轮廓线自动断开。淡彩先算「本来要涂的区域」,再像手快那样涂:整块错位 2–5 px(一边出线、另一边在线里留白缝),边缘用游走的阈值重新取、顺着纸纹,干边更深,颗粒沉在纸纹的谷里,淡淡的平刷条纹,浓淡斑驳,腮红和面包烤色湿中湿滴进去,打湿处纸面起皱;小形状错位缩小,鼻子不会变成白圈。不铺满卡片的背景色块绕开人物、留一圈白边;白色水粉高光最后上。墨和颜料都按光密度叠加,相叠变深、混色。带画呆萌小人的部件:大圆眼镜、点点眼、翘头发、简单的手、四肢、手绘边框、地线。照片:带「山纹」年轮和拼接缝的橡木桌、卡片的软阴影和受光的切边、按圆柱打光的针管笔和水笔(透明水杆折射下面的东西)、窗光衰减、暗角和颗粒 |
对 Claude 说「claude绘图」「你自己画」「用代码画」,也可以指定画风。它会:
1. **先定构图**:层次、焦点、留白,而且画面要图解内容本身;
@@ -481,6 +486,7 @@ python3 examples/overlay_city_map.py out.jpg --stages stages/ # 描图纸
python3 examples/pastelui_packing.py out.jpg --stages stages/ # 粉彩界面:出发前,再查一遍行李
python3 examples/grading_math_quiz.py out.jpg --stages stages/ # 阅卷批改:数学单元测验
python3 examples/shadowpuppet_cuju.py out.jpg --stages stages/ # 皮影戏:蹴鞠
+python3 examples/penwash_neighbours.py out.jpg --stages stages/ # 钢笔淡彩:街角速写
```
### 作画要点(Claude 交图前逐条自查)
@@ -546,6 +552,7 @@ python3 examples/shadowpuppet_cuju.py out.jpg --stages stages/ # 皮影戏:
- **粉彩界面**:一屏只讲一件事——一个大标题、一个主窗口、一个侧面板、一个状态,字少而大。底色平、卡片实心白,颜色只放在强调处(步骤条、标签、徽章、色条);绿色只留给「通过」,所以有 ✓ / ✗ 的画面用蓝底。小图标放在它探头的那张卡片下一层,让卡片自己挡住其余部分。放大镜要有地方放:对准一样东西,标签放在镜框外(镜片压在窄窄一列上会把日期和温度切成两半)。同一样东西的不同状态各画一层再切换;做动图时,会动的东西给几个中间姿态,不要叠化。
- **阅卷批改**:一张卷子讲一件批改的事——几道作答、一处错,所有红笔都指向它:下面波浪线、外面一个圈、一道引线拉到阅卷栏,批注和叉跟出错那行同高(把批注行排在阅卷栏第一行,引线才短)。字少而大,纹理交给表格本身(涂卡圆泡、定位黑块、斜纹)。圈要有地方:两边各要约 8 px 空白,所以让考生在写错的那个数前多空一格。印章要不匀但认得出(轻的那头压力约 0.64)。红墨按比尔定律算密度,0.8 以上只是略微变深,浓淡要靠密度范围(约 0.4–1.2)拉开,而不是换颜色。做动图时,笔和章给真正的中间帧(`~` 运动阶段),不要叠化。
- **皮影戏**:幕布边缘要暗,只在灯后面那一块发淡金,染色的皮才会「透亮」,而不是像印上去的。大面积留实色,镂空纹样只放在一段里:画布上一个纹样单元小于约 12 px,袍子就成了渔网。侧身时肩就在头的正下方,近侧手臂抬过约 140° 会从脸前过:要高举就举远侧那只往后上方,近侧手臂斜向前上(130–147°);亮相就是一手高(远侧向后上)、一手低(近侧向前下),再提膝。给翎子留地方;护肩花只放在近侧手臂上。离幕一点(d ≈ 0.05)的人应该是一个清楚的影加一条软的双边,不是失焦。做动图时,会动的都给真正的中间帧(`~` 运动阶段):光晕铺开,人从侧幕滑进来由虚变实,起脚,亮相定住。
+- **钢笔淡彩**:先墨后彩,让颜色「涂歪」:每块淡彩错开线条几 px,一边出线、另一边留白缝;但小形状要把错位缩小,否则鼻子、面包屑会变成白圈。纸纹和颗粒要收着,开满了卡片像拉毛墙、淡彩像彩铅。部件要分前后,被挡住的轮廓线才会断开;五官收在头的轮廓里(只有鼻子可以鼓出去)。小心看错:胡子下面的小圆圈会读成字母,红圆顶加白点是毒蘑菇,白色椭圆肚子是雪人,滑板车立杆不能穿过脸。背景色块绕开人物留白边,不要铺到卡边。桌上的笔按真实比例画(针管笔比卡片还长)。做动图时空桌面单独分少量色位,其余只从变化的像素里切,否则橡木会吃掉淡色背景块的色位。
### 计划
diff --git a/SKILL.md b/SKILL.md
index 69e37fd..95d5c8a 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(油灯照亮的幕布上,雕空、透明染色的驴皮关节人偶:镂空纹样、阳刻空脸、雉翎盔头、线结与操纵杆、离幕时虚化的双影;雕花戏台、红漆金字牌匾、红灯笼)。用户说「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 窗口、界面卡片、讲解片界面页、小图标探头、阅卷、阅卷批改、批改、判卷、改卷、改作业、答题卡、试卷、考卷、测验卷、红笔批改、红笔打分、打分数、盖章批改、朱红印章、标准答案卡、长尾夹、讲解片评测 / 打分页、皮影、皮影戏、影子戏、驴皮影、灯影戏、皮影人偶、雕花戏台、戏台牌匾、亮相),或 "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 without an image model" 时使用;也用于需要逐步画出(draw-on)动画的插画。单独说「剪纸」指剪纸拼贴、「刺绣」指十字绣、「丝网印刷 / screen print」指包豪斯几何;「打马赛克」是打码,不是马赛克画风;单说「蓝图」指蓝图工程图,「蓝晒 / 晒图」仍指蓝晒;「铅笔 / 素描」指铅笔素描,「彩铅」指韩国彩铅;「像素」仍指像素风,「1-bit / 黑白画图软件」指 1-bit 早期画图软件;「霓虹」仍指赛博朋克;「喷漆 / 街头涂鸦」仍指喷漆模板涂鸦,「圆珠笔 / 随手涂鸦 / 页边涂鸦」指圆珠笔涂鸦;「描图纸 / 硫酸纸 / 叠片 / 灯箱」指描图纸叠层(蓝图工程图那张描图布是晒成蓝图的,不是叠片);「Dot 风 / 粉彩界面 / 窗口卡片 / 发布会界面」指粉彩界面(纯色底 + 白色实心窗口卡片),要磨砂玻璃和弥散渐变仍用弥散玻璃;「阅卷 / 批改 / 答题卡 / 判卷 / 红笔打分」指阅卷批改,实验记录里的红笔圈和便利贴仍用实验笔记本,带「已付」橡皮章的小票拼贴仍用贴纸拼贴 · 小票;「皮影 / 皮影戏 / 影子戏」指皮影戏(透光的彩色驴皮人偶),黑纸剪出的侧影小像仍用剪影,彩纸剪贴仍用剪纸拼贴。
+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(速写小卡上的针管笔线稿 + 松散淡彩:线条抖、出头、不闭合,颜色错位出线、留白缝、干边与颗粒,不铺满的背景色块;大头、圆眼镜、点点眼、红鼻子的呆萌小人;卡片拍在木桌上,旁边放着针管笔和水笔)。用户说「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 窗口、界面卡片、讲解片界面页、小图标探头、阅卷、阅卷批改、批改、判卷、改卷、改作业、答题卡、试卷、考卷、测验卷、红笔批改、红笔打分、打分数、盖章批改、朱红印章、标准答案卡、长尾夹、讲解片评测 / 打分页、皮影、皮影戏、影子戏、驴皮影、灯影戏、皮影人偶、雕花戏台、戏台牌匾、亮相、钢笔淡彩、淡彩、淡彩速写、钢笔淡彩小人、针管笔、勾线笔、针管笔加水彩、线稿上色、速写卡片、速写本小人、水彩小卡、城市速写、街头速写、水笔、自来水笔),或 "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 without an image model" 时使用;也用于需要逐步画出(draw-on)动画的插画。单独说「剪纸」指剪纸拼贴、「刺绣」指十字绣、「丝网印刷 / screen print」指包豪斯几何;「打马赛克」是打码,不是马赛克画风;单说「蓝图」指蓝图工程图,「蓝晒 / 晒图」仍指蓝晒;「铅笔 / 素描」指铅笔素描,「彩铅」指韩国彩铅;「像素」仍指像素风,「1-bit / 黑白画图软件」指 1-bit 早期画图软件;「霓虹」仍指赛博朋克;「喷漆 / 街头涂鸦」仍指喷漆模板涂鸦,「圆珠笔 / 随手涂鸦 / 页边涂鸦」指圆珠笔涂鸦;「描图纸 / 硫酸纸 / 叠片 / 灯箱」指描图纸叠层(蓝图工程图那张描图布是晒成蓝图的,不是叠片);「Dot 风 / 粉彩界面 / 窗口卡片 / 发布会界面」指粉彩界面(纯色底 + 白色实心窗口卡片),要磨砂玻璃和弥散渐变仍用弥散玻璃;「阅卷 / 批改 / 答题卡 / 判卷 / 红笔打分」指阅卷批改,实验记录里的红笔圈和便利贴仍用实验笔记本,带「已付」橡皮章的小票拼贴仍用贴纸拼贴 · 小票;「皮影 / 皮影戏 / 影子戏」指皮影戏(透光的彩色驴皮人偶),黑纸剪出的侧影小像仍用剪影,彩纸剪贴仍用剪纸拼贴。「钢笔淡彩 / 淡彩速写 / 针管笔加水彩 / 线稿上色的速写小卡」指钢笔淡彩;单说「水彩」仍指水彩(风景、花卉的大片晕染),蓝铅笔稿 + 毛笔线 + 赛璐璐阴影的拟人小物仍用卡通手绘,「素描 / 铅笔」仍指铅笔素描。
---
# Claude 绘图
@@ -77,6 +77,7 @@ description: Claude 绘图 / Claude Drawing —— 不借助任何生图模型
| 粉彩界面 · Pastel UI | `lib/pastelui.py` · `PastelUI` | `examples/pastelui_packing.py` 出发前,再查一遍行李 · Pack Check(产品发布片里的一帧:蓝色粉彩底、一大片柔光和几颗白色光斑;左上胶囊「旅行清单」和步骤条 证件 → 充电 → 雨具 → 出发,粗黑大标题「出发前,再查一遍行李」压一条浅蓝色条;macOS 窗口「打包清单 · 京都 4 天」:左栏目的地、三天天气预报(周一下雨)、已装好 11 / 12 进度条,右栏打包助手的话逐行写出——行首的引用标签「证件夹 ✓」、绿色色条压在已装好的东西下、粉色高亮「周一京都有小雨」配「伞还没装」小标签;右边「出门检查」面板三行:证件 ✓、充电 ✓、雨具 ✗,结论「还差一把伞」;放大镜停在周一的雨云上,镜里是真像素放大;紫色云朵 >_ 从窗口后面探头、奶油色圆里的橙色星芒从面板后面探头、橙色像素小怪站在面板上) | 约 0.5 秒(加 `--stages` 约 5 秒) |
| 阅卷批改 · Exam Grading | `lib/grading.py` · `Grading` | `examples/grading_math_quiz.py` 数学单元测验 · Unit Test, Graded(深绿毛毡桌上一张米色答题卡,下面还压着两张:左边一排定位黑块、角标、粗黑标题、姓名班级栏、考号格和涂好的涂卡圆泡、得分 / 阅卷人表格、填涂示例;一题三道计算,二题应用题(灰底题目框 + 浅方格横线作答区 + 斜纹阅卷栏);左边长尾夹夹着深蓝页眉的标准答案卡,下面一张评分小纸条。考生用蓝黑墨水逐行作答;两个朱红橡皮章盖进阅卷栏(书写工整 ✓、列式正确 ✓);红笔给三道计算打勾,在 128 ÷ 16 = 6(天)下画波浪线、圈出「6(天)」、引线拉到阅卷栏写「应为 8 天」再打叉,答句里的 6 划一道,标准答案卡上 ① 打勾、② 打叉,最后在得分格写 75 并圈起来,笔放在得分格旁;印章一头发干、边缘飞白、轻微歪斜,红墨有浓淡和晕染,纸纹和灯光不均;`--stages` 出 113 个阶段,含纸落下、章落下压一下抬起、红笔边走边写的中间帧) | 约 1 秒(成品)/ 约 35 秒(含阶段) |
| 皮影戏 · Shadow Puppetry | `lib/shadowpuppet.py` · `ShadowPuppet` | `examples/shadowpuppet_cuju.py` 蹴鞠 · Cuju by Lamplight(油灯从背后照亮的琥珀色幕布,前面是雕花戏台:回纹浮雕横楣、红漆金字牌匾「蹴鞠」、透空回纹挂落、两角镂空花牙子、两盏红灯笼;幕上是雕空、透明染色的驴皮:牌楼式球门(瓦顶飞檐、鸱吻、窗棂网、红边风流眼)、底部回纹装饰带、四个关节人偶。红方球头刚起脚,一条腿踢得老高,同伴一手高一手低、提膝亮相;青方一个跳起扑球(离幕一点,边缘发软、成双影),一个指着球;鞠正卡在风流眼里;「球头」「骁色」两块小牌挂在线上。人偶是阳刻空脸或阴刻红脸、雉翎盔或三叉冠、云肩护心镜鱼鳞甲、厚底靴,皮叠在一起处更深,关节有线结,操纵杆从领口和手上垂下去;`--stages` 出 60 个阶段,全是真运动:点灯、横楣落下、灯笼晃着亮起、球门升起、人从侧幕滑进来由虚变实、传球、起脚、亮相、小牌落下) | 约 7 秒(成品)/ 约 27 秒(含阶段) |
+| 钢笔淡彩 · Pen & Wash | `lib/penwash.py` · `PenWash` | `examples/penwash_neighbours.py` 街角速写 · Sketchbook Neighbours(橡木桌上并排四张冷压水彩小卡,一张一个街坊在做一件小事:吹着口哨的邮差,钴蓝帽子和外套,挎包塞得太满,两封信从背后逃出去扑扇着飞走;戴超大圆眼镜的奶奶给花盆浇水,猫却钻进了盆里,水滴正落在它两耳之间(眯眼、爪子扒着盆沿),真正的那朵红花在旁边干等;踩滑板车的小孩,钴蓝头盔大了两号、压到眉毛,吐着舌头,膝盖贴着创可贴,身后速度线和尘土;圆滚滚的面包师戴高高的白帽子,抱着一根比他还长的法棍,法棍从手绘边框里戳出去,一只麻雀落在尖上啄;针管笔线条抖、出头、不闭合、偶尔描两遍,淡彩错位出线、在线里留白缝、干边、颗粒,腮红湿中湿,不铺满的背景色块绕开人物留白边,白色水粉高光;卡片有阴影和受光的切边,旁边放着一支针管笔、一支水笔(透明杆里的水和气泡、染了颜色的尼龙笔尖)和水笔的笔帽;`--stages` 出 9 个阶段:空桌、白卡、两批墨线、两遍淡彩、背景色块、高光、放下笔) | 约 3 秒(成品)/ 约 6 秒(含阶段) |
各画风共用 `lib/core.py` 里的底层工具:噪声、模糊、样条曲线、多边形遮罩、有机轮廓 `blob_pts`、毛笔 `bristle_stroke`、中文字体查找;新四种还用到补零平移 `shift`、文字遮罩 `text_mask`、西文字体查找 `latin_font`/`load_font`,以及高度图打光 `height_normals`、`height_shadow`(沿光线步进的投影)、`ambient_occlusion`。
@@ -143,7 +144,8 @@ description: Claude 绘图 / Claude Drawing —— 不借助任何生图模型
- 地图、路线与导览、城市 / 园区 / 校园平面图,「一层一层把信息加上去」的图解(底图 → 水系 → 绿地 → 路线),设计稿或方案的分层、叠加与对照,讲解片里「把几层信息叠起来看」的页 → 描图纸叠层(要正等轴的微缩模型用等轴 2.5D;要剖面、尺寸和施工说明用蓝图工程图;要三原色丝网海报用包豪斯几何);
- 产品发布片 / 科技讲解片的「界面 / 流程 / 检查结果」页,要明亮干净、像真产品截图的窗口卡片,一屏讲一件事(大标题 + 一个主窗口 + 一个侧面板 + 状态),一整部讲解片统一的主画面(每节换一种粉彩底、圆形擦除转场)→ 粉彩界面(要磨砂玻璃和弥散渐变用弥散玻璃;要等轴微缩模型用等轴 2.5D;要黑白早期界面用 1-bit 早期画图软件);
- 考试、作业、批改与打分,「对照标准答案逐条检查」的过程(评测、验收、审核、评分规则、哪里错了、为什么扣分),讲解片里的「怎么判对错 / 评分标准 / 检查结果」页 → 阅卷批改(要草稿纸上的随手推演用圆珠笔涂鸦;要实验记录、红笔圈和便利贴用实验笔记本;要明亮的产品界面里打 ✓ / ✗ 用粉彩界面);
-- 中国传统与民间艺术、节庆(元宵、庙会、过年)、戏曲和民间故事、古代体育与游戏(蹴鞠、赛龙舟、舞狮)、「一场好戏」式的小叙事(登场—交手—亮相),讲解片里的「历史 / 传统 / 一场比赛的高光时刻」页,要人物有动作又不能用真人 → 皮影戏(要黑纸剪的侧影小像用剪影;要彩纸剪贴的童趣用剪纸拼贴;要山水留白用水墨)。
+- 中国传统与民间艺术、节庆(元宵、庙会、过年)、戏曲和民间故事、古代体育与游戏(蹴鞠、赛龙舟、舞狮)、「一场好戏」式的小叙事(登场—交手—亮相),讲解片里的「历史 / 传统 / 一场比赛的高光时刻」页,要人物有动作又不能用真人 → 皮影戏(要黑纸剪的侧影小像用剪影;要彩纸剪贴的童趣用剪纸拼贴;要山水留白用水墨);
+- 人物小品、街坊邻居与日常小事(送信、浇花、骑车、买面包)、一组角色卡 / 人设卡、旅行和城市速写里「一个人在做一件小事」、轻松幽默的配图,讲解片里「一组用户 / 角色 / 团队成员」的介绍页 → 钢笔淡彩(要蓝铅笔稿、毛笔线和赛璐璐阴影的拟人小物用卡通手绘;要风景和花卉的大片晕染用水彩;要真的动起来的角色用绘本角色动画;要草稿纸上的随手涂鸦用圆珠笔涂鸦)。
每种画风一幅范例作为质量基准(范例都不用禅意主题);水墨另加一幅「月印万川」(留白托月、水面倒影)。
@@ -1006,6 +1008,16 @@ from core import spline, curve, blob_pts, fbm1d, blur, polygon_mask
- 字体:`plaque` / `label`(牌匾、小牌):魏碑(macOS 按需下载的字体)→ 隶变 → 楷体 → 宋体,Linux 用 Noto Serif CJK,Windows 用华文新魏 / 楷体;可用 `INKPAINT_FONT_SHADOWPUPPET_PLAQUE` / `_LABEL` 指定
- 染料 `DYES`:plain red crimson teal green ochre yellow blue brown pink black;色板常量 `SCREEN SCREEN_EDGE HIDE WOOD LACQUER GOLD SPILL ROD LAMPS`;`render()`、`composite()`、`stage(name)`、`save(path, stages_dir)`;`save('x.jpg')` 默认 quality 88、4:4:4 色度
+**钢笔淡彩 `PenWash`**:
+- 思路:每张卡片是一张独立的冷压水彩纸(自己的缓冲区,按卡片坐标 = 画布像素、不转着画,内部 2 倍分辨率),拍照时才按位置和小角度放到桌上。纸:约 1 mm 的凸点(这里 2–4 px)叠在更缓的起伏上,按左上窗光打光;切边略不直、有毛边。墨线是针管笔:几乎等宽,每一笔重采样后加低频手抖和一点颤动,线宽 ±9% 漂移,落笔处一个小墨点,部分笔画收尾一甩变细;画得快,闭合形状由 1–3 笔组成,接口处要么停早留缺口、要么冲过头沿切线出头,方框的角各画各的、相互出头,偶尔一段再描一遍、偏 1–2.5 px;墨按比尔定律光密度叠加,纸纹最深的谷里略漏白;部件按 z 遮挡,被前面部件盖住的轮廓线自动断开。淡彩(墨干后上)先算「本来要涂的区域」(部件减去前面的部件),再像手快那样涂:整块错位 2–5 px(一边出线、另一边在线里留白缝);边缘在模糊副本上用游走的阈值重新取(负的出线、正的回缩,另有成片回缩的白缝),利落但抖、顺着纸纹;干边(水干时颜料跑到边上);颗粒(颜料沉进纸纹的谷);平刷条纹;浓淡斑驳;可选干笔飞白;湿中湿 `bleed`(滴进还湿的色块、软边、停在湿边);打湿的地方纸面起皱。颜料也按光密度叠加,相叠变深、混色。背景色块是不铺满卡片的粗糙平涂矩形,绕开人物留几 px 白边。白色水粉最后上、不透明
+- 构造:`PenWash(W, H, seed, ss=2, keep_stages=True, stages_dir=None)`;`table(kind='oak'|'pale'|'walnut'|'linen', plank=176)` 桌面(橡木板:带「山纹」拱形的年轮、导管、板缝和拼接缝、缎面光泽);`card(cx, cy, w, h, rot, tone, corner, tooth, seed)` 放一张白卡并设为当前卡(rot 是顺时针度数),`use(card)` 切换;之后的绘制都画在当前卡上(也可以传 `card=`)
+- 部件(墨线在 `ink()` 时才画):`part(pts, z, ink=True, strokes=None, corners=False, smooth=True, width, reserve=True, nseg)` 一个区域加它的轮廓(`strokes` 改成只描给定的几段开放路径;`corners` 在角上拆成相互出头的直线;`reserve=False` 时背景色块不绕开它;`nseg` 指定闭合轮廓分几笔);`limb(pts, w0, w1, z, caps=(False, True))` 袖子、腿、背带(只描两侧和指定的端头);`stroke(pts, z, width, closed, smooth, corners, wobble, over=(0, 3), double, flick, nseg)` 单独一笔(被 z 更高的部件挡住的部分不画);`lines(paths, …)`;`dot(x, y, r, z)` 点出来的眼睛;`ink()` 给当前卡上所有待画的笔画上墨
+- 脸和小件:`glasses(cx, cy, r, gap, z, temple=(x, y))` 一副大圆眼镜(两片镜片是部件,后面的肤色涂到镜框就停、镜片里留白),返回两片镜片;`brows(paths)`;`tufts(x, y, n, length, spread, angle)` 几根翘起的头发;`frame(x0, y0, x1, y1)` 手绘边框(四边各一笔、角上出头);`ground(x0, x1, y)` 两笔粗地线;`signature(x, y, size)` 角上的小螺旋签名
+- 形状(静态方法,卡片坐标):`PenWash.oval(cx, cy, rx, ry, rot, egg, wob)`(`egg` > 0 是下宽的大头)、`rrect`、`box(cx, cy, w, h, rot)`、`turn(pts, cx, cy, deg)`、`smooth(pts, closed)`、`tube(pts, w0, w1)` → (轮廓, [左边, 右边, 末端, 起端])、`hand(x, y, angle, size, kind='mitten'|'open'|'fist', flip)` → (轮廓, 指缝线)
+- 颜料:`wash(target, colour, strength, shift, slip=(2, 4.8), warp=1.6, gaps=2.2, soft=2.2, edge=0.35, gran=0.14, streak=0.08, angle, var=0.13, dry)`,target 是部件、部件列表、点列或 `('mask', sl, m)`;区域等效半径小于 16 px 时错位、白缝和抖动按比例缩小;`bleed(target, x, y, r, colour, strength)` 湿中湿(腮红、面包烤色);`background_block(x0, y0, x1, y1, colour, strength, rough, corner, halo, angle, edge, streak, dry)`;`spatter(colour, n, box, size)` 甩上去的颜料点;`highlight(pts, width, alpha)`、`glint(x, y, r)` 白色水粉;颜色用 `PAINTS` 里的名字(coral red pink rose peach skin tan ochre yellow brown terracotta teal mint sage green cobalt sky bluegrey grey warmgrey black lilac)或 '#rrggbb'
+- 桌上的道具:`pen(x, y, angle, length=430, r=10.5, cap=True)` 针管笔(笔尖在 (x, y)、笔身朝 angle 度:纤维笔尖、金属套管、灰色锥头、哑光笔杆上印着线宽、套在尾部的亮面笔帽和笔夹);`water_brush(x, y, angle, length=320, r=12, stain='teal', cap=(x, y, angle))` 水笔(尼龙笔尖、尖上染一点颜料、螺纹握把、微雾的透明水杆按圆柱折射下面的东西、尾部气泡;`cap` 另放一个透明笔帽);都按圆柱打光、带投影(透明部分影子浅、有一点焦散)。比例:卡片约 9 cm 宽时,针管笔比卡片还长(范例 640 px、r 16),水笔 600 px、r 24
+- 常量 `PAINTS INK PAPER WOODS LINEN SHADOW`;`render()`、`composite()`、`stage(name)`、`save(path, stages_dir)`;`save('x.jpg')` 默认 quality 88、4:4:4 色度;笔杆上的字用 core 的 sans_bold(可用 `INKPAINT_FONT_SANS_BOLD` 指定)
+
**顺序**:都是先远后近、先大后小,文字最后叠加。水墨的雾要画在它该吞没的东西之后;水彩的叶梗要先画,并且只画在叶子外面。
## 三、毛病清单(都真实出现过)
@@ -1992,6 +2004,22 @@ from core import spline, curve, blob_pts, fbm1d, blur, polygon_mask
| 结尾灯闪三下多出 360 KB | 每闪一下整片幕布都变,要整帧重发:只暗一下(7%);点灯也从 7 帧减到 5 帧 |
| 画戏台时峰值内存 1.2 GB | 浮雕打光在整张画布上算:只在横楣一条、两根柱子、台口一条上分段算,远处溢光用半分辨率,球门和底带用 2 倍超采样;峰值约 0.8 GB(出阶段约 0.9 GB) |
+**钢笔淡彩**
+
+| 问题 | 改法 |
+|---|---|
+| 卡片像拉毛墙,淡彩像彩铅一粒一粒 | 纸纹受光 0.42 → 0.20;淡彩颗粒 0.35 → 0.14、笔刷条纹 0.18 → 0.08(背景色块 0.2 / 0.12)。颗粒和条纹只要隐约看得见 |
+| 鼻子、舌头、面包屑变成一个个白圈 | 小区域也照样错位 3–5 px、留 2 px 白缝,颜色就被挤没了:`wash()` 按区域等效半径缩放错位、留白缝和边缘抖动(小于 16 px 按比例缩小,最低 0.22 倍) |
+| 胡子下面吹口哨的小「o」读成字母 p | 小圆圈挂在胡子下面就是一个字母:删掉,口哨只靠旁边两个音符 |
+| 红色圆顶头盔读成毒蘑菇 | 红顶 + 白通风孔 + 一块大高光就是蘑菇:换钴蓝头盔、深色通风槽、珊瑚色条纹,不加大高光;帽檐压到眉毛,两只眼睛从下面露出来,「头盔太大」才看得出来 |
+| 浇水壶像烧水壶 | 壶身前倾约 14°,长壶嘴从壶底前侧斜伸出去,头上一个莲蓬头带几个小孔,提手从顶上跨过去 |
+| 白围裙椭圆像雪人肚子;换成蓝袖白前胸又像企鹅 | 白厨师服的圆身子 + 窄一点的钴蓝背带围裙;围裙口袋只描线,做成不上色的部件会变成白洞,把围裙变成「6」字 |
+| 小孩的第二只眼、鼻子、舌头落在脸的轮廓外 | 五官收进头的轮廓里,只让鼻子在轮廓边上鼓出一点;车把立杆放在脸的前方,不能从脸上穿过 |
+| 透明水杆没有影子,像浮在桌上,还有橙色光斑 | 透明部分影子密度 0.62(实心是 1),焦散只提亮 0.10;杆身加一点雾面(+0.08)才像塑料不像玻璃 |
+| 木纹像贴膜地板,中间突然断一截 | 每块板单独生成,加 1–2 组「山纹」拱形年轮;不要用 `np.roll` 挪纹理(卷绕处会断开),拼接缝右边换一块新板 |
+| 笔太小,下面三分之一桌面空着 | 按真实比例:卡片约 9 cm 宽时,针管笔比卡片还长(640 px、r 16),水笔 600 px、r 24 |
+| 动图里淡蓝、灰绿背景块变成灰青和米色,黄衣服发橙 | 橡木桌本身就是饱和色,「饱和像素 ×5」把色位都给了木头:56 色只从空桌面切,198 色只从和空桌面不同的像素切;末帧 p99 误差 35 → 23 |
+
## 四、做成动画
- 各画风都有 `stage(name)` 和 `save(path, stages_dir)`,按阶段依次淡入叠化,就是「一幅画被逐步画出来」。README 里的动图就是这样做的。
@@ -2015,6 +2043,7 @@ from core import spline, curve, blob_pts, fbm1d, blur, polygon_mask
- 粉彩界面的动图(脚本在 `claude_drawing/pastelui_work/make_gif_pastelui.py`):阶段是 圆形擦除铺开底色 → 窗口弹出 → 胶囊、标题、色条、左栏、正文逐行写出 → 面板弹出 → 徽章依次打勾 / 打叉(中间放大镜从第三行飞到天气预报上)→ 三个小图标探头。会动的东西不用叠化:范例里 `move()` 给每样东西几个缓动 / 回弹的中间姿态,存成 `mv_*` 阶段,动图里每个 50 毫秒硬切,就是真运动(写字是 reveal 从 0 到 1,徽章是绕自己中心从 0.3 倍回弹到 1);其余阶段用 70 毫秒的帧叠化。调色板先强制放进整套界面色,再按加权样本中值切分;固定 4×4 Bayer,没变的像素记成品红透明。107 帧、15.6 秒、约 0.35 MB,按解码结果逐帧自检。
- 阅卷批改的动图(脚本在 `claude_drawing/grading_work/make_gif_grading.py`):阶段是 桌面 → 答题卡抬着淡入、两帧落下 → 标准答案卡和纸条同样落下 → 夹上长尾夹 → 五行作答逐字出现 → 两个章各「落下两帧 → 压下停 360 毫秒 → 抬起 → 拿走」→ 红笔从右下角进来,给三道计算打勾,画波浪线、圈、引线、批注、叉,划答句,在标准答案卡上打勾打叉,写分数再圈起来,每一笔之间抬笔移过去 → 笔放回得分格旁。阶段名里带时间:带 `~` 的是运动帧(硬切、不叠化),`@毫秒` 是停留时间,其余是关键阶段(停 900 毫秒,相邻两个关键阶段之间 5 帧叠化),所以章和笔是真的在动。重发规则沿用描图纸叠层的平滑分量 / 细节残差阈值;帧一张张算、不全留在内存里;调色板 180 色中值切分(饱和像素 ×5、亮色 ×2)+ 75 色只从饱和像素里切(红笔、朱红印、深蓝页眉、木章),固定 4×4 Bayer。133 帧、21.4 秒、约 1.17 MB,按解码结果逐帧自检,末帧误差和单纯调色板量化相同。
- 皮影戏的动图(脚本在 `claude_drawing/shadowpuppet_work/make_gif_shadowpuppet.py`):阶段是 黑场 → 灯点着、光晕一圈圈铺开、闪动 → 横楣带着灯笼从上面落下,灯笼晃着亮起来 → 底带和球门从下面升上来,边升边贴紧幕布(由虚变实)→ 四个人从两边侧幕滑进来,离幕远时又虚又是双影,边走边贴上幕布 → 站定 → 同伴挑球传过去 → 球头收腿、起脚,球画一道弧穿过风流眼,青方一个跳起扑空、一个指着球,同伴摆出亮相 → 全体带一点过冲定住 → 两块小牌顺着线落下 → 灯暗一下 → 成品。全部是真运动(`~` 运动帧),一个叠化都没有;阶段名的约定和阅卷批改一样(`~` 运动帧、`@毫秒` 停留)。重发规则同阅卷批改;调色板 150 色中值切分(成品取样 ×8、饱和像素 ×5、亮色 ×2)+ 105 色只从最后几帧的饱和色和冷色里切,再做 6 轮 k-means 收短误差尾巴;固定 4×4 Bayer。61 帧、10.8 秒、约 1.75 MB,按解码结果逐帧自检,末帧误差(p99 16)和单纯调色板量化相同。点灯那几帧和结尾灯暗一下要整帧重发,是最贵的几帧(各 75–130 KB)。
+- 钢笔淡彩的动图(脚本在 `claude_drawing/penwash_work/make_gif_penwash.py`):阶段是 空桌面 → 四张白卡放下 → 第 1、2 张上墨线 → 第 3、4 张上墨线 → 第一遍淡彩 → 第二遍(鼻子、鞋、细部)→ 背景色块 → 白色水粉高光 → 放下针管笔和水笔,都是 900 毫秒 + 5 帧叠化。橡木桌本身就是饱和色,「饱和像素 ×5」会把色位都给木头,淡蓝 / 灰绿背景块被量化成灰青和米色:调色板改成 56 色只从空桌面切、198 色只从和空桌面不同的像素(卡片、墨线、颜料、笔)切(饱和 ×3、末帧 ×3),固定 4×4 Bayer,和屏上已显示颜色差不到 7 级(叠化帧)/ 4 级(关键帧)的像素沿用上一帧,末帧精确发送。49 帧、13.4 秒、约 0.77 MB,按解码结果逐帧自检,末帧 p99 误差 23。
- 绘本角色动画的动图是真动画,不是阶段叠化:`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 遮罩按顺序显现。这个还没做成现成接口。
@@ -2086,6 +2115,7 @@ lib/overlay.py 描图纸叠层(灯箱发光、黑线灰调底图与单
lib/pastelui.py 粉彩界面(纯色粉彩底与光斑、距离场抗锯齿的窗口卡片与部件、CSS 式多层阴影、带姿态的图层、真像素放大镜、圆形擦除、三个扁平小图标)
lib/grading.py 阅卷批改(绿毛毡桌、带位姿和投影的纸与卡片、答题卡部件与装订齿孔、长尾夹、带进度和时间图的红笔 / 批注 / 作答 / 印章、比尔定律红墨、立体红笔与木章道具)
lib/shadowpuppet.py 皮影戏(油灯照亮的幕布、两个灯芯;按光密度叠加的透明染色驴皮:剪、染、描边、打孔、九种镂空纹样;关节树人偶、线结、操纵杆;离幕虚化与双影;标准人偶(阳刻空脸 / 阴刻脸、雉翎盔 / 三叉冠);牌楼球门、鞠、底部回纹带、小牌;雕花戏台、红漆金字牌匾、灯笼)
+lib/penwash.py 钢笔淡彩(冷压水彩小卡:受光纸纹、不直的切边;针管笔线:手抖、出头、不闭合、描两遍、按 z 遮挡断线;淡彩:错位出线与留白缝、游走的边、干边、颗粒、平刷条纹、湿中湿、起皱;不铺满的背景色块与白边;白色水粉;呆萌小人部件;橡木桌、卡片阴影、针管笔与透明水笔)
examples/*.py 范例脚本;*.jpg 成品;drawing_*.gif 逐步画出的动图
中文字体:自动找 Kaiti/Songti(macOS)、Noto CJK(Linux)、KaiTi/SimSun(Windows),或设 INKPAINT_FONT
西文字体(后来新增的画风用):core.latin_font(style) 按 sans / sans_bold / rounded / script / hand / typewriter 等找系统字体,可用 INKPAINT_FONT_<STYLE> 指定;字体文件不要放进仓库
diff --git a/examples/drawing_penwash_neighbours.gif b/examples/drawing_penwash_neighbours.gif
new file mode 100644
index 0000000..041f174
Binary files /dev/null and b/examples/drawing_penwash_neighbours.gif differ
diff --git a/examples/penwash_neighbours.jpg b/examples/penwash_neighbours.jpg
new file mode 100644
index 0000000..5599a44
Binary files /dev/null and b/examples/penwash_neighbours.jpg differ
diff --git a/examples/penwash_neighbours.py b/examples/penwash_neighbours.py
new file mode 100644
index 0000000..039b644
--- /dev/null
+++ b/examples/penwash_neighbours.py
@@ -0,0 +1,422 @@
+"""Example (pen & wash): 街角速写 · Sketchbook Neighbours — four little fineliner-and-watercolour cards of the
+people on one street corner, photographed lying on an oak table next to the pen and the water brush.
+
+ 1 the postman, whistling, cap and jacket in cobalt; his satchel is so overstuffed that two letters have
+ escaped behind him and are flapping away;
+ 2 a granny with huge round glasses waters her flowerpot -- but the cat has climbed into it, and the drops
+ land on its head (eyes squeezed shut, paws on the rim) while the actual flower waits to the side;
+ 3 a kid kicks along on a scooter, the cobalt helmet (coral stripe) two sizes too big, down to the eyebrows,
+ tongue out in concentration, a plaster on one knee, speed lines and dust puffs behind;
+ 4 a round baker in a tall white toque proudly holds a baguette longer than he is; it pokes out of the inked
+ frame at the top, where a sparrow has landed on the end and is pecking at it.
+
+Each card: quick fineliner lines (wobble, overshooting corners, open gaps, a doubled stroke here and there), then
+loose washes slipped off the lines, a dried darker rim, granulation in the paper tooth, cheeks dropped wet into
+wet, a flat background block that does not fill the card, white gouache glints last.
+--stages writes the draw-on: the bare table, the four blank cards laid down, the ink on cards 1-2 and 3-4, the
+first washes, the second washes, the background blocks, the details (glints, drops), then the fineliner and the
+water brush are put down on the table for the photo.
+No image model.
+python3 penwash_neighbours.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 penwash import PenWash
+
+O, S, T, B = PenWash.oval, PenWash.smooth, PenWash.turn, PenWash.box
+
+
+# ------------------------------------------------------------------ shared little props
+def envelope(pw, cx, cy, w, h, rot, z, airmail=False):
+ """a letter: a box with its flap V; returns the part (and the airmail border dashes if any)"""
+ P = B(cx, cy, w, h, rot)
+ e = pw.part(P, z=z, corners=True, smooth=False)
+ V = T([(cx - w / 2 + 2, cy - h / 2 + 2), (cx, cy + h * 0.08), (cx + w / 2 - 2, cy - h / 2 + 2)], cx, cy, rot)
+ pw.stroke(V, z=z + 0.01, width=pw.width * 0.8, smooth=False, double=0)
+ dashes = []
+ if airmail: # the striped border of an airmail envelope, as little slanted dashes along both long edges
+ dashes = [T(B(cx + (t - 0.5) * w * 0.86, cy + sy * (h / 2 - 2.6), 5.5, 3.0, 35), cx, cy, rot)
+ for t in np.linspace(0.04, 0.96, 8) for sy in (-1, 1)]
+ return e, dashes
+
+
+def note(pw, x, y, s=1.0, z=1e9):
+ """a music note: a filled oval head, a stem and a flag"""
+ pw.dot(x, y, 4.6 * s)
+ pw.stroke([(x + 4 * s, y - 1 * s), (x + 5 * s, y - 26 * s)], z=z, double=0, over=(0, 1))
+ pw.stroke([(x + 5 * s, y - 26 * s), (x + 12 * s, y - 19 * s), (x + 13 * s, y - 12 * s)], z=z, double=0, over=(0, 1))
+
+
+# ================================================================== card 1: the postman
+def postman(pw):
+ P = {}
+ P['hair'] = pw.part([(156, 150), (178, 150), (180, 176), (172, 202), (157, 194), (151, 170)], z=11)
+ P['ear'] = pw.part(O(160, 197, 12, 16), z=9)
+ P['head'] = pw.part(O(228, 180, 66, 72, egg=0.06), z=10)
+ P['crown'] = pw.part(S([(160, 146), (168, 112), (204, 92), (252, 89), (288, 104), (300, 132), (298, 147), (228, 152)], closed=True), z=14)
+ P['band'] = pw.part([(160, 140), (300, 134), (302, 152), (162, 158)], z=15, corners=True, smooth=False)
+ P['visor'] = pw.part(S([(286, 146), (322, 148), (338, 156), (320, 162), (290, 160)], closed=True), z=16)
+ P['badge'] = pw.part(B(268, 145, 16, 11, -3), z=17, corners=True, smooth=False)
+ pw.stroke([(261, 141), (268, 146), (276, 140)], z=17.1, width=2.0, smooth=False, double=0)
+ pw.brows([[(229, 158), (238, 153), (248, 156)], [(266, 153), (275, 149), (284, 152)]], z=13)
+ pw.dot(239, 175, 4.0, z=13); pw.dot(275, 172, 4.0, z=13)
+ P['nose'] = pw.part(O(298, 197, 17, 15, rot=-8), z=13)
+ P['stache'] = pw.part(S([(258, 212), (281, 208), (300, 213), (322, 209), (332, 220), (318, 233), (298, 229),
+ (280, 238), (260, 232), (249, 222)], closed=True), z=14)
+ pw.lines([[(272, 220), (279, 230)], [(292, 219), (298, 228)], [(312, 219), (316, 227)]], z=14.1, width=2.2, double=0)
+ note(pw, 352, 136, 0.9); note(pw, 376, 104, 0.7)
+ # body, strap, bag and its letters
+ P['legB'] = pw.limb([(212, 382), (196, 430), (182, 470)], 30, 24, z=3)
+ P['legF'] = pw.limb([(258, 382), (276, 428), (292, 466)], 30, 24, z=3)
+ P['shoeB'] = pw.part(O(176, 478, 22, 10, rot=-12), z=3.5)
+ P['shoeF'] = pw.part(O(300, 474, 23, 11, rot=6), z=3.5)
+ P['coat'] = pw.part(S([(178, 252), (215, 238), (262, 240), (284, 262), (294, 330), (300, 392), (240, 400),
+ (170, 394), (166, 330)], closed=True), z=5)
+ pw.stroke([(222, 241), (238, 262), (255, 241)], z=5.2, smooth=False)
+ for (x, y) in ((270, 300), (274, 342)): pw.dot(x, y, 2.6, z=5.3)
+ P['strap'] = pw.limb([(264, 246), (226, 300), (186, 352)], 12, 12, z=7, caps=(False, False))
+ P['letters'] = []
+ for (cx, cy, rot, air) in ((118, 301, -20, True), (148, 290, 6, False), (178, 297, 24, False)):
+ e, d = envelope(pw, cx, cy, 40, 27, rot, z=7.5, airmail=air)
+ P['letters'].append(e)
+ if d: P['air1'] = d
+ P['parcel'] = pw.part(B(196, 312, 30, 26, 32), z=7.6, corners=True, smooth=False)
+ pw.stroke(T([(196, 299), (196, 325)], 196, 312, 32), z=7.61, width=2.0, double=0)
+ P['bag'] = pw.part([(100, 316), (196, 308), (204, 402), (108, 410)], z=8, corners=True, smooth=False)
+ pw.stroke([(100, 318), (122, 344), (176, 342), (198, 312)], z=8.1, smooth=True) # the flap that won't close
+ pw.dot(150, 352, 3.0, z=8.2)
+ P['arm'] = pw.limb([(268, 262), (296, 300), (316, 330)], 30, 26, z=9)
+ P['held'], _ = envelope(pw, 342, 356, 38, 26, 18, z=9.5)
+ hand, det = PenWash.hand(318, 334, 62, 28, 'fist')
+ P['hand'] = pw.part(hand, z=10)
+ pw.lines(det, z=10.1, width=2.2, double=0)
+ # escaped letters, flapping away
+ P['fly'] = []
+ for (cx, cy, rot) in ((92, 226, -24), (64, 146, 16)):
+ e, _ = envelope(pw, cx, cy, 36, 25, rot, z=20)
+ P['fly'].append(e)
+ pw.lines([[(108, 248), (120, 262), (136, 268)], [(118, 238), (132, 250), (146, 254)]], width=2.4, double=0)
+ pw.lines([[(84, 166), (100, 176), (114, 178)], [(74, 172), (86, 186), (100, 192)]], width=2.4, double=0)
+ pw.ground(120, 345, 490)
+ pw.signature(388, 506, 7)
+ return P
+
+
+def postman_wash(pw, P, phase):
+ if phase == 1:
+ pw.wash(P['head'], 'skin'); pw.wash(P['ear'], 'skin'); pw.wash(P['hand'], 'skin')
+ pw.bleed(P['head'], 252, 206, 16, 'rose', 0.65); pw.bleed(P['head'], 196, 214, 14, 'rose', 0.45)
+ pw.wash([P['crown'], P['band']], 'cobalt', angle=10)
+ pw.wash(P['coat'], 'cobalt', angle=80); pw.wash(P['arm'], 'cobalt', angle=60)
+ pw.wash([P['legB'], P['legF']], 'grey', 0.95)
+ pw.wash(P['bag'], 'tan', 1.05, angle=95); pw.wash(P['strap'], 'brown', 0.9)
+ elif phase == 2:
+ pw.wash(P['nose'], 'coral', 1.05)
+ pw.wash(P['visor'], 'black', 1.1)
+ pw.wash([P['shoeB'], P['shoeF']], 'black', 1.1)
+ pw.wash(P['hair'], 'warmgrey', 0.7)
+ pw.wash(P['stache'], 'bluegrey', 0.16, gaps=0, edge=0.6)
+ pw.bleed(P['stache'], 292, 236, 22, 'bluegrey', 0.35)
+ pw.wash(P['parcel'], 'ochre', 0.95)
+ for d in P.get('air1', []): pw.wash(d, 'coral', 1.0, slip=(0.3, 0.8), soft=0.6, warp=0.3, gaps=0)
+ pw.bleed(P['bag'], 186, 392, 30, 'brown', 0.5)
+ pw.wash(O(236, 492, 112, 9), 'sage', 0.8, edge=0.6)
+ elif phase == 3:
+ pw.background_block(54, 76, 336, 318, 'yellow', 0.6, rough=6, angle=88)
+ elif phase == 4:
+ pw.glint(292, 190, 3.4); pw.glint(255, 98, 2.2)
+ pw.spatter('yellow', 4, (36, 330, 120, 420), (1.4, 3.2), 0.8)
+
+
+# ================================================================== card 2: granny, a flowerpot and the wrong customer
+def granny(pw):
+ P = {}
+ P['bun'] = pw.part(O(152, 110, 25, 22), z=10.6)
+ P['ear'] = pw.part(O(99, 208, 11, 15), z=9)
+ P['pearl'] = pw.part(O(99, 229, 3.6, 3.6), z=9.5)
+ P['head'] = pw.part(O(160, 194, 64, 68, egg=0.1), z=10)
+ P['hair'] = pw.part(S([(97, 196), (98, 154), (124, 128), (160, 120), (200, 124), (222, 142), (226, 166), (204, 152),
+ (174, 146), (146, 154), (122, 172), (113, 202)], closed=True), z=11)
+ pw.lines([[(130, 140), (150, 136), (168, 140)], [(186, 136), (204, 142)], [(108, 176), (116, 160)]], z=11.1, width=2.2, double=0)
+ la, lb = pw.glasses(170, 198, 24, gap=54, z=12, temple=(108, 196))
+ P['lenses'] = [la, lb]
+ pw.brows([[(160, 165), (172, 161), (183, 164)], [(214, 162), (226, 159), (236, 163)]], z=13)
+ pw.dot(176, 201, 4.0, z=13); pw.dot(229, 199, 4.0, z=13)
+ P['nose'] = pw.part(O(207, 228, 10, 9), z=13)
+ pw.stroke([(188, 247), (200, 253), (213, 247)], z=13, double=0)
+ # body
+ P['legB'] = pw.limb([(140, 440), (138, 474)], 15, 13, z=3)
+ P['legF'] = pw.limb([(196, 440), (200, 474)], 15, 13, z=3)
+ P['shoeB'] = pw.part(O(133, 480, 16, 8), z=3.5)
+ P['shoeF'] = pw.part(O(207, 480, 16, 8, rot=6), z=3.5)
+ P['skirt'] = pw.part(S([(106, 386), (232, 384), (250, 446), (90, 448)], closed=True, per=4), z=4)
+ P['coat'] = pw.part(S([(110, 270), (150, 254), (196, 255), (222, 280), (232, 340), (238, 392), (160, 400),
+ (96, 392), (100, 330)], closed=True), z=5)
+ pw.stroke([(196, 262), (206, 330), (212, 392)], z=5.2)
+ for y in (300, 336, 370): pw.stroke(O(207 + (y - 300) * 0.08, y, 3.6, 3.4), z=5.3, closed=True, width=2.2, double=0)
+ P['collar'] = pw.part(S([(146, 251), (172, 264), (199, 252), (192, 270), (172, 275), (152, 268)], closed=True), z=6)
+ # the watering can, tipped forward to pour; she holds it by the top handle
+ cx, cy, rot = 268, 334, 14
+ P['can'] = pw.part(T(PenWash.rrect(236, 304, 300, 364, 7), cx, cy, rot), z=7, smooth=False)
+ pw.stroke(T([(237, 318), (299, 318)], cx, cy, rot), z=7.1, width=2.4, double=0)
+ P['mouth'] = pw.part(T(O(254, 304, 13, 4), cx, cy, rot), z=7.2, width=2.4)
+ P['spout'] = pw.limb([tuple(T([(294, 352)], cx, cy, rot)[0]), (316, 318), (342, 294)], 10, 7, z=6.9, caps=(False, False))
+ P['rose'] = pw.part(S([(336, 286), (350, 278), (362, 290), (354, 304), (342, 300)], closed=True, per=4), z=7.4)
+ for (x, y) in ((352, 288), (356, 295), (349, 295)): pw.dot(x, y, 1.3, z=7.5)
+ P['handle'] = pw.limb([tuple(T([(242, 306)], cx, cy, rot)[0]), (244, 276), (270, 264), (292, 280),
+ tuple(T([(294, 306)], cx, cy, rot)[0])], 7, 7, z=6.8, caps=(False, False))
+ P['arm'] = pw.limb([(212, 272), (234, 284), (258, 274)], 28, 24, z=8)
+ hand, det = PenWash.hand(258, 274, -14, 26, 'fist')
+ P['hand'] = pw.part(hand, z=10)
+ pw.lines(det, z=10.1, width=2.2, double=0)
+ P['drops'] = []
+ for (x, y, s) in ((356, 312, 1.0), (346, 322, 0.9), (362, 326, 0.85), (350, 335, 0.8), (342, 346, 0.75)):
+ dp = [(x, y - 7 * s), (x + 4 * s, y + 1 * s), (x, y + 5 * s), (x - 4 * s, y + 1 * s)]
+ P['drops'].append(pw.part(S(dp, closed=True, per=4), z=21, width=2.4))
+ # the pot, the cat in it, the flower nobody is watering
+ P['stem'] = pw.limb([(392, 410), (398, 372), (402, 346)], 5, 4, z=5.8, caps=(False, False))
+ P['leaf'] = pw.part(S([(398, 384), (416, 370), (424, 376), (408, 388)], closed=True, per=4), z=5.9)
+ petals = [O(402 + 11 * np.cos(a), 336 + 11 * np.sin(a), 8, 6, rot=np.degrees(a)) for a in np.linspace(0, 2 * np.pi, 6)[:-1] + 0.3]
+ P['petals'] = [pw.part(p, z=6.4, width=2.4) for p in petals]
+ P['bud'] = pw.part(O(402, 336, 5, 5), z=6.5, width=2.4)
+ P['earL'] = pw.part([(314, 372), (318, 340), (338, 360)], z=4.4, corners=True, smooth=False)
+ P['earR'] = pw.part([(350, 358), (370, 342), (374, 370)], z=4.4, corners=True, smooth=False)
+ P['cat'] = pw.part(O(343, 388, 35, 32), z=4.5)
+ pw.lines([[(326, 380), (335, 385), (326, 390)], [(362, 379), (353, 384), (362, 389)]], z=4.6, width=2.6, double=0, over=(0, 1))
+ pw.lines([[(338, 397), (343, 400), (348, 397)], [(312, 394), (296, 391)], [(313, 400), (297, 403)],
+ [(373, 393), (390, 389)], [(372, 399), (389, 402)]], z=4.6, width=2.0, double=0)
+ pw.lines([[(318, 352), (322, 346)], [(366, 350), (370, 345)]], z=4.6, width=2.0, double=0)
+ P['pot'] = pw.part([(296, 422), (396, 422), (384, 488), (308, 488)], z=5, corners=True, smooth=False)
+ P['rim'] = pw.part([(286, 404), (406, 403), (407, 424), (285, 425)], z=6, corners=True, smooth=False)
+ P['paws'] = [pw.part(O(322, 408, 10, 7), z=6.5, width=2.6), pw.part(O(364, 407, 10, 7), z=6.5, width=2.6)]
+ pw.ground(70, 420, 488)
+ pw.signature(412, 508, 7)
+ return P
+
+
+def granny_wash(pw, P, phase):
+ if phase == 1:
+ pw.wash(P['head'], 'skin'); pw.wash(P['ear'], 'skin'); pw.wash(P['hand'], 'skin')
+ pw.bleed(P['head'], 132, 226, 15, 'rose', 0.7); pw.bleed(P['head'], 214, 222, 12, 'rose', 0.55)
+ pw.wash(P['coat'], 'coral', angle=75); pw.wash(P['arm'], 'coral', angle=40)
+ pw.wash(P['skirt'], 'teal', 0.95, angle=95)
+ pw.wash(P['can'], 'sky', 1.05, angle=20); pw.wash([P['spout'], P['rose'], P['handle']], 'sky', 1.0)
+ pw.wash(P['mouth'], 'cobalt', 0.6, slip=(0.5, 1.0))
+ pw.wash(P['cat'], 'ochre'); pw.wash([P['earL'], P['earR']], 'ochre'); pw.wash(P['paws'], 'ochre')
+ pw.wash([P['pot'], P['rim']], 'terracotta', 0.95, angle=92)
+ elif phase == 2:
+ pw.wash([P['hair'], P['bun']], 'bluegrey', 0.55)
+ pw.wash(P['nose'], 'rose', 0.9)
+ pw.wash([P['legB'], P['legF']], 'tan', 0.8)
+ pw.wash([P['shoeB'], P['shoeF']], 'black', 1.1)
+ pw.wash(P['drops'], 'cobalt', 0.8, slip=(0.5, 1.5), gaps=0.5)
+ pw.wash(P['petals'], 'red', 1.0); pw.wash(P['bud'], 'yellow', 1.0)
+ pw.wash([P['stem'], P['leaf']], 'green', 0.9)
+ pw.bleed(P['cat'], 352, 404, 14, 'peach', 0.5)
+ pw.bleed(P['pot'], 300, 470, 26, 'brown', 0.45)
+ pw.wash(O(250, 490, 140, 8), 'sage', 0.75, edge=0.6)
+ elif phase == 3:
+ pw.background_block(52, 64, 338, 296, 'sky', 0.72, rough=6, angle=94)
+ elif phase == 4:
+ for (x, y) in ((162, 190), (216, 188)): pw.highlight([(x - 7, y + 3), (x - 3, y - 6)], 2.4, 0.85)
+ pw.glint(203, 224, 2.0); pw.glint(248, 322, 2.4)
+ pw.highlight([(250, 340), (254, 362)], 2.4, 0.6)
+
+
+# ================================================================== card 3: a kid on a scooter, helmet two sizes too big
+def scooter(pw):
+ P = {}
+ # scooter
+ P['wheelB'] = pw.part(O(130, 392, 16, 16), z=7)
+ P['wheelF'] = pw.part(O(362, 392, 16, 16), z=7)
+ for x in (130, 362): pw.dot(x, 392, 3.0, z=7.1)
+ P['deck'] = pw.part(S([(112, 368), (330, 366), (338, 380), (112, 382)], closed=True, per=3), z=8, nseg=2)
+ P['fork'] = pw.part([(346, 372), (360, 374), (368, 394), (356, 396)], z=8.5, corners=True, smooth=False)
+ P['stem'] = pw.limb([(354, 380), (350, 300), (344, 212)], 10, 9, z=9, caps=(False, False))
+ P['bar'] = pw.limb([(330, 206), (346, 212), (360, 220)], 8, 8, z=12)
+ P['grip'] = pw.part(O(330, 205, 7, 6), z=12.2, width=2.4)
+ # kid
+ P['legB'] = pw.limb([(232, 334), (198, 352), (166, 344)], 18, 15, z=7.5)
+ P['shoeB'] = pw.part(O(154, 342, 18, 10, rot=-14), z=7.6)
+ P['legF'] = pw.limb([(262, 334), (264, 350), (268, 362)], 18, 16, z=8.6)
+ P['plaster'] = pw.part(B(265, 350, 16, 8, 14), z=8.7, corners=True, smooth=False, width=2.2)
+ P['shoeF'] = pw.part(O(276, 365, 19, 9, rot=3), z=8.8)
+ pw.stroke([(260, 366), (292, 366)], z=8.9, width=2.0, double=0)
+ P['shorts'] = pw.part(S([(214, 306), (282, 302), (288, 340), (256, 345), (248, 332), (220, 342)], closed=True, per=4), z=9)
+ P['shirt'] = pw.part(S([(206, 250), (254, 238), (284, 256), (284, 310), (220, 316), (206, 290)], closed=True), z=10)
+ P['arm'] = pw.limb([(266, 260), (302, 254), (330, 214)], 13, 12, z=11)
+ P['sleeve'] = pw.part(S([(252, 250), (276, 242), (286, 262), (266, 272)], closed=True, per=4), z=11.5)
+ hand, det = PenWash.hand(330, 216, -64, 18, 'fist')
+ P['hand'] = pw.part(hand, z=13)
+ P['ear'] = pw.part(O(188, 216, 10, 12), z=11.5)
+ P['head'] = pw.part(O(240, 204, 56, 48), z=12)
+ P['helmet'] = pw.part(S([(144, 206), (146, 150), (180, 106), (232, 86), (286, 96), (318, 128), (328, 164),
+ (344, 184), (330, 198), (292, 202), (248, 206), (190, 216)], closed=True), z=14)
+ P['stripe'] = pw.part(S([(178, 112), (228, 90), (258, 92), (234, 110), (198, 130), (166, 154), (158, 140)], closed=True), z=15, ink=False)
+ P['vents'] = [pw.part(O(x, y, 11, 4.2, rot=a), z=15.1, width=2.4) for (x, y, a) in ((256, 116, 20), (282, 132, 36), (300, 156, 54))]
+ pw.stroke([(206, 210), (226, 236), (256, 252)], z=13.5, width=2.4, double=0)
+ pw.tufts(176, 216, n=3, length=11, spread=50, angle=160, z=11.8)
+ pw.dot(256, 216, 3.9, z=13); pw.dot(282, 214, 3.9, z=13)
+ P['nose'] = pw.part(O(297, 225, 7, 6), z=13, width=2.6)
+ pw.stroke([(264, 239), (278, 237)], z=13, width=2.6, double=0)
+ P['tongue'] = pw.part(O(280, 243, 5.5, 5, rot=20), z=13.2, width=2.4)
+ # speed lines and dust
+ pw.lines([[(44, 246), (104, 244)], [(30, 280), (86, 278)], [(54, 314), (110, 312)], [(80, 224), (112, 223)]], width=2.6, double=0)
+ for (x, y, r) in ((92, 384, 13), (68, 374, 10), (50, 388, 8)):
+ pw.stroke(O(x, y, r, r * 0.8, wob=0.25, seed=int(x)), closed=True, width=2.4)
+ pw.ground(60, 420, 410)
+ pw.signature(440, 426, 7)
+ return P
+
+
+def scooter_wash(pw, P, phase):
+ if phase == 1:
+ pw.wash(P['head'], 'skin'); pw.wash(P['ear'], 'skin'); pw.wash(P['hand'], 'skin')
+ pw.wash([P['legB'], P['legF'], P['arm']], 'skin')
+ pw.bleed(P['head'], 250, 234, 13, 'rose', 0.7)
+ pw.wash(P['helmet'], 'cobalt', 1.0, angle=30)
+ pw.wash([P['shirt'], P['sleeve']], 'yellow', 1.0, angle=70)
+ pw.wash(P['shorts'], 'coral', 1.0)
+ pw.wash([P['deck'], P['stem'], P['fork'], P['bar']], 'teal', 1.0, angle=5)
+ pw.wash(P['stripe'], 'coral', 0.95, slip=(1, 2))
+ elif phase == 2:
+ pw.wash([P['wheelB'], P['wheelF']], 'grey', 1.0)
+ pw.wash([P['shoeB'], P['shoeF']], 'black', 0.9)
+ pw.wash(P['vents'] + [P['grip']], 'black', 1.2, slip=(0.3, 0.8))
+ pw.wash(P['tongue'], 'coral', 1.0, slip=(0.4, 1.0), gaps=0.4); pw.wash(P['nose'], 'rose', 0.9, slip=(0.4, 1.0), gaps=0.4)
+ pw.bleed(P['helmet'], 300, 176, 30, 'cobalt', 0.45)
+ pw.wash(O(226, 408, 140, 8), 'warmgrey', 0.7, edge=0.6)
+ elif phase == 3:
+ pw.background_block(36, 80, 352, 352, 'sage', 0.85, rough=7, angle=0)
+ elif phase == 4:
+ pw.glint(204, 120, 2.6); pw.glint(295, 222, 1.6)
+
+
+# ================================================================== card 4: the baker's baguette (and its first customer)
+def baker(pw):
+ P = {}
+ pw.frame(42, 124, 380, 506)
+ P['ear'] = pw.part(O(258, 240, 12, 15), z=9)
+ P['head'] = pw.part(O(190, 236, 68, 66, egg=0.12), z=10)
+ P['toque'] = pw.part(S([(130, 170), (112, 140), (120, 104), (148, 92), (162, 70), (192, 62), (216, 74), (242, 72),
+ (264, 94), (264, 128), (252, 162)], closed=True), z=14)
+ pw.lines([[(160, 100), (166, 130)], [(208, 96), (212, 132)]], z=14.1, width=2.2, double=0)
+ P['band'] = pw.part([(126, 158), (254, 152), (256, 178), (128, 184)], z=15, corners=True, smooth=False)
+ la, lb = pw.glasses(156, 232, 22, gap=48, z=12, temple=(252, 230))
+ P['lenses'] = [la, lb]
+ pw.brows([[(146, 200), (158, 196), (168, 199)], [(194, 198), (206, 194), (216, 197)]], z=13)
+ pw.dot(158, 235, 3.9, z=13); pw.dot(205, 233, 3.9, z=13)
+ P['nose'] = pw.part(O(181, 260, 16, 14), z=13)
+ P['stacheL'] = pw.limb([(178, 274), (156, 278), (138, 270), (134, 258)], 11, 3, z=14)
+ P['stacheR'] = pw.limb([(184, 274), (206, 278), (224, 270), (229, 258)], 11, 3, z=14)
+ pw.stroke([(168, 290), (181, 296), (194, 290)], z=13, double=0)
+ # body: a round cobalt shirt, a white bib apron, short legs under it
+ P['shoeL'] = pw.part(O(152, 500, 22, 9), z=2)
+ P['shoeR'] = pw.part(O(240, 500, 22, 9), z=2)
+ P['body'] = pw.part(O(198, 404, 104, 98, egg=0.08), z=5)
+ for y in (330, 356): pw.dot(150, y, 2.6, z=5.1); pw.dot(248, y + 2, 2.6, z=5.1)
+ P['apron'] = pw.part([(166, 326), (230, 324), (232, 372), (264, 384), (268, 488), (130, 490), (132, 386), (164, 374)],
+ z=6, corners=True, smooth=False)
+ pw.lines([[(166, 328), (176, 302)], [(230, 326), (220, 302)], [(132, 386), (110, 392)], [(264, 384), (288, 390)]], z=6.1, width=2.4)
+ pw.stroke([(182, 430), (180, 462), (224, 462), (226, 430)], z=6.2, width=2.6, smooth=False, corners=True)
+ P['scarf'] = pw.part(S([(166, 298), (214, 298), (200, 318), (190, 312), (182, 320)], closed=True, per=4), z=8)
+ P['armL'] = pw.limb([(110, 352), (108, 420), (128, 452)], 30, 26, z=9)
+ P['armR'] = pw.limb([(288, 342), (292, 372), (244, 378)], 28, 24, z=9)
+ # the baguette, hugged diagonally and poking out of the frame; a sparrow on the end
+ a0, a1 = np.array([140.0, 490.0]), np.array([356.0, 104.0])
+ P['loaf'] = pw.limb([tuple(a0), tuple((a0 + a1) / 2), tuple(a1)], 36, 32, z=12, caps=(True, True))
+ cuts = []
+ for t in np.linspace(0.10, 0.86, 7):
+ cx, cy = a0 + (a1 - a0) * t
+ cuts.append([(cx - 13, cy + 4), (cx + 2, cy - 7), (cx + 13, cy - 12)])
+ P['cuts'] = cuts
+ pw.lines(cuts, z=12.1, width=2.4, double=0, over=(0, 1))
+ hl, d1 = PenWash.hand(128, 452, -6, 30, 'fist')
+ hr, d2 = PenWash.hand(244, 378, 186, 30, 'fist', flip=True)
+ P['hands'] = [pw.part(hl, z=13), pw.part(hr, z=13)]
+ pw.lines(d1 + d2, z=13.1, width=2.2, double=0)
+ P['tail'] = pw.part([(384, 70), (406, 56), (404, 70)], z=19.5, corners=True, smooth=False, width=2.6)
+ P['bird'] = pw.part(S([(352, 76), (362, 64), (382, 64), (394, 76), (384, 88), (360, 90)], closed=True), z=20)
+ P['bhead'] = pw.part(O(350, 76, 11, 10), z=20.5)
+ P['beak'] = pw.part([(340, 80), (343, 92), (348, 84)], z=20.6, corners=True, smooth=False, width=2.2)
+ pw.dot(348, 73, 2.2, z=21)
+ pw.stroke([(368, 72), (382, 74), (388, 82)], z=20.6, width=2.2, double=0)
+ pw.lines([[(366, 90), (364, 96)], [(374, 90), (374, 96)]], z=19, width=2.0, double=0)
+ P['crumbs'] = [pw.part(O(x, y, 2.6, 2.2), z=21, width=1.8) for (x, y) in ((316, 116), (306, 132), (304, 150))]
+ pw.signature(392, 528, 7)
+ return P
+
+
+def baker_wash(pw, P, phase):
+ if phase == 1:
+ pw.wash(P['head'], 'skin'); pw.wash(P['ear'], 'skin'); pw.wash(P['hands'], 'skin')
+ pw.bleed(P['head'], 140, 262, 16, 'rose', 0.65); pw.bleed(P['head'], 226, 258, 14, 'rose', 0.55)
+ pw.wash(P['apron'], 'cobalt', 0.95, angle=80)
+ pw.wash(P['loaf'], 'ochre', 1.05, angle=62)
+ elif phase == 2:
+ pw.wash(P['nose'], 'coral', 1.05)
+ pw.wash([P['stacheL'], P['stacheR']], 'black', 0.9, slip=(0.5, 1.2))
+ pw.wash(P['scarf'], 'coral', 1.0)
+ pw.wash([P['shoeL'], P['shoeR']], 'black', 1.0)
+ pw.bleed(P['loaf'], 318, 150, 60, 'brown', 0.55); pw.bleed(P['loaf'], 150, 450, 40, 'brown', 0.4)
+ pw.wash([P['bird'], P['bhead'], P['tail']], 'brown', 0.75); pw.wash(P['beak'], 'yellow', 1.0)
+ pw.bleed(P['bird'], 364, 62, 9, 'warmgrey', 0.8)
+ pw.wash(P['crumbs'], 'ochre', 1.0, slip=(0.3, 0.8))
+ pw.wash([P['toque'], P['band']], 'bluegrey', 0.20, gaps=0, edge=0.5)
+ pw.bleed(P['toque'], 250, 120, 30, 'bluegrey', 0.4)
+ pw.wash([P['body'], P['armL'], P['armR']], 'bluegrey', 0.13, gaps=0, edge=0.6)
+ pw.bleed(P['body'], 286, 420, 40, 'bluegrey', 0.4); pw.bleed(P['armR'], 292, 380, 20, 'bluegrey', 0.4)
+ elif phase == 3:
+ pw.background_block(46, 128, 376, 502, 'teal', 0.8, rough=4, corner=6, halo=3.5, angle=92)
+ elif phase == 4:
+ for c in P['cuts']: pw.highlight([(x + 2, y + 3) for (x, y) in c], 2.2, 0.8)
+ pw.glint(174, 254, 3.0)
+ for k in range(3): pw.highlight([(200 + 9 * k, 400 + 4 * k), (206 + 9 * k, 420 + 3 * k)], 3.4, 0.55)
+ for (x, y) in ((150, 224), (198, 222)): pw.highlight([(x - 6, y + 2), (x - 2, y - 6)], 2.2, 0.85)
+ pw.spatter('coral', 4, (300, 440, 410, 540), (0.8, 2.0))
+
+
+# ================================================================== the photo
+CARDS = [ # (cx, cy, w, h, rot, corner, draw, wash)
+ (250, 424, 420, 540, -4.0, 3.0, postman, postman_wash),
+ (706, 494, 440, 530, 2.6, 9.0, granny, granny_wash),
+ (1172, 404, 470, 450, -2.2, 14.0, scooter, scooter_wash),
+ (1652, 470, 420, 550, 3.4, 4.0, baker, baker_wash),
+]
+
+
+def main():
+ out = sys.argv[1] if len(sys.argv) > 1 and not sys.argv[1].startswith('--') else 'penwash_neighbours.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:16s} {time.time() - T0:5.1f}s')) if os.environ.get('PW_TIMING') else (lambda name: None)
+ pw = PenWash(1920, 1080, seed=21, keep_stages=bool(stages), stages_dir=stages)
+ pw.table('oak')
+ pw.stage('table')
+ cards, parts = [], []
+ for k, (cx, cy, w, h, rot, corner, draw, _) in enumerate(CARDS):
+ cards.append(pw.card(cx, cy, w, h, rot=rot, corner=corner, seed=100 + k))
+ pw.stage('cards')
+ for k, c in enumerate(cards):
+ pw.use(c)
+ parts.append(CARDS[k][6](pw))
+ pw.ink()
+ tick(f'ink {k}')
+ if k in (1, 3): pw.stage(f'ink_{k - 1}{k}')
+ for phase, name in ((1, 'washes'), (2, 'more_washes'), (3, 'background'), (4, 'details')):
+ for k, c in enumerate(cards):
+ pw.use(c)
+ CARDS[k][7](pw, parts[k], phase)
+ tick(name)
+ pw.stage(name)
+ pw.pen(706, 868, 166, length=640, r=16)
+ pw.water_brush(1052, 744, 19, length=600, r=24, cap=(1700, 960, -14))
+ tick('tools')
+ img = pw.save(out, stages_dir=stages)
+ tick('saved')
+ print('saved', out)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/lib/penwash.py b/lib/penwash.py
new file mode 100644
index 0000000..d754d2e
--- /dev/null
+++ b/lib/penwash.py
@@ -0,0 +1,1107 @@
+"""penwash — 钢笔淡彩 / Pen & Wash: little fineliner-and-watercolour sketch cards on a table (numpy + Pillow only).
+
+A sketcher's habit: a stack of small cold-press watercolour cards, a waterproof fineliner and a water brush. On each
+card one goofy character is drawn quickly in ink (big head, round glasses, dot eyes, a red nose, a little body), then
+loose washes go on top, and the cards are photographed lying on the table next to the pen and the brush.
+
+ card Each card is its own sheet with its own buffers, drawn in card units (= canvas px) *as if unrotated*, at
+ `ss` x internal resolution, and laid on the table at a position and a small angle when the photo is
+ composed. Cold-press paper: a height field of ~1 mm bumps (2-4 px here) on a softer undulation, lit by
+ the window light from the upper left, so the tooth reads as tooth and not as noise; a warm white tone
+ with faint mottle. The edge is a guillotine cut that is not quite straight (a sub-pixel wobble and fuzz),
+ corners square or a little rounded.
+ ink A fineliner lays a near-uniform line (felt tip, pigment ink): every stroke is the drawn path re-sampled
+ and pushed sideways by low-frequency hand wobble plus a little tremor, its width drifting +-9 %, a small
+ blob where the tip rested before moving, and on some strokes a quick thinning flick at the end. It is
+ drawn fast, so closed shapes are not closed: a head is one to three strokes that either stop short (an
+ open gap) or run past the join and leave the curve on its tangent (crossing tails); corners of boxes are
+ separate strokes that overshoot. Now and then part of a stroke is gone over again 1-2.5 px off (a doubled
+ line). The ink is Beer-Lambert density (nearly black at one pass), with the deepest valleys of the tooth
+ barely skipped. A part's outline is hidden where a part in front covers it (z order), so a sleeve's line
+ stops at the coat and the ears tuck behind the head.
+ wash Watercolour / gouache is laid loosely after the ink (the ink is waterproof): a wash is the *intended*
+ region (a part minus whatever is in front of it), then painted the way a quick hand paints it:
+ misregistration the whole wash slips 2-5 px one way, so colour runs over the line on one side and
+ leaves a white paper gap inside the line on the other;
+ edge the edge is re-found on a blurred copy with a threshold that wanders (low-frequency
+ noise in px: spill where negative, pull back where positive, plus patches pulled
+ back from the line), so the edge is crisp but wobbly and follows the paper tooth;
+ wet edge pigment migrates to the rim of a drying puddle: a darker rim just inside the edge;
+ granulation pigment settles into the valleys of the tooth: speckle tied to the paper itself;
+ streaks the flat brush leaves faint parallel streaks along its direction;
+ variation a puddle is never even: low-frequency density mottle;
+ dry brush on request the brush skips the tooth peaks (white specks at a dragged edge);
+ bleed colour dropped into a wash that is still wet spreads softly and stops at the wet
+ edge (cheeks into skin, a warm-to-cool gradient on a face);
+ cockle paper buckles where it got wet: a faint low relief in the photo light.
+ Pigments are kept as density too (absorbance = -ln(masstone)), so overlaps darken and mix like paint.
+ A background block is a rough flat wash rectangle that does not fill the card: wobbly brushed sides and
+ corners, painted around the figure (the figure is reserved with a halo of a few px, so white paper
+ shows between figure and block in places). White gouache (`highlight`, `glint`) is opaque and goes on
+ last: glints on glasses, a shine on a nose or a loaf.
+ photo The cards lie on a table (`table`: oak planks with growth-ring grain, pores, seams and a satin sheen, or
+ linen) under one window light from the upper left. Each card casts a soft offset shadow and a tight
+ contact shadow; its cut edge catches the light on the lit side and darkens on the other. Tools are
+ shaded cylinders with their own cast shadows: a fineliner (fibre tip, metal sleeve, grey cone, matte
+ barrel with its size printed on it, posted glossy cap with a clip) and a water brush (black nylon tip
+ stained with paint, ribbed grip, a clear barrel of water that refracts what is under it, with a bubble,
+ and its clear cap). Then the camera: light fall-off away from the window, a vignette, a warm white
+ balance and fine sensor grain.
+
+API (card units are canvas px on the unturned card; z orders parts, higher is in front):
+ surface table(kind='oak'|'pale'|'walnut'|'linen'); card(cx, cy, w, h, rot, tone, corner) lays a blank card and
+ makes it current, use(card) switches
+ drawing part(pts, z, strokes=None, corners=False, smooth=True, reserve=True) a region + its outline;
+ limb(pts, w0, w1, z, caps) a sleeve / leg / strap; stroke(pts, z, width, closed, corners, double, over);
+ lines(paths); dot(x, y, r); glasses(cx, cy, r, gap, z, temple); brows(paths); tufts(x, y, n, length);
+ frame(x0, y0, x1, y1); ground(x0, x1, y); signature(x, y); ink() inks everything pending
+ shapes PenWash.oval(cx, cy, rx, ry, rot, egg, wob), rrect, box(cx, cy, w, h, rot), turn(pts, cx, cy, deg),
+ smooth(pts, closed), tube(pts, w0, w1) -> (outline, sides), hand(x, y, angle, size, 'mitten'|'open'|'fist')
+ paint wash(target, colour, strength, shift, slip, warp, gaps, soft, edge, gran, streak, angle, var, dry);
+ bleed(target, x, y, r, colour, strength); background_block(x0, y0, x1, y1, colour, rough, corner, halo);
+ spatter(colour, n, box, size); highlight(pts, width) and glint(x, y, r) in white gouache. Colours are
+ names in PAINTS or '#rrggbb'.
+ photo pen(x, y, angle, length, r); water_brush(x, y, angle, length, r, stain, cap=(x, y, angle));
+ stage(name); save(path, stages_dir)
+
+ import sys; sys.path.insert(0, 'lib')
+ from penwash import PenWash
+ pw = PenWash(1920, 1080, seed=3)
+ pw.table('oak')
+ pw.card(960, 540, 420, 520, rot=-3) # lays a blank card and makes it current
+ head = pw.part(PenWash.oval(210, 200, 70, 78), z=10) # an outline that will be inked
+ lens = pw.glasses(196, 205, 24, gap=50, z=12)
+ pw.dot(196, 207, 3.8, z=13); pw.dot(246, 205, 3.8, z=13)
+ nose = pw.part(PenWash.oval(222, 238, 14, 12), z=13)
+ coat = pw.part(PenWash.smooth([(150, 270), (275, 268), (300, 450), (128, 452)], closed=True), z=4)
+ pw.ink(); pw.stage('ink')
+ pw.wash(head, 'skin'); pw.bleed(head, 175, 245, 18, 'pink'); pw.wash(nose, 'coral'); pw.wash(coat, 'cobalt')
+ pw.background_block(60, 90, 330, 380, 'mint'); pw.stage('wash')
+ pw.pen(400, 990, 160); pw.save('penwash.jpg')
+"""
+import io
+import os
+from types import SimpleNamespace
+import numpy as np
+from PIL import Image, ImageDraw
+from core import blur, fbm1d, spline, noise2d, smoothstep, load_font
+from core import shift as _move
+
+
+def hexc(h):
+ if not isinstance(h, str): return np.asarray(h, np.float32)
+ h = h.lstrip('#')
+ return np.array([int(h[i:i + 2], 16) for i in (0, 2, 4)], np.float32) / 255
+
+
+# masstone of each paint at strength 1 on white paper (absorbance = -ln(masstone), so strength scales density)
+PAINTS = {
+ 'coral': '#ee4a3b', 'red': '#de3a2e', 'pink': '#f19a92', 'rose': '#ec7f80', 'peach': '#f5bc9c',
+ 'skin': '#f2c7a2', 'tan': '#e3ad7c', 'ochre': '#e2a656', 'yellow': '#f3cb52', 'brown': '#a8723f',
+ 'terracotta': '#d0724a', 'teal': '#3ea98b', 'mint': '#a3d5bd', 'sage': '#a7bc9f', 'green': '#5aa064',
+ 'cobalt': '#3c6ec4', 'sky': '#93b9df', 'bluegrey': '#9db0c3', 'grey': '#94979b', 'warmgrey': '#aaa197',
+ 'black': '#2c2c30', 'lilac': '#b3a3d3',
+}
+INK = '#141518'
+PAPER = '#f7f4ec'
+WOODS = {'oak': ('#cf9f66', '#93633a'), 'pale': ('#dcc29a', '#a98457'), 'walnut': ('#8a5d3b', '#4e321f')}
+LINEN = '#cfc6b6'
+SHADOW = np.array([0.20, 0.16, 0.13], np.float32) # shadow tint (warm, multiplies)
+
+
+def _closed_spline(P, per=6):
+ P = np.asarray(P, np.float32)
+ n = len(P)
+ t = np.linspace(0, 1, per, endpoint=False, dtype=np.float32)[:, None]
+ t2, t3 = t * t, t * t * t
+ out = []
+ for i in range(n):
+ p0, p1, p2, p3 = P[(i - 1) % n], P[i], P[(i + 1) % n], P[(i + 2) % n]
+ out.append(0.5 * ((2 * p1) + (-p0 + p2) * t + (2 * p0 - 5 * p1 + 4 * p2 - p3) * t2 + (-p0 + 3 * p1 - 3 * p2 + p3) * t3))
+ return np.concatenate(out).astype(np.float32)
+
+
+def _resample(P, step, closed=False):
+ P = np.asarray(P, np.float32)
+ if closed: P = np.vstack([P, P[:1]])
+ seg = np.hypot(*np.diff(P, axis=0).T)
+ s = np.concatenate([[0], np.cumsum(seg)])
+ L = float(s[-1])
+ if L < 1e-6: return P[:1].copy()
+ n = max(2, int(np.ceil(L / step)) + 1)
+ u = np.linspace(0, L, n)
+ Q = np.stack([np.interp(u, s, P[:, 0]), np.interp(u, s, P[:, 1])], 1).astype(np.float32)
+ return Q[:-1] if closed else Q
+
+
+def _extend(Q, e0, e1):
+ """open path: positive e runs past the end on the tangent (overshoot), negative stops short (gap)"""
+ Q = np.asarray(Q, np.float32)
+ if len(Q) < 4: return Q
+ if e1 < 0: Q = Q[:max(3, len(Q) - int(-e1))]
+ if e0 < 0: Q = Q[min(len(Q) - 3, int(-e0)):]
+ if e1 > 0:
+ d = Q[-1] - Q[-min(4, len(Q))]; d /= (np.linalg.norm(d) + 1e-6)
+ k = np.arange(1, int(e1) + 1, dtype=np.float32)[:, None]
+ Q = np.vstack([Q, Q[-1] + d * k])
+ if e0 > 0:
+ d = Q[0] - Q[min(3, len(Q) - 1)]; d /= (np.linalg.norm(d) + 1e-6)
+ k = np.arange(int(e0), 0, -1, dtype=np.float32)[:, None]
+ Q = np.vstack([Q[0] + d * k, Q])
+ return Q
+
+
+def _corners(P, closed, thr=48.0):
+ """split a polyline at sharp corners (turning angle > thr degrees)"""
+ P = np.asarray(P, np.float32)
+ n = len(P)
+ idx = []
+ rng_ = range(n) if closed else range(1, n - 1)
+ for i in rng_:
+ a, b, c = P[(i - 1) % n], P[i], P[(i + 1) % n]
+ u, v = b - a, c - b
+ nu, nv = np.linalg.norm(u), np.linalg.norm(v)
+ if nu < 1e-6 or nv < 1e-6: continue
+ ang = np.degrees(np.arccos(np.clip((u @ v) / (nu * nv), -1, 1)))
+ if ang > thr: idx.append(i)
+ if not idx:
+ return [np.vstack([P, P[:1]])] if closed else [P]
+ segs = []
+ if closed:
+ for k in range(len(idx)):
+ a, b = idx[k], idx[(k + 1) % len(idx)]
+ if b <= a: b += n
+ segs.append(P[np.arange(a, b + 1) % n])
+ else:
+ cut = [0] + idx + [n - 1]
+ for a, b in zip(cut[:-1], cut[1:]): segs.append(P[a:b + 1])
+ return segs
+
+
+def _inter(a, b):
+ """overlap of two (slice_y, slice_x) boxes -> (sub-slices of a, sub-slices of b) or None"""
+ y0, y1 = max(a[0].start, b[0].start), min(a[0].stop, b[0].stop)
+ x0, x1 = max(a[1].start, b[1].start), min(a[1].stop, b[1].stop)
+ if y1 <= y0 or x1 <= x0: return None
+ return ((slice(y0 - a[0].start, y1 - a[0].start), slice(x0 - a[1].start, x1 - a[1].start)),
+ (slice(y0 - b[0].start, y1 - b[0].start), slice(x0 - b[1].start, x1 - b[1].start)))
+
+
+def _bilinear(img, fx, fy):
+ """sample img (h, w, c) at float pixel coords (pixel centres at integers); outside -> 0"""
+ h, w = img.shape[:2]
+ x0 = np.floor(fx).astype(np.int32); y0 = np.floor(fy).astype(np.int32)
+ ax = (fx - x0).astype(np.float32)[..., None]; ay = (fy - y0).astype(np.float32)[..., None]
+ out = np.zeros(fx.shape + (img.shape[2],), np.float32)
+ for dy, wy in ((0, 1 - ay), (1, ay)):
+ for dx, wx in ((0, 1 - ax), (1, ax)):
+ xi, yi = x0 + dx, y0 + dy
+ ok = (xi >= 0) & (xi < w) & (yi >= 0) & (yi < h)
+ v = img[np.clip(yi, 0, h - 1), np.clip(xi, 0, w - 1)]
+ out += v * (wx * wy) * ok[..., None]
+ return out
+
+
+class PenWash:
+ PAINTS = PAINTS
+
+ def __init__(self, W=1920, H=1080, seed=0, ss=2, keep_stages=True, stages_dir=None):
+ self.W, self.H, self.ss = W, H, ss
+ self.rng = np.random.default_rng(seed)
+ self.keep_stages, self.stages_dir = keep_stages, stages_dir
+ self.stages, self._n_stages = [], 0
+ self.surface = np.full((H, W, 3), 0.75, np.float32)
+ self.cards, self.cur = [], None
+ self.tools = []
+ self.ld = np.array([0.55, 0.83], np.float32) # direction the window light travels (to lower right)
+ self.ink_abs = -np.log(hexc(INK))
+ self.width = 3.3 # default fineliner width, canvas px
+ YY, XX = np.mgrid[0:H, 0:W].astype(np.float32)
+ g = (0.55 * XX / W + 0.83 * YY / H) / 1.38
+ rr = np.hypot((XX - W * 0.42) / (W * 0.75), (YY - H * 0.40) / (H * 0.78))
+ self._light = (1.06 - 0.17 * smoothstep(0.05, 1.05, g) - 0.13 * smoothstep(0.45, 1.25, rr)).astype(np.float32)
+ self._grain = np.random.default_rng(seed + 991).normal(0, 1, (H, W)).astype(np.float32)
+ self._grain = 0.7 * self._grain + 0.3 * blur(self._grain, 0.8) * 2.2
+ self.warm = np.array([1.025, 1.0, 0.95], np.float32)
+
+ def _seed(self):
+ return int(self.rng.integers(1 << 30))
+
+ # ================================================================== table
+ def table(self, kind='oak', plank=176, seed=None):
+ """the surface the cards lie on: 'oak' / 'pale' / 'walnut' planks, or 'linen' cloth"""
+ H, W = self.H, self.W
+ r = np.random.default_rng(self._seed() if seed is None else seed)
+ if kind == 'linen':
+ self.surface = self._linen(r); return
+ lite, dark = (hexc(c) for c in WOODS[kind])
+ YY = np.arange(H, dtype=np.float32)[:, None]
+
+ def streaks(sy, sx, rows): # noise stretched along the board: sy px across, sx px along
+ g = r.random((int(rows / sy) + 3, int(W / sx) + 3)).astype(np.float32)
+ return np.asarray(Image.fromarray(g).resize((W, rows), Image.BICUBIC), np.float32)
+
+ def board(rows):
+ """one board's colour mix 0..1 (growth rings with cathedral arches, fibres, pores)"""
+ fine, mid, broad, pores, warp = (streaks(1.3, 60, rows), streaks(5, 260, rows), streaks(45, 700, rows),
+ streaks(1.0, 9, rows), streaks(70, 520, rows))
+ yy = np.arange(rows, dtype=np.float32)[:, None]
+ XX = np.arange(W, dtype=np.float32)[None, :]
+ period = r.uniform(6, 12)
+ ph = yy + r.uniform(20, 60) * (warp - 0.5) + 9 * (mid - 0.5)
+ for _ in range(int(r.integers(1, 3))): # flat-sawn boards: nested 'cathedral' arches
+ xc, wc = r.uniform(-0.1, 1.1) * W, r.uniform(260, 700)
+ arch = np.sqrt(np.clip(1 - ((XX - xc) / wc) ** 2, 0, 1)) ** 1.5
+ ph = ph - r.uniform(0.6, 1.6) * rows * arch * (0.85 + 0.3 * warp)
+ ring = 0.5 + 0.5 * np.cos(2 * np.pi * ph / period)
+ late = smoothstep(0.55, 0.97, ring) * (0.55 + 0.45 * mid)
+ a = 0.16 + 0.34 * late + 0.22 * (broad - 0.5) + 0.16 * (fine - 0.5)
+ a += 0.35 * smoothstep(0.82, 0.95, pores) * (0.4 + 0.6 * late)
+ return a + r.normal(0, 0.05), 1 + r.normal(0, 0.045)
+
+ off = r.uniform(0, plank)
+ out = np.zeros((H, W, 3), np.float32)
+ XX = np.arange(W, dtype=np.float32)[None, :]
+ edges = [0] + [int(off + plank * i) for i in range(0, int(H / plank) + 3) if 0 < off + plank * i < H] + [H]
+ for y0, y1 in zip(edges[:-1], edges[1:]):
+ if y1 <= y0: continue
+ rows = y1 - y0
+ yy = np.arange(rows, dtype=np.float32)[:, None]
+ a, tone = board(rows)
+ col = (lite[None, None] * (1 - a[..., None]) + dark[None, None] * a[..., None]) * tone
+ if r.random() < 0.8: # a butt joint: another board starts here
+ xj = r.uniform(0.1, 0.9) * W
+ a2, tone2 = board(rows)
+ col2 = (lite[None, None] * (1 - a2[..., None]) + dark[None, None] * a2[..., None]) * tone2
+ right = (XX > xj)[..., None]
+ col = np.where(right, col2, col)
+ col *= (1 - 0.5 * np.exp(-((XX - xj) / 1.2) ** 2))[..., None]
+ col *= (1 + 0.04 * np.exp(-((XX - xj - 2.5) / 1.5) ** 2))[..., None]
+ # plank seams: a dark gap with a lit bevel just below it
+ seam = np.exp(-(yy / 1.3) ** 2) + np.exp(-((rows - 1 - yy) / 1.3) ** 2)
+ col *= (1 - 0.55 * seam)[..., None]
+ col *= (1 + 0.05 * np.exp(-((yy - 3.0) / 1.6) ** 2))[..., None]
+ out[y0:y1] = col
+ # satin finish: a broad soft reflection of the window
+ XX = np.arange(W, dtype=np.float32)[None, :]
+ sheen = np.exp(-(((XX - 0.30 * W) / (0.42 * W)) ** 2 + ((YY - 0.12 * H) / (0.55 * H)) ** 2))
+ out = out * (1 + 0.06 * sheen[..., None]) + 0.025 * sheen[..., None]
+ self.surface = out.astype(np.float32)
+
+ def _linen(self, r):
+ H, W = self.H, self.W
+ base = hexc(LINEN)
+ a = blur(r.random((H, W), dtype=np.float32), 0.6)
+ wx = np.asarray(Image.fromarray(r.random((H, W // 3), dtype=np.float32)).resize((W, H), Image.BILINEAR))
+ wy = np.asarray(Image.fromarray(r.random((H // 3, W), dtype=np.float32)).resize((W, H), Image.BILINEAR))
+ YY, XX = np.mgrid[0:H, 0:W].astype(np.float32)
+ weave = 0.5 + 0.25 * np.sin(XX * 2.1) * (wy - 0.5) * 2 + 0.25 * np.sin(YY * 2.1) * (wx - 0.5) * 2
+ slub = smoothstep(0.75, 0.95, np.asarray(Image.fromarray(r.random((H // 2, W // 40), dtype=np.float32)).resize((W, H), Image.BICUBIC)))
+ v = 1 + 0.06 * (weave - 0.5) + 0.03 * (a - 0.5) - 0.05 * slub
+ return (base[None, None] * v[..., None]).astype(np.float32)
+
+ # ================================================================== cards
+ def card(self, cx, cy, w, h, rot=0.0, tone=PAPER, corner=6.0, tooth=1.0, seed=None):
+ """lay a blank cold-press card centred at (cx, cy), w x h canvas px, turned rot degrees (clockwise);
+ it becomes the current card. Draw on it in card units (0..w, 0..h) as if it were not turned."""
+ ss = self.ss
+ Wi, Hi = int(round(w * ss)), int(round(h * ss))
+ r = np.random.default_rng(self._seed() if seed is None else seed)
+ t1 = blur(r.random((Hi, Wi), dtype=np.float32), 1.0 * ss); t1 = (t1 - t1.mean()) / (t1.std() + 1e-6)
+ t2 = blur(r.random((Hi, Wi), dtype=np.float32), 2.4 * ss); t2 = (t2 - t2.mean()) / (t2.std() + 1e-6)
+ t = 0.6 * t1 + 0.4 * t2; t /= (t.std() + 1e-6)
+ th = np.clip(0.5 + 0.17 * t, 0, 1).astype(np.float32)
+ gy, gx = np.gradient(blur(th, 0.5 * ss))
+ lit = (0.55 * gx + 0.83 * gy) * ss
+ mot = noise2d(Hi, Wi, 90 * ss, 3, int(r.integers(1 << 30))) - 0.5
+ base = hexc(tone)[None, None] * (1 + 0.20 * tooth * lit + 0.012 * mot)[..., None]
+ # the cut: a rounded rectangle whose sides are not quite straight, with a little fuzz
+ u = (np.arange(Wi, dtype=np.float32) + 0.5) / ss - w / 2
+ v = (np.arange(Hi, dtype=np.float32) + 0.5) / ss - h / 2
+ qx = np.abs(u)[None, :] - (w / 2 - corner); qy = np.abs(v)[:, None] - (h / 2 - corner)
+ sdf = np.hypot(np.maximum(qx, 0), np.maximum(qy, 0)) + np.minimum(np.maximum(qx, qy), 0) - corner
+ sdf += 0.9 * (noise2d(Hi, Wi, 60 * ss, 2, int(r.integers(1 << 30))) - 0.5)
+ sdf += 0.35 * (blur(r.random((Hi, Wi), dtype=np.float32), 0.7 * ss) - 0.5) * 4
+ alpha = np.clip(0.5 - sdf * ss, 0, 1).astype(np.float32)
+ c = SimpleNamespace(cx=cx, cy=cy, w=w, h=h, rot=rot, Wi=Wi, Hi=Hi, base=base.astype(np.float32), tooth=th,
+ alpha=alpha, D=np.zeros((Hi, Wi, 3), np.float32), wet=np.zeros((Hi, Wi), np.float32),
+ cover_a=None, cover_rgb=None, parts=[], strokes=[], shown=True, rng=r)
+ self.cards.append(c)
+ self.cur = c
+ return c
+
+ def use(self, card):
+ """make `card` the current card"""
+ self.cur = card
+ return card
+
+ def _c(self, card):
+ return card if card is not None else self.cur
+
+ def _box(self, c, x0, y0, x1, y1):
+ """internal-pixel box clipped to the card"""
+ x0, y0 = max(0, int(np.floor(x0))), max(0, int(np.floor(y0)))
+ x1, y1 = min(c.Wi, int(np.ceil(x1)) + 1), min(c.Hi, int(np.ceil(y1)) + 1)
+ if x1 <= x0 or y1 <= y0: return None
+ return (slice(y0, y1), slice(x0, x1))
+
+ def _poly(self, c, polys, pad=3, sl=None):
+ """closed polygons (card units) -> (slice, AA mask crop); 2x supersampled"""
+ ss = self.ss
+ if sl is None:
+ P = np.concatenate([np.asarray(p, np.float32) for p in polys]) * ss
+ sl = self._box(c, P[:, 0].min() - pad, P[:, 1].min() - pad, P[:, 0].max() + pad, P[:, 1].max() + pad)
+ if sl is None: return None, None
+ x0, y0 = sl[1].start, sl[0].start
+ w, h = sl[1].stop - x0, sl[0].stop - y0
+ im = Image.new('L', (w * 2, h * 2), 0)
+ d = ImageDraw.Draw(im)
+ for p in polys:
+ q = (np.asarray(p, np.float32) * ss - [x0, y0]) * 2
+ if len(q) >= 3: d.polygon([tuple(map(float, a)) for a in q], fill=255)
+ return sl, np.asarray(im.resize((w, h), Image.BOX), np.float32) / 255
+
+ # ================================================================== geometry helpers (card units)
+ @staticmethod
+ def smooth(pts, closed=False, per=8):
+ """Catmull-Rom through control points"""
+ return _closed_spline(pts, per) if closed else spline(pts, per)
+
+ @staticmethod
+ def oval(cx, cy, rx, ry=None, rot=0.0, egg=0.0, n=72, wob=0.0, seed=0):
+ """closed ellipse; egg > 0 widens the bottom (a jowly head), < 0 the top; wob = relative wobble"""
+ ry = rx if ry is None else ry
+ t = np.linspace(0, 2 * np.pi, n, endpoint=False)
+ x, y = np.cos(t) * rx, np.sin(t) * ry
+ x = x * (1 + egg * np.sin(t))
+ if wob:
+ k = 1 + wob * fbm1d(n, n / 5, 3, seed)
+ x, y = x * k, y * k
+ c, s = np.cos(np.radians(rot)), np.sin(np.radians(rot))
+ return np.stack([cx + x * c - y * s, cy + x * s + y * c], 1).astype(np.float32)
+
+ @staticmethod
+ def turn(pts, cx, cy, deg):
+ """rotate points about (cx, cy) by deg (clockwise on screen)"""
+ P = np.asarray(pts, np.float32)
+ c, s = np.cos(np.radians(deg)), np.sin(np.radians(deg))
+ d = P - [cx, cy]
+ return np.stack([cx + d[:, 0] * c - d[:, 1] * s, cy + d[:, 0] * s + d[:, 1] * c], 1).astype(np.float32)
+
+ @staticmethod
+ def box(cx, cy, w, h, rot=0.0):
+ """corners of a w x h rectangle centred on (cx, cy), turned rot degrees"""
+ P = np.array([(cx - w / 2, cy - h / 2), (cx + w / 2, cy - h / 2), (cx + w / 2, cy + h / 2), (cx - w / 2, cy + h / 2)], np.float32)
+ return PenWash.turn(P, cx, cy, rot)
+
+ @staticmethod
+ def rrect(x0, y0, x1, y1, r=6.0, n=5):
+ pts = []
+ for (cx, cy, a0) in ((x1 - r, y0 + r, -90), (x1 - r, y1 - r, 0), (x0 + r, y1 - r, 90), (x0 + r, y0 + r, 180)):
+ for a in np.linspace(a0, a0 + 90, n):
+ pts.append((cx + r * np.cos(np.radians(a)), cy + r * np.sin(np.radians(a))))
+ return np.array(pts, np.float32)
+
+ @staticmethod
+ def tube(pts, w0, w1=None, per=8):
+ """a limb / strap / loaf around a centre line, width w0 -> w1.
+ Returns (outline, sides): sides = [left, right, end_cap, start_cap] open paths for inking."""
+ w1 = w0 if w1 is None else w1
+ C = spline(pts, per) if len(pts) > 2 else _resample(pts, 3.0)
+ C = _resample(C, 2.0)
+ n = len(C)
+ tg = np.gradient(C, axis=0); tg /= (np.linalg.norm(tg, axis=1, keepdims=True) + 1e-6)
+ nr = np.stack([-tg[:, 1], tg[:, 0]], 1)
+ wd = np.linspace(w0, w1, n)[:, None] / 2
+ L, R = C + nr * wd, C - nr * wd
+ a1 = np.arctan2(nr[-1, 1], nr[-1, 0])
+ cap_e = np.array([C[-1] + wd[-1] * np.array([np.cos(a1 - t), np.sin(a1 - t)]) for t in np.linspace(0, np.pi, 9)], np.float32)
+ a0 = np.arctan2(-nr[0, 1], -nr[0, 0])
+ cap_s = np.array([C[0] + wd[0] * np.array([np.cos(a0 - t), np.sin(a0 - t)]) for t in np.linspace(0, np.pi, 9)], np.float32)
+ outline = np.vstack([L, cap_e[1:-1], R[::-1], cap_s[1:-1]]).astype(np.float32)
+ return outline, [L.astype(np.float32), R.astype(np.float32), cap_e, cap_s]
+
+ @staticmethod
+ def hand(x, y, angle, size=26.0, kind='mitten', flip=False):
+ """a simple cartoon hand at the wrist (x, y), pointing at `angle` degrees.
+ kind: 'mitten' (thumb + a paddle), 'open' (four short fingers + thumb), 'fist' (round, holding).
+ Returns (outline, detail paths)."""
+ if kind == 'open':
+ P = [(0, 0.30), (0.42, 0.36)]
+ fy = [0.27, 0.09, -0.09, -0.27]
+ for i, c in enumerate(fy):
+ hw = 0.085
+ tip = 0.95 - 0.07 * abs(i - 1.3)
+ P += [(0.46, c + hw), (tip - 0.05, c + hw), (tip + 0.02, c + hw * 0.4), (tip + 0.02, c - hw * 0.4),
+ (tip - 0.05, c - hw), (0.52, c - hw)]
+ P += [(0.44, -0.36), (0.50, -0.55), (0.42, -0.66), (0.30, -0.60), (0.20, -0.38), (0, -0.30)]
+ det = []
+ elif kind == 'fist':
+ P = [(0, 0.28), (0.25, 0.36), (0.55, 0.36), (0.72, 0.25), (0.75, 0.0), (0.70, -0.24), (0.52, -0.36),
+ (0.38, -0.50), (0.22, -0.48), (0.18, -0.34), (0, -0.28)]
+ det = [[(0.55, 0.12), (0.72, 0.12)], [(0.55, -0.08), (0.73, -0.08)]]
+ else:
+ P = [(0, 0.30), (0.40, 0.38), (0.78, 0.30), (0.95, 0.06), (0.90, -0.20), (0.66, -0.32), (0.50, -0.34),
+ (0.52, -0.55), (0.40, -0.66), (0.26, -0.56), (0.20, -0.36), (0, -0.30)]
+ det = []
+ a = np.radians(angle); c, s = np.cos(a), np.sin(a)
+ sg = -1.0 if flip else 1.0
+
+ def tf(Q):
+ Q = np.asarray(Q, np.float32) * size
+ Q[:, 1] *= sg
+ return np.stack([x + Q[:, 0] * c - Q[:, 1] * s, y + Q[:, 0] * s + Q[:, 1] * c], 1).astype(np.float32)
+ outl = _closed_spline(tf(P), 4) if kind != 'open' else tf(P)
+ return outl, [tf(d) for d in det]
+
+ # ================================================================== parts and strokes (deferred until ink())
+ def part(self, pts, z=0.0, ink=True, strokes=None, corners=False, smooth=True, width=None, reserve=True,
+ nseg=None, card=None, name=None):
+ """a shape on the current card: its region (for washes and occlusion) and its ink outline.
+ strokes: list of open paths to ink instead of the closed outline (tube sides, a hat brim);
+ corners: split the outline at corners into overshooting strokes (boxes, bags, envelopes);
+ reserve: background blocks are painted around it."""
+ c = self._c(card)
+ P = np.asarray(pts, np.float32)
+ if smooth and not corners and len(P) > 3: P = _closed_spline(P, 5)
+ sl, m = self._poly(c, [P])
+ p = SimpleNamespace(kind='part', P=P, z=float(z), sl=sl, m=m, name=name, wet=None, reserve=reserve)
+ if sl is None: return p
+ c.parts.append(p)
+ if ink:
+ if strokes is None:
+ self.stroke(P, z=z, closed=True, smooth=False, corners=corners, width=width, nseg=nseg, card=c)
+ else:
+ for s_ in strokes:
+ self.stroke(s_, z=z, smooth=False, width=width, card=c)
+ return p
+
+ def stroke(self, pts, z=1e9, width=None, closed=False, smooth=True, corners=False, wobble=1.0, over=(0.0, 3.0),
+ double=None, flick=0.35, nseg=None, card=None):
+ """one fineliner line (inked at the next ink()); z: hidden where parts with a higher z cover it"""
+ c = self._c(card)
+ s = SimpleNamespace(kind='line', P=np.asarray(pts, np.float32), z=float(z), width=width or self.width,
+ closed=closed, smooth=smooth, corners=corners, wobble=wobble, over=over,
+ double=(0.12 if closed else 0.07) if double is None else double, flick=flick, nseg=nseg,
+ seed=int(c.rng.integers(1 << 30)), done=False)
+ c.strokes.append(s)
+ return s
+
+ def dot(self, x, y, r=3.8, z=1e9, card=None):
+ """a pressed dot (an eye): a small filled blob of ink"""
+ c = self._c(card)
+ sd = int(c.rng.integers(1 << 30))
+ P = PenWash.oval(x, y, r * np.random.default_rng(sd).uniform(0.92, 1.05), r * 1.08, n=24, wob=0.08, seed=sd)
+ s = SimpleNamespace(kind='dot', P=P, z=float(z), seed=sd, done=False)
+ c.strokes.append(s)
+ return s
+
+ def lines(self, paths, z=1e9, width=None, card=None, **kw):
+ return [self.stroke(p, z=z, width=width, card=card, **kw) for p in paths]
+
+ def limb(self, pts, w0, w1=None, z=0.0, caps=(False, True), card=None, name=None):
+ """a sleeve, leg or strap as a part: tube region; inks both sides and the chosen end caps"""
+ outl, (L, R, ce, cs) = PenWash.tube(pts, w0, w1)
+ st = [L, R] + ([cs] if caps[0] else []) + ([ce] if caps[1] else [])
+ return self.part(outl, z=z, strokes=st, smooth=False, card=card, name=name)
+
+ # ------------------------------------------------------------------ face and figure helpers
+ def glasses(self, cx, cy, r, gap=None, z=20.0, ry=None, temple=None, bridge=True, card=None):
+ """big round glasses: two lens parts (kept white: washes behind them stop at the rims), a bridge,
+ and a temple arm running back to `temple` (x, y) if given. Returns the two lens parts."""
+ gap = 2.15 * r if gap is None else gap
+ ry = r if ry is None else ry
+ a = self.part(PenWash.oval(cx, cy, r, ry, wob=0.03, seed=int(self._c(card).rng.integers(999))), z=z, nseg=1, card=card)
+ b = self.part(PenWash.oval(cx + gap, cy - 1, r, ry, wob=0.03, seed=int(self._c(card).rng.integers(999))), z=z, nseg=1, card=card)
+ if bridge:
+ self.stroke([(cx + r - 1, cy - 2), (cx + gap / 2, cy - 6), (cx + gap - r + 1, cy - 3)], z=z, card=card, double=0)
+ if temple is not None:
+ self.stroke([(cx - r + 1, cy - 2), ((cx - r + temple[0]) / 2, (cy + temple[1]) / 2 - 2), temple], z=z - 0.5,
+ card=card, double=0)
+ return a, b
+
+ def brows(self, pts_list, z=1e9, card=None):
+ return [self.stroke(p, z=z, width=self.width * 0.85, card=card, double=0, over=(0, 1)) for p in pts_list]
+
+ def tufts(self, x, y, n=5, length=14.0, spread=60.0, angle=-90.0, z=1e9, card=None, seed=None):
+ """a few quick hair strands fanning out from (x, y)"""
+ c = self._c(card)
+ r = np.random.default_rng(int(c.rng.integers(1 << 30)) if seed is None else seed)
+ out = []
+ for i in range(n):
+ a = np.radians(angle + spread * ((i + 0.5) / n - 0.5) + r.uniform(-6, 6))
+ L = length * r.uniform(0.7, 1.15)
+ bend = r.uniform(-0.25, 0.25)
+ p0 = np.array([x + r.uniform(-3, 3), y + r.uniform(-2, 2)])
+ p2 = p0 + L * np.array([np.cos(a), np.sin(a)])
+ p1 = (p0 + p2) / 2 + bend * L * np.array([-np.sin(a), np.cos(a)])
+ out.append(self.stroke([p0, p1, p2], z=z, width=self.width * 0.85, card=card, double=0, over=(0, 1)))
+ return out
+
+ def frame(self, x0, y0, x1, y1, z=-50.0, card=None):
+ """an inked border box, each side its own stroke overshooting the corners. Returns its points."""
+ P = np.array([(x0, y0), (x1, y0), (x1, y1), (x0, y1)], np.float32)
+ self.stroke(P, z=z, closed=True, smooth=False, corners=True, card=card, double=0.3, over=(2, 9))
+ return P
+
+ def ground(self, x0, x1, y, width=None, z=-10.0, heavy=True, card=None):
+ """a ground line: one or two quick heavy strokes"""
+ c = self._c(card)
+ r = np.random.default_rng(int(c.rng.integers(1 << 30)))
+ w = width or self.width * (1.7 if heavy else 1.0)
+ xm = x0 + (x1 - x0) * r.uniform(0.45, 0.65)
+ self.stroke([(x0, y + r.uniform(-1, 1)), ((x0 + xm) / 2, y + r.uniform(-1.5, 1.5)), (xm + 8, y + r.uniform(-1, 1))],
+ z=z, width=w, card=card, double=0, over=(0, 2))
+ self.stroke([(xm - 6, y + r.uniform(0.5, 2.0)), ((xm + x1) / 2, y + r.uniform(-1, 2)), (x1, y + r.uniform(-1, 1.5))],
+ z=z, width=w, card=card, double=0, over=(0, 2))
+
+ def signature(self, x, y, size=9.0, z=1e9, card=None):
+ """a tiny spiral mark in a corner, the way a sketcher initials a card"""
+ t = np.linspace(0, 3.3 * np.pi, 40)
+ rr = size * (1 - t / (4 * np.pi))
+ P = np.stack([x + rr * np.cos(t), y + rr * np.sin(t) * 0.9], 1)
+ return self.stroke(P, z=z, width=self.width * 0.9, smooth=False, card=card, double=0)
+
+ # ================================================================== ink
+ def _paths(self, s):
+ """a deferred stroke -> list of (points, widths) as the hand actually drew them"""
+ r = np.random.default_rng(s.seed)
+ P = np.asarray(s.P, np.float32)
+ segs = []
+ if s.closed:
+ if s.smooth and len(P) > 3: P = _closed_spline(P, 6)
+ if s.corners:
+ for g in _corners(P, True):
+ g = _resample(g, 1.0)
+ segs.append(_extend(g, r.uniform(*s.over), r.uniform(*s.over)))
+ else:
+ Q = _resample(P, 1.0, closed=True)
+ n = len(Q)
+ k = s.nseg or (1 if n < 150 else int(r.choice([1, 2, 2, 3])))
+ start = int(r.integers(n))
+ cuts = [start + int(n * (i + (r.uniform(-0.1, 0.1) if i else 0)) / k) for i in range(k)]
+ for i in range(k):
+ a = cuts[i]
+ b = cuts[i + 1] if i + 1 < k else cuts[0] + n
+ g = Q[np.arange(a, b + 1) % n]
+ e = r.uniform(-1, 1)
+ e0 = r.uniform(-4.0, 5.0) if e < 0.1 else r.uniform(1.0, 7.0)
+ e1 = r.uniform(-6.0, 7.0)
+ segs.append(_extend(g, e0, e1))
+ else:
+ if s.smooth and len(P) > 2: P = spline(P, 8)
+ parts = _corners(P, False) if s.corners else [P]
+ for g in parts:
+ g = _resample(g, 1.0)
+ segs.append(_extend(g, r.uniform(*s.over), r.uniform(*s.over)))
+ out = []
+ for g in segs:
+ if len(g) < 2: continue
+ out += self._hand(g, s, r)
+ return out
+
+ def _hand(self, g, s, r):
+ """wobble, width drift, rest blob, flick; sometimes a second pass a little off"""
+ n = len(g)
+ tg = np.gradient(g, axis=0); tg /= (np.linalg.norm(tg, axis=1, keepdims=True) + 1e-6)
+ nr = np.stack([-tg[:, 1], tg[:, 0]], 1)
+ off = fbm1d(n, 55, 3, int(r.integers(1 << 30))) * 1.0 * s.wobble
+ off += fbm1d(n, 8, 2, int(r.integers(1 << 30))) * 0.22 * s.wobble
+ Q = g + nr * off[:, None]
+ tpx = np.arange(n, dtype=np.float32)
+ w = s.width * (1 + 0.09 * fbm1d(n, 40, 2, int(r.integers(1 << 30))))
+ w *= 1 + 0.22 * np.exp(-tpx / 2.5)
+ if r.random() < s.flick and n > 14:
+ w *= np.interp(tpx, [n - 9, n - 1], [1.0, 0.5])
+ out = [(Q, w)]
+ if r.random() < s.double and n > 30:
+ a = int(r.uniform(0, 0.4) * n); b = int(min(n, a + r.uniform(0.35, 0.8) * n))
+ d = r.uniform(1.1, 2.4) * (1 if r.random() < 0.5 else -1)
+ off2 = d * (0.5 + 0.5 * np.sin(np.linspace(0, np.pi, b - a))) + fbm1d(b - a, 30, 2, int(r.integers(1 << 30))) * 0.6
+ Q2 = g[a:b] + nr[a:b] * (off[a:b] + off2)[:, None]
+ out.append((Q2, w[a:b] * 0.85))
+ return out
+
+ def _raster(self, c, paths):
+ """paths in card units -> (slice, coverage crop) at internal res, 2x supersampled"""
+ ss = self.ss
+ allp = np.concatenate([q for q, _ in paths]) * ss
+ pad = max(float(np.max(w)) for _, w in paths) * ss + 4
+ sl = self._box(c, allp[:, 0].min() - pad, allp[:, 1].min() - pad, allp[:, 0].max() + pad, allp[:, 1].max() + pad)
+ if sl is None: return None, None
+ x0, y0 = sl[1].start, sl[0].start
+ bw, bh = sl[1].stop - x0, sl[0].stop - y0
+ S = 2 * ss
+ im = Image.new('L', (bw * 2, bh * 2), 0)
+ d = ImageDraw.Draw(im)
+ o = np.array([x0, y0], np.float32) / ss
+ for Q, w in paths:
+ q = (Q - o) * S
+ ww = np.maximum(1, np.round((w[:-1] + w[1:]) * 0.5 * S)).astype(int) if len(q) > 1 else np.array([max(1, int(w[0] * S))])
+ ql = q.tolist()
+ i = 0
+ n = len(q)
+ while i < n - 1:
+ j = i + 1
+ while j < n - 1 and ww[j] == ww[i] and j - i < 60: j += 1
+ d.line([tuple(p) for p in ql[i:j + 1]], fill=255, width=int(ww[i]), joint='curve')
+ i = j
+ for k in (0, n - 1):
+ rr = w[k] * S / 2
+ d.ellipse([q[k, 0] - rr, q[k, 1] - rr, q[k, 0] + rr, q[k, 1] + rr], fill=255)
+ cov = np.asarray(im.resize((bw, bh), Image.BOX), np.float32) / 255
+ return sl, cov
+
+ def _front(self, c, sl, z):
+ """union of the regions of parts in front of depth z, over box sl"""
+ F = np.zeros((sl[0].stop - sl[0].start, sl[1].stop - sl[1].start), np.float32)
+ for q in c.parts:
+ if q.z <= z or q.sl is None: continue
+ ij = _inter(sl, q.sl)
+ if ij is None: continue
+ np.maximum(F[ij[0]], q.m[ij[1]], out=F[ij[0]])
+ return F
+
+ def ink(self, card=None):
+ """ink every pending stroke of the card (outlines, details, dots)"""
+ c = self._c(card)
+ for s in c.strokes:
+ if s.done: continue
+ s.done = True
+ if s.kind == 'dot':
+ sl, cov = self._poly(c, [s.P], pad=4)
+ else:
+ paths = self._paths(s)
+ if not paths: continue
+ sl, cov = self._raster(c, paths)
+ if sl is None: continue
+ th = c.tooth[sl]
+ amt = cov * (1 - 0.22 * smoothstep(0.26, 0.10, th))
+ amt = blur(amt, 0.3 * self.ss)
+ if s.z < 1e8:
+ F = self._front(c, sl, s.z)
+ if F.any():
+ F = smoothstep(0.55, 0.9, blur(F, 0.6 * self.ss))
+ amt = amt * (1 - F)
+ c.D[sl] += amt[..., None] * self.ink_abs
+
+ # ================================================================== washes
+ def _region(self, c, target, pad):
+ """wash target -> (padded slice, intended region). target: part, list of parts, points, or ('mask', sl, m)"""
+ def is_pts(t): # a polygon given as an array or a list of (x, y) pairs
+ if isinstance(t, np.ndarray): return True
+ return isinstance(t, (list, tuple)) and len(t) > 2 and all(np.ndim(q) == 1 and len(q) == 2 and
+ not isinstance(q[0], str) for q in t[:3])
+ if isinstance(target, tuple) and len(target) == 3 and isinstance(target[0], str): items = [target]
+ elif is_pts(target): items = [np.asarray(target, np.float32)]
+ elif isinstance(target, (list, tuple)): items = list(target)
+ else: items = [target]
+ boxes, pieces = [], []
+ for t in items:
+ if isinstance(t, SimpleNamespace):
+ if t.sl is None: continue
+ vis = t.m * (1 - self._front(c, t.sl, t.z))
+ pieces.append((t.sl, vis)); boxes.append(t.sl)
+ elif isinstance(t, tuple) and len(t) == 3 and t[0] == 'mask':
+ pieces.append((t[1], t[2])); boxes.append(t[1])
+ else:
+ sl, m = self._poly(c, [np.asarray(t, np.float32)])
+ if sl is None: continue
+ pieces.append((sl, m)); boxes.append(sl)
+ if not boxes: return None, None
+ p = int(pad)
+ sl = self._box(c, min(b[1].start for b in boxes) - p, min(b[0].start for b in boxes) - p,
+ max(b[1].stop for b in boxes) + p, max(b[0].stop for b in boxes) + p)
+ R = np.zeros((sl[0].stop - sl[0].start, sl[1].stop - sl[1].start), np.float32)
+ for bsl, m in pieces:
+ ij = _inter(sl, bsl)
+ if ij is not None: np.maximum(R[ij[0]], m[ij[1]], out=R[ij[0]])
+ return sl, R
+
+ def _streaks(self, h, w, angle, along, across, seed):
+ D = int(np.ceil(np.hypot(h, w))) + 4
+ g = np.random.default_rng(seed).random((max(2, int(D / across)), max(2, int(D / along)))).astype(np.float32)
+ im = Image.fromarray(g).resize((D, D), Image.BICUBIC).rotate(-angle, resample=Image.BILINEAR)
+ a = np.asarray(im, np.float32)
+ y0, x0 = (D - h) // 2, (D - w) // 2
+ return a[y0:y0 + h, x0:x0 + w]
+
+ def wash(self, target, colour, strength=1.0, shift=None, slip=(2.0, 4.8), warp=1.6, gaps=2.2, soft=2.2,
+ edge=0.35, gran=0.14, streak=0.08, angle=None, var=0.13, dry=0.0, card=None):
+ """a loose watercolour wash of `colour` (paint name or '#rrggbb') over a target region.
+ shift: (dx, dy) misregistration in px (default: random, |slip| px); warp: px the edge wanders in and out;
+ gaps: px the paint pulls back from the line in patches; soft: px of edge rounding; edge: wet-edge rim;
+ gran: granulation; streak: brush streaks along `angle` (degrees); var: density mottle; dry: dry-brush specks."""
+ c = self._c(card)
+ ss = self.ss
+ r = np.random.default_rng(int(c.rng.integers(1 << 30)))
+ col = hexc(PAINTS.get(colour, colour) if isinstance(colour, str) else colour)
+ absorb = -np.log(np.clip(col, 0.02, 1.0))
+ pad = (max(slip) + warp + soft * 3 + 6) * ss
+ sl, R = self._region(c, target, pad)
+ if sl is None: return None
+ h, w = R.shape
+ req = np.sqrt(R.sum() / np.pi) / ss # equivalent radius of the region, px
+ f = float(np.clip(req / 16.0, 0.22, 1.0))
+ slip, gaps, warp, soft = (slip[0] * f, slip[1] * f), gaps * f, warp * f, max(0.6, soft * f)
+ if shift is None:
+ a = r.uniform(0, 2 * np.pi); m = r.uniform(*slip)
+ shift = (m * np.cos(a), m * np.sin(a))
+ if shift[0] or shift[1]:
+ R = _move(R, shift[0] * ss, shift[1] * ss)
+ sig = max(0.5, soft) * ss
+ Rb = blur(R, sig)
+ o = warp * 2 * (noise2d(h, w, 26 * ss, 2, int(r.integers(1 << 30))) - 0.5)
+ if gaps: o = o + gaps * smoothstep(0.52, 0.78, noise2d(h, w, 20 * ss, 2, int(r.integers(1 << 30))))
+ thr = 0.5 + 0.5 * np.tanh(0.8 * o * ss / sig)
+ tex = (c.tooth[sl] - 0.5) * 0.10 + (noise2d(h, w, 4 * ss, 1, int(r.integers(1 << 30))) - 0.5) * 0.04
+ M = smoothstep(thr - 0.035, thr + 0.035, Rb + tex)
+ if not M.any(): return None
+ d = strength * (1 + var * 2 * (noise2d(h, w, 40 * ss, 3, int(r.integers(1 << 30))) - 0.5))
+ if streak:
+ ang = r.uniform(0, 180) if angle is None else angle
+ st = self._streaks(h, w, ang, 70 * ss, 3.5 * ss, int(r.integers(1 << 30)))
+ d = d * (1 + streak * 2 * (st - 0.5))
+ ring = np.clip(M - blur(M, 1.6 * ss), 0, None)
+ d = d + edge * 2.0 * ring * strength
+ th = c.tooth[sl]
+ d = d * (1 + gran * 2.2 * (0.5 - th))
+ if dry:
+ d = d * (1 - dry * smoothstep(0.6, 0.74, th) * smoothstep(0.35, 0.7, noise2d(h, w, 30 * ss, 2, int(r.integers(1 << 30)))))
+ dens = np.clip(M * d, 0, 3.0)
+ c.D[sl] += dens[..., None] * absorb
+ c.wet[sl] += M * min(1.0, strength)
+ if isinstance(target, SimpleNamespace): target.wet = (sl, M)
+ return (sl, M)
+
+ def bleed(self, target, x, y, r, colour, strength=0.6, card=None):
+ """drop `colour` into a wash that is still wet: soft spread around (x, y), stopped by the wet edge"""
+ c = self._c(card)
+ ss = self.ss
+ col = hexc(PAINTS.get(colour, colour) if isinstance(colour, str) else colour)
+ absorb = -np.log(np.clip(col, 0.02, 1.0))
+ if isinstance(target, SimpleNamespace) and target.wet is not None:
+ sl, M = target.wet
+ elif isinstance(target, tuple) and len(target) == 2:
+ sl, M = target
+ else:
+ sl, M = self._region(c, target, 4 * ss)
+ if sl is None: return
+ h, w = M.shape
+ Y = (np.arange(h, dtype=np.float32)[:, None] + sl[0].start + 0.5) / ss
+ X = (np.arange(w, dtype=np.float32)[None, :] + sl[1].start + 0.5) / ss
+ nz = noise2d(h, w, max(4, r * 0.6) * ss, 2, int(c.rng.integers(1 << 30)))
+ dist = np.hypot(X - x, Y - y) / (r * (0.8 + 0.4 * nz))
+ g = np.exp(-dist ** 2 * 1.4)
+ dens = g * M * strength
+ c.D[sl] += dens[..., None] * absorb
+
+ def background_block(self, x0, y0, x1, y1, colour, strength=0.92, rough=5.0, corner=12.0, halo=4.0, angle=None,
+ edge=0.5, streak=0.12, dry=0.2, card=None):
+ """a rough flat wash rectangle behind the figure that does not fill the card. Its sides are wobbly brush
+ edges; it is painted around every reserving part, leaving a white halo of ~halo px in places."""
+ c = self._c(card)
+ ss = self.ss
+ r = np.random.default_rng(int(c.rng.integers(1 << 30)))
+ P = _resample(PenWash.rrect(x0, y0, x1, y1, corner, 7), 2.0, closed=True)
+ n = len(P)
+ tg = np.gradient(np.vstack([P[-1:], P, P[:1]]), axis=0)[1:-1]
+ tg /= (np.linalg.norm(tg, axis=1, keepdims=True) + 1e-6)
+ nr = np.stack([tg[:, 1], -tg[:, 0]], 1)
+ off = fbm1d(n, 30, 3, int(r.integers(1 << 30))) * rough + fbm1d(n, 6, 2, int(r.integers(1 << 30))) * rough * 0.25
+ P = P + nr * off[:, None]
+ sl, R = self._poly(c, [P], pad=(rough + 20) * ss)
+ if sl is None: return None
+ h, w = R.shape
+ F = np.zeros_like(R)
+ for q in c.parts:
+ if not q.reserve or q.sl is None: continue
+ ij = _inter(sl, q.sl)
+ if ij is not None: np.maximum(F[ij[0]], q.m[ij[1]], out=F[ij[0]])
+ if F.any():
+ Fb = blur(F, halo * 0.8 * ss)
+ t = 0.06 + 0.22 * noise2d(h, w, 30 * ss, 2, int(r.integers(1 << 30)))
+ R = R * (1 - smoothstep(t - 0.03, t + 0.03, Fb))
+ return self.wash(('mask', sl, R), colour, strength, shift=(0, 0), warp=1.2, gaps=0.0, soft=1.6, edge=edge,
+ gran=0.2, streak=streak, angle=90.0 if angle is None else angle, var=0.12, dry=dry, card=c)
+
+ def spatter(self, colour, n=10, box=None, size=(0.8, 2.8), strength=1.0, card=None):
+ """flicked droplets of paint, each with a darker dried rim"""
+ c = self._c(card)
+ r = np.random.default_rng(int(c.rng.integers(1 << 30)))
+ x0, y0, x1, y1 = box or (0, 0, c.w, c.h)
+ polys = [PenWash.oval(r.uniform(x0, x1), r.uniform(y0, y1), rr, rr * r.uniform(0.8, 1.15), n=18, wob=0.1, seed=int(r.integers(999)))
+ for rr in r.uniform(*size, n)]
+ sl, m = self._poly(c, polys, pad=6)
+ if sl is None: return
+ self.wash(('mask', sl, m), colour, strength, shift=(0, 0), warp=0.2, gaps=0, soft=0.6, edge=0.7, gran=0.2, streak=0, card=c)
+
+ # ------------------------------------------------------------------ opaque white gouache (last)
+ def _cover(self, c, sl, a, colour):
+ if c.cover_a is None:
+ c.cover_a = np.zeros((c.Hi, c.Wi), np.float32); c.cover_rgb = np.zeros((c.Hi, c.Wi, 3), np.float32)
+ col = hexc(colour)
+ ca, cr = c.cover_a[sl], c.cover_rgb[sl]
+ cr[:] = cr * (1 - a[..., None]) + col * a[..., None]
+ ca[:] = 1 - (1 - ca) * (1 - a)
+
+ def highlight(self, pts, width=3.0, alpha=0.9, colour='#fbfaf3', card=None):
+ """a stroke of opaque white gouache (glints, a shine on a loaf or a nose)"""
+ c = self._c(card)
+ s = SimpleNamespace(P=np.asarray(pts, np.float32), closed=False, smooth=True, corners=False, wobble=0.6,
+ over=(0, 1), width=width, double=0, flick=0.8, seed=int(c.rng.integers(1 << 30)))
+ sl, cov = self._raster(c, self._paths(s))
+ if sl is None: return
+ a = cov * alpha * (0.7 + 0.3 * smoothstep(0.3, 0.6, c.tooth[sl]))
+ self._cover(c, sl, a, colour)
+
+ def glint(self, x, y, r=2.2, alpha=0.95, colour='#fdfcf6', card=None):
+ """a dab of white gouache"""
+ c = self._c(card)
+ sl, m = self._poly(c, [PenWash.oval(x, y, r, r * 0.9, n=16, wob=0.12, seed=int(c.rng.integers(999)))], pad=4)
+ if sl is None: return
+ self._cover(c, sl, m * alpha, colour)
+
+ # ================================================================== tools on the table
+ def pen(self, x, y, angle, length=430.0, r=10.5, cap=True):
+ """a fineliner lying on the table, tip at (x, y), its body running toward `angle` degrees"""
+ k = r / 10.5
+ segs = [(0, 5 * k, 0.9 * k, 1.2 * k, 'tip'), (5 * k, 18 * k, 1.5 * k, 2.3 * k, 'metal'),
+ (18 * k, 46 * k, 2.6 * k, 0.80 * r, 'grey'), (46 * k, 53 * k, 0.92 * r, 0.92 * r, 'gloss'),
+ (53 * k, length * 0.70, r * 0.95, r * 0.95, 'matte'),
+ (length * 0.70, length * 0.70 + 4 * k, r * 0.98, r * 0.98, 'metal')]
+ if cap:
+ segs.append((length * 0.70 + 4 * k, length, r * 1.07, r * 1.07, 'gloss'))
+ self.tools.append(dict(kind='pen', x=x, y=y, angle=angle, L=length, r=r, segs=segs,
+ clip=(length * 0.77, length * 0.97) if cap else None, label=(70 * k, '0.3', k)))
+
+ def water_brush(self, x, y, angle, length=320.0, r=12.0, stain='teal', cap=None):
+ """a water brush lying on the table: nylon tip at (x, y) stained with a little paint, ribbed grip, a clear
+ barrel of water with a bubble; cap=(x, y, angle) also lays its clear cap on the table"""
+ k = r / 12.0
+ segs = [(0, 36 * k, 0.0, 0.55 * r, 'bristle'), (36 * k, 46 * k, 0.6 * r, 0.66 * r, 'white'),
+ (46 * k, 112 * k, 0.78 * r, 0.80 * r, 'rib'), (112 * k, 120 * k, 0.86 * r, 0.86 * r, 'white'),
+ (120 * k, length, r, r, 'water')]
+ self.tools.append(dict(kind='brush', x=x, y=y, angle=angle, L=length, r=r, segs=segs, stain=stain,
+ tipL=36 * k, bubble=(length * 0.80, length * 0.96)))
+ if cap is not None:
+ cx, cy, ca = cap
+ self.tools.append(dict(kind='cap', x=cx, y=cy, angle=ca, L=74.0 * k, r=r * 0.92,
+ segs=[(0, 74 * k, r * 0.92, r * 0.92, 'clear')]))
+
+ def _profile(self, t):
+ """radius and material index along the axis at 0.25 px steps (rounded ends)"""
+ L = t['L']
+ s = np.arange(0, L + 0.25, 0.25, dtype=np.float32)
+ rad = np.zeros_like(s); mat = np.zeros(len(s), np.int32)
+ names = []
+ for (s0, s1, r0, r1, m) in t['segs']:
+ if m not in names: names.append(m)
+ k = (s >= s0) & (s <= s1)
+ rad[k] = r0 + (r1 - r0) * (s[k] - s0) / max(1e-3, s1 - s0)
+ mat[k] = names.index(m)
+ if t['kind'] == 'brush':
+ tl = t['tipL']
+ k = s <= tl
+ rad[k] = 0.55 * t['r'] * np.clip(s[k] / tl, 0, 1) ** 0.75 * (1 - 0.15 * np.clip(s[k] / tl, 0, 1) ** 4)
+ e = min(5.0, t['r'] * 0.5)
+ tail = s > L - e
+ rad[tail] *= np.sqrt(np.clip(1 - ((s[tail] - (L - e)) / e) ** 2, 0, 1))
+ if t['kind'] == 'cap':
+ head = s < 3
+ rad[head] *= np.sqrt(np.clip(1 - ((3 - s[head]) / 3) ** 2, 0.3, 1))
+ return s, rad, mat, names
+
+ def _lay_tool(self, I, t):
+ H, W = self.H, self.W
+ a = np.radians(t['angle']); ax, ay = np.cos(a), np.sin(a)
+ nx, ny = -ay, ax
+ L, R = t['L'], t['r'] * 1.1
+ x0, y0 = t['x'], t['y']
+ pts = np.array([(x0, y0), (x0 + ax * L, y0 + ay * L)])
+ pad = R + 30
+ bx0, by0 = int(max(0, pts[:, 0].min() - pad)), int(max(0, pts[:, 1].min() - pad))
+ bx1, by1 = int(min(W, pts[:, 0].max() + pad)), int(min(H, pts[:, 1].max() + pad))
+ if bx1 <= bx0 or by1 <= by0: return
+ YY, XX = np.mgrid[by0:by1, bx0:bx1].astype(np.float32)
+ px, py = XX + 0.5 - x0, YY + 0.5 - y0
+ s = px * ax + py * ay
+ tt = px * nx + py * ny
+ sp, rad, mat, names = self._profile(t)
+ si = np.clip((s / 0.25).astype(np.int32), 0, len(sp) - 1)
+ inside_s = (s >= 0) & (s <= L)
+ rr = np.where(inside_s, rad[si], 0.0)
+ cov = np.clip(rr - np.abs(tt) + 0.5, 0, 1) * inside_s
+ # cast shadow on what is below (lifted by its radius, light from the upper left), plus contact shadow
+ dx, dy = self.ld * t['r'] * 0.95
+ clear = np.isin(mat[si], [names.index(m) for m in names if m in ('water', 'clear')]) if any(m in ('water', 'clear') for m in names) else np.zeros_like(cov, bool)
+ dens = np.where(clear, 0.62, 1.0) * cov
+ sh = blur(_move(dens, dx, dy), 0.28 * t['r'] + 1.5) * 0.42 + blur(_move(cov * (np.abs(tt) < rr * 0.5), 1, 1.5), 1.6) * 0.30
+ if clear.any():
+ caus = blur(_move(clear * cov * (np.abs(tt) < rr * 0.22), dx * 1.1, dy * 1.1), 1.4)
+ sh = sh - 0.10 * caus
+ reg = I[by0:by1, bx0:bx1]
+ reg *= (1 - np.clip(sh, -0.3, 0.9)[..., None] * (1 - SHADOW))
+ # shading of the cylinder
+ u = np.clip(tt / np.maximum(rr, 1e-3), -1, 1)
+ nz = np.sqrt(np.clip(1 - u * u, 0, 1))
+ Lv = np.array([-0.55, -0.83, 1.15], np.float32); Lv /= np.linalg.norm(Lv)
+ Nx, Ny = nx * u, ny * u
+ lam = np.clip(Nx * Lv[0] + Ny * Lv[1] + nz * Lv[2], 0, 1)
+ Hv = Lv + np.array([0, 0, 1], np.float32); Hv /= np.linalg.norm(Hv)
+ ndh = np.clip(Nx * Hv[0] + Ny * Hv[1] + nz * Hv[2], 0, 1)
+ out = np.zeros(cov.shape + (3,), np.float32)
+ m_here = mat[si]
+ under = reg.copy()
+ for k, m in enumerate(names):
+ sel = (m_here == k) & (cov > 0)
+ if not sel.any(): continue
+ uu, lm, sp_, nzz = u[sel], lam[sel], ndh[sel], nz[sel]
+ if m in ('matte', 'gloss', 'tip', 'grey', 'white', 'rib', 'bristle'):
+ alb, amb, dif, ks, shin = {'matte': (0.075, 0.35, 0.65, 0.16, 9), 'gloss': (0.05, 0.3, 0.7, 0.75, 60),
+ 'tip': (0.06, 0.4, 0.6, 0.2, 10), 'grey': (0.50, 0.35, 0.65, 0.45, 35),
+ 'white': (0.80, 0.45, 0.55, 0.35, 25), 'rib': (0.16, 0.4, 0.6, 0.18, 12),
+ 'bristle': (0.07, 0.45, 0.55, 0.25, 14)}[m]
+ cval = alb * (amb + dif * lm)
+ if m == 'rib':
+ cval = cval * (0.78 + 0.22 * np.cos(2 * np.pi * s[sel] / (3.2 * t['r'] / 12.0)))
+ if m == 'bristle':
+ kk = t['r'] / 12.0
+ cval = cval * (0.8 + 0.4 * (np.sin(tt[sel] * 2.7 / kk + np.sin(s[sel] * 0.07 / kk) * 3) * 0.5 + 0.5))
+ col = np.stack([cval] * 3, -1) + (ks * sp_ ** shin)[..., None]
+ if m == 'grey': col *= np.array([0.98, 1.0, 1.03], np.float32)
+ if m == 'bristle' and t.get('stain'):
+ st = hexc(PAINTS.get(t['stain'], t['stain']))
+ k_ = np.clip(1 - s[sel] / (0.36 * t['tipL']), 0, 1)[..., None] * 0.85
+ col = col * (1 - k_) + (st * (0.35 + 0.5 * lm[..., None])) * k_
+ elif m == 'metal':
+ env = 0.42 + 0.5 * np.exp(-((uu + 0.42) / 0.22) ** 2) - 0.2 * np.exp(-((uu - 0.35) / 0.3) ** 2)
+ col = np.stack([env * 0.98, env, env * 1.03], -1) + (0.5 * sp_ ** 50)[..., None]
+ else: # clear plastic / water: refract what is under it
+ kref = 7.0 if m == 'water' else 3.0
+ ox = nx * (uu ** 3) * kref; oy = ny * (uu ** 3) * kref
+ ys, xs = np.nonzero(sel)
+ fx = np.clip(xs - ox, 0, reg.shape[1] - 1); fy = np.clip(ys - oy, 0, reg.shape[0] - 1)
+ und = _bilinear(under, fx, fy)
+ tint = np.array([0.90, 0.95, 0.98] if m == 'water' else [0.95, 0.97, 0.985], np.float32)
+ col = und * tint * (0.80 + 0.14 * nzz)[..., None] + 0.08 # slightly milky plastic
+ col = col * (1 - 0.55 * ((1 - nzz) ** 3))[..., None]
+ col += (0.55 * np.exp(-((uu + 0.52) / 0.08) ** 2) + 0.16 * np.exp(-((uu - 0.62) / 0.1) ** 2))[..., None]
+ if m == 'water' and t.get('bubble'):
+ b0, b1 = t['bubble']
+ sb = s[sel]
+ inb = (sb > b0) & (sb < b1) & (uu > -0.85) & (uu < -0.05)
+ edgeb = np.exp(-((sb - b0) / 1.6) ** 2) * (uu > -0.85) * (uu < -0.05)
+ col = col + (0.10 * inb)[..., None] - (0.18 * edgeb)[..., None]
+ if m == 'clear':
+ ring = np.exp(-((s[sel] - 4) / 1.5) ** 2)
+ col = col * (1 - 0.25 * ring)[..., None]
+ out[sel] = col
+ if t.get('label'):
+ s0, txt, kk = t['label']
+ self._ax_neg = ax < 0
+ self._print_label(out, cov, s / kk, tt / kk, s0 / kk, txt, rr / kk)
+ a_ = cov[..., None]
+ reg[:] = reg * (1 - a_) + out * a_
+ if t.get('clip'):
+ c0, c1 = t['clip']
+ cw = 2.6 * t['r'] / 10.5
+ kk = t['r'] / 10.5
+ cc = np.clip(cw - np.abs(tt + 0.5 * kk) + 0.5, 0, 1) * (s > c0) * (s < c1)
+ cc *= np.clip((c1 + 2 - s) / 3, 0, 1)
+ shc = blur(_move(cc, dx * 0.25, dy * 0.25), 0.8 * kk) * 0.5
+ reg *= (1 - shc[..., None] * (1 - SHADOW))
+ v = 0.12 + 0.55 * np.exp(-((tt + 1.6 * kk) / kk) ** 2) + 0.1 * np.exp(-((s - c1 + 4 * kk) / (3 * kk)) ** 2)
+ reg[:] = reg * (1 - cc[..., None]) + np.stack([v, v, v * 1.02], -1) * cc[..., None]
+
+ def _print_label(self, out, cov, s, tt, s0, txt, rr):
+ """small light-grey print on the barrel (the line width), following the cylinder"""
+ f = load_font('sans_bold', 22)
+ im = Image.new('L', (90, 30), 0)
+ ImageDraw.Draw(im).text((2, 2), txt, font=f, fill=255)
+ g = np.asarray(im, np.float32) / 255
+ flip = getattr(self, '_ax_neg', False)
+ u = (s - s0) if not flip else (s0 + 60 - s)
+ v = (tt * 1.25 + 14) if not flip else (-tt * 1.25 + 14)
+ ok = (u >= 0) & (u < 89) & (v >= 0) & (v < 29) & (cov > 0)
+ if not ok.any(): return
+ val = g[np.clip(v.astype(int), 0, 29), np.clip(u.astype(int), 0, 89)] * ok
+ val = val * np.clip(1 - np.abs(tt / np.maximum(rr, 1e-3)) ** 2, 0, 1)
+ out[:] = out * (1 - 0.65 * val[..., None]) + 0.62 * 0.65 * val[..., None]
+
+ # ================================================================== compose the photo
+ def _card_rgba(self, c):
+ ss = self.ss
+ rgb = c.base * np.exp(-c.D)
+ if c.wet.any():
+ wb = blur(c.wet, 10 * ss)
+ gy, gx = np.gradient(wb)
+ rgb *= (1 + np.clip((0.55 * gx + 0.83 * gy) * ss * 2.2, -0.035, 0.035))[..., None]
+ if c.cover_a is not None:
+ a = c.cover_a[..., None]
+ rgb = rgb * (1 - a) + c.cover_rgb * a * c.base / hexc(PAPER)
+ A = c.alpha[..., None]
+ rgba = np.concatenate([rgb * A, A], -1)
+ h1, w1 = c.Hi // ss, c.Wi // ss
+ rgba = rgba[:h1 * ss, :w1 * ss].reshape(h1, ss, w1, ss, 4).mean((1, 3))
+ return rgba
+
+ def _lay_card(self, I, c):
+ H, W = self.H, self.W
+ rgba = self._card_rgba(c)
+ th = np.radians(c.rot); cs, sn = np.cos(th), np.sin(th)
+ hw, hh = c.w / 2, c.h / 2
+ corners = np.array([[-hw, -hh], [hw, -hh], [hw, hh], [-hw, hh]])
+ P = np.stack([c.cx + corners[:, 0] * cs - corners[:, 1] * sn, c.cy + corners[:, 0] * sn + corners[:, 1] * cs], 1)
+ pad = 28
+ bx0, by0 = int(max(0, P[:, 0].min() - pad)), int(max(0, P[:, 1].min() - pad))
+ bx1, by1 = int(min(W, P[:, 0].max() + pad)), int(min(H, P[:, 1].max() + pad))
+ if bx1 <= bx0 or by1 <= by0: return
+ YY, XX = np.mgrid[by0:by1, bx0:bx1].astype(np.float32)
+ dx, dy = XX + 0.5 - c.cx, YY + 0.5 - c.cy
+ u = cs * dx + sn * dy + hw
+ v = -sn * dx + cs * dy + hh
+ smp = _bilinear(rgba, u - 0.5, v - 0.5)
+ a = smp[..., 3]
+ reg = I[by0:by1, bx0:bx1]
+ sh = blur(_move(a, 6, 8), 7.0) * 0.30 + blur(_move(a, 1.2, 1.8), 1.3) * 0.36
+ reg *= (1 - np.clip(sh, 0, 0.9)[..., None] * (1 - SHADOW))
+ reg[:] = reg * (1 - a[..., None]) + smp[..., :3]
+ gy, gx = np.gradient(a)
+ facing = -(gx * -self.ld[0] + gy * -self.ld[1]) # outward normal . (toward the light)
+ reg *= (1 + 0.10 * np.clip(facing, 0, 1) - 0.16 * np.clip(-facing, 0, 1))[..., None]
+
+ def render(self):
+ I = self.surface.copy()
+ for c in self.cards:
+ if c.shown: self._lay_card(I, c)
+ for t in self.tools: self._lay_tool(I, t)
+ return I
+
+ def composite(self):
+ I = self.render() * self._light[..., None] * self.warm
+ I = I + self._grain[..., None] * 0.010
+ return Image.fromarray((np.clip(I, 0, 1) * 255 + 0.5).astype(np.uint8))
+
+ def stage(self, name):
+ if not self.keep_stages: return
+ im = self.composite()
+ if self.stages_dir:
+ os.makedirs(self.stages_dir, exist_ok=True)
+ im.save(f'{self.stages_dir}/{self._n_stages:02d}_{name}.png', compress_level=1)
+ else:
+ b = io.BytesIO(); im.save(b, 'PNG', compress_level=1)
+ self.stages.append((name, b.getvalue()))
+ self._n_stages += 1
+
+ def save(self, path, stages_dir=None, quality=88):
+ img = self.composite()
+ if str(path).lower().endswith(('.jpg', '.jpeg')): img.save(path, quality=quality, subsampling=0)
+ else: img.save(path)
+ sd = stages_dir or self.stages_dir
+ if sd and self.keep_stages:
+ os.makedirs(sd, exist_ok=True)
+ for i, (name, b) in enumerate(self.stages):
+ with open(f'{sd}/{i:02d}_{name}.png', 'wb') as f: f.write(b)
+ img.save(f'{sd}/{self._n_stages:02d}_final.png', compress_level=1)
+ return img