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 hatched nocturne style (70 total): lava meeting the sea at night

cloveric70658538cf89
diff --git a/README.md b/README.md
index 4bebacf..2274966 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# Claude Drawing · Claude 绘图
-**Claude paints with code — no image model.** Sixty-nine styles, from ink wash and impasto oil to clay, cyanotype, stained glass, a Roman mosaic, Delft tiles, a cyberpunk street, a ray-traced ball pit, low-poly 3D, a thermal camera, an X-ray, a VHS tape, a synthwave sunset, a pastel product-film UI, an answer sheet marked in red, a lamp-lit shadow-puppet play, pen-and-wash sketch cards, retro gouache picture-book portraits, a soft-blue picture-book spread, a Jiangnan water garden in spring, a dry-brushed mid-century poster and a dusk picture-book page where the sky turns to stars.
-**不用生图模型,Claude 用代码一笔一笔作画。** 六十九种画风,从水墨、油画到黏土、蓝晒、彩色玻璃花窗、罗马马赛克、代尔夫特蓝瓷砖、赛博朋克、光线追踪的小球海、低多边形 3D、热成像、X 光片、VHS 录像带、Synthwave 落日、产品发布片式的粉彩界面、红笔批改的答题卡、油灯下的皮影戏、钢笔淡彩的速写小卡、复古水粉的绘本大头像、蓝调绘本的雨天跨页、江南园林的春水园景、干刷色块的 mid-century 海报和暮色微缩绘本里转入星空的黄昏。
+**Claude paints with code — no image model.** Seventy styles, from ink wash and impasto oil to clay, cyanotype, stained glass, a Roman mosaic, Delft tiles, a cyberpunk street, a ray-traced ball pit, low-poly 3D, a thermal camera, an X-ray, a VHS tape, a synthwave sunset, a pastel product-film UI, an answer sheet marked in red, a lamp-lit shadow-puppet play, pen-and-wash sketch cards, retro gouache picture-book portraits, a soft-blue picture-book spread, a Jiangnan water garden in spring, a dry-brushed mid-century poster, a dusk picture-book page where the sky turns to stars and a hatched night print of lava meeting the sea.
+**不用生图模型,Claude 用代码一笔一笔作画。** 七十种画风,从水墨、油画到黏土、蓝晒、彩色玻璃花窗、罗马马赛克、代尔夫特蓝瓷砖、赛博朋克、光线追踪的小球海、低多边形 3D、热成像、X 光片、VHS 录像带、Synthwave 落日、产品发布片式的粉彩界面、红笔批改的答题卡、油灯下的皮影戏、钢笔淡彩的速写小卡、复古水粉的绘本大头像、蓝调绘本的雨天跨页、江南园林的春水园景、干刷色块的 mid-century 海报、暮色微缩绘本里转入星空的黄昏和排线夜景里流进海里的熔岩。
[English](#english) · [中文](#中文)
@@ -52,8 +52,8 @@
| ![grading](examples/drawing_grading_math_quiz.gif) | ![shadowpuppet](examples/drawing_shadowpuppet_cuju.gif) | ![penwash](examples/drawing_penwash_neighbours.gif) |
| **Retro gouache · 复古水粉** | **Blue picture book · 蓝调绘本** | **Jiangnan garden · 江南园林** |
| ![gouache](examples/drawing_gouache_rainy_day.gif) | ![bluebook](examples/drawing_bluebook_shared_umbrella.gif) | ![jiangnan](examples/drawing_jiangnan_spring_water.gif) |
-| **Dry-brush blocks · 干刷色块** | **Twilight storybook · 暮色微缩绘本** | **Ink wash · 水墨(月印万川)** |
-| ![drybrush](examples/drawing_drybrush_noodle_counter.gif) | ![twilight](examples/drawing_twilight_paper_kite.gif) | ![moonriver](examples/drawing_moon_river.gif) |
+| **Dry-brush blocks · 干刷色块** | **Twilight storybook · 暮色微缩绘本** | **Hatched nocturne · 排线夜景** |
+| ![drybrush](examples/drawing_drybrush_noodle_counter.gif) | ![twilight](examples/drawing_twilight_paper_kite.gif) | ![nocturne](examples/drawing_nocturne_lava_sea.gif) |
### Gallery · 画廊
@@ -61,76 +61,78 @@
|---|---|
| **八万四千法门** · *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%"> |
-| **街角速写** · *Sketchbook Neighbours*<br><sub>Pen & wash · 钢笔淡彩</sub> | **雨天三人像** · *Rainy-Day Portraits*<br><sub>Retro gouache · 复古水粉</sub> |
-| <img src="examples/penwash_neighbours.jpg" width="100%"> | <img src="examples/gouache_rainy_day.jpg" width="100%"> |
-| **借伞** · *The Shared Umbrella*<br><sub>Blue picture book · 蓝调绘本</sub> | **春水园林** · *Spring Water Garden*<br><sub>Jiangnan garden · 江南园林</sub> |
-| <img src="examples/bluebook_shared_umbrella.jpg" width="100%"> | <img src="examples/jiangnan_spring_water.jpg" width="100%"> |
-| **面馆** · *Noodle Counter*<br><sub>Dry-brush blocks · 干刷色块</sub> | **夜的边上** · *The Kite at the Edge of Night*<br><sub>Twilight storybook · 暮色微缩绘本</sub> |
-| <img src="examples/drybrush_noodle_counter.jpg" width="100%"> | <img src="examples/twilight_paper_kite.jpg" width="100%"> |
-
-Every mark above is computed: paper fibres, ink washes and mist, dry-brush strokes, pigment granulation and blooms, torn-paper edges, pencil wax on paper tooth, cel-shaded clouds, risograph grain and halftones, lit impasto relief, woodblock grain and bokashi, dithered pixels, plasticine lit like a film set, sunlight through leaves on Prussian blue, twisted thread on Aida cloth, machined knobs behind a backlit dial, die-cut vinyl with a laminate gloss, streaky thermal print, graphite catching the tooth of graph paper, highlighter pooling at the start of a swipe, chalk dust settling under half-erased lessons, rain-lit neon glass mirrored in a wet street, a blue-pencil rough under boiling brush ink, an island ray-traced under one soft sun, a single unbroken gold line, candy balls with softbox glints, one outline morphing through six shapes, halftone photos cut out with scissors, frosted glass blurring the real pixels behind it, screen-printed primaries out of register, a slit sun sinking behind a neon grid played off tape, hollow fuse beads on a pegboard melting together under an iron, pits knocked through desert varnish, a red grid showing through flaking plaster, stones laid row by row along an outline, daylight through leaded glass, burnished gold that mirrors the room, left-handed hatching in iron-gall ink, black paper cut with scissors, wood type printed a hair out of register, red and black plates slipping apart, airbrush fades inside knife-cut friskets, Ben-Day dots on yellowed newsprint, one photo key pulled across hand-painted colour, characters struck through a fading ribbon, flat-shaded triangles dithered to 15 bits, spray drifting past cut card, satin stitches catching the light by their angle, ink lines printed white on Prussian blue, wax scribbles skipping the paper's pits, phosphor glowing behind curved glass, heat leaking out of a kitchen, cobalt fired into tin glaze tile by tile, ochre blown onto rock lit by a fire, 1-bit patterns in an old paint program, slip silhouettes incised to the clay, graphite that never quite reaches black, X-rays adding up through a suitcase, grey cels shot on scratched film, gouge marks in a rolled-up block, a birthday smeared onto tape, seven flat colours lifting off each other, an acorn squashing and stretching through a world drawn as it goes, ballpoint ink blobbing at every corner of a hand-drawn game, inks multiplying through tracing paper on a light box, window cards floating on a pastel field over shadows tinted by it, a vermilion stamp running dry at one end, red ink pooling where the pen slowed down, dyed donkey hide glowing on a lamp-lit screen, gouache scumbled dry over a toned board, knit stitch by stitch, dry pastel blue under a scratchy brush line, with chalk rain on top, a spring garden built leaf by leaf, its tiled roofs and willows mirrored in a jade lake, a roller and a dry brush running out across cream paper, and a dusk sky going over to stars above thousands of tiny wildflowers. 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.
+| **秋日湖畔** · *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%"> |
+| **雨天三人像** · *Rainy-Day Portraits*<br><sub>Retro gouache · 复古水粉</sub> | **借伞** · *The Shared Umbrella*<br><sub>Blue picture book · 蓝调绘本</sub> |
+| <img src="examples/gouache_rainy_day.jpg" width="100%"> | <img src="examples/bluebook_shared_umbrella.jpg" width="100%"> |
+| **春水园林** · *Spring Water Garden*<br><sub>Jiangnan garden · 江南园林</sub> | **面馆** · *Noodle Counter*<br><sub>Dry-brush blocks · 干刷色块</sub> |
+| <img src="examples/jiangnan_spring_water.jpg" width="100%"> | <img src="examples/drybrush_noodle_counter.jpg" width="100%"> |
+| **夜的边上** · *The Kite at the Edge of Night*<br><sub>Twilight storybook · 暮色微缩绘本</sub> | **熔岩入海** · *Lava Meets the Sea*<br><sub>Hatched nocturne · 排线夜景</sub> |
+| <img src="examples/twilight_paper_kite.jpg" width="100%"> | <img src="examples/nocturne_lava_sea.jpg" width="100%"> |
+
+Every mark above is computed: paper fibres, ink washes and mist, dry-brush strokes, pigment granulation and blooms, torn-paper edges, pencil wax on paper tooth, cel-shaded clouds, risograph grain and halftones, lit impasto relief, woodblock grain and bokashi, dithered pixels, plasticine lit like a film set, sunlight through leaves on Prussian blue, twisted thread on Aida cloth, machined knobs behind a backlit dial, die-cut vinyl with a laminate gloss, streaky thermal print, graphite catching the tooth of graph paper, highlighter pooling at the start of a swipe, chalk dust settling under half-erased lessons, rain-lit neon glass mirrored in a wet street, a blue-pencil rough under boiling brush ink, an island ray-traced under one soft sun, a single unbroken gold line, candy balls with softbox glints, one outline morphing through six shapes, halftone photos cut out with scissors, frosted glass blurring the real pixels behind it, screen-printed primaries out of register, a slit sun sinking behind a neon grid played off tape, hollow fuse beads on a pegboard melting together under an iron, pits knocked through desert varnish, a red grid showing through flaking plaster, stones laid row by row along an outline, daylight through leaded glass, burnished gold that mirrors the room, left-handed hatching in iron-gall ink, black paper cut with scissors, wood type printed a hair out of register, red and black plates slipping apart, airbrush fades inside knife-cut friskets, Ben-Day dots on yellowed newsprint, one photo key pulled across hand-painted colour, characters struck through a fading ribbon, flat-shaded triangles dithered to 15 bits, spray drifting past cut card, satin stitches catching the light by their angle, ink lines printed white on Prussian blue, wax scribbles skipping the paper's pits, phosphor glowing behind curved glass, heat leaking out of a kitchen, cobalt fired into tin glaze tile by tile, ochre blown onto rock lit by a fire, 1-bit patterns in an old paint program, slip silhouettes incised to the clay, graphite that never quite reaches black, X-rays adding up through a suitcase, grey cels shot on scratched film, gouge marks in a rolled-up block, a birthday smeared onto tape, seven flat colours lifting off each other, an acorn squashing and stretching through a world drawn as it goes, ballpoint ink blobbing at every corner of a hand-drawn game, inks multiplying through tracing paper on a light box, window cards floating on a pastel field over shadows tinted by it, a vermilion stamp running dry at one end, red ink pooling where the pen slowed down, dyed donkey hide glowing on a lamp-lit screen, gouache scumbled dry over a toned board, knit stitch by stitch, dry pastel blue under a scratchy brush line, with chalk rain on top, a spring garden built leaf by leaf, its tiled roofs and willows mirrored in a jade lake, a roller and a dry brush running out across cream paper, a dusk sky going over to stars above thousands of tiny wildflowers, and a night sea laid stroke by stroke under the one warm light of lava meeting the water. No diffusion model, no API, no stock art. It is just Python with **numpy + Pillow** on a CPU: from 0.1 s (pixel art) to about 45 s (the soft 3D ray tracer) per 1920×1080 image.
---
@@ -138,7 +140,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-nine styles:
+A [Claude Code](https://claude.com/claude-code) skill and a small painting library with seventy styles:
| Style | Module | What makes it read as the real medium |
|---|---|---|
@@ -211,6 +213,7 @@ A [Claude Code](https://claude.com/claude-code) skill and a small painting libra
| **Jiangnan garden (江南园林)** | `lib/jiangnan.py` · `JiangnanGarden` | a lush, finely painted spring garden in the manner of a contemporary digital-gouache illustration, painted back to front the way a landscape painter works: sky, far hills, haze, the trees behind, the buildings, the far bank, the water, things on the water, the foreground, the hanging frame, the seal. Every painting call takes a `far` value that pulls colours toward a pale blue-green haze and flattens their contrast, and haze bands separate the depth planes. The unit of paint is a dab — a pointed leaf, a round petal, a sword blade — and thousands of them are laid at once: Pillow fills every polygon with its own id into a 2× supersampled id map (later ids cover earlier ones), numpy looks the ids up in a colour/alpha table and box-averages back down, so a dab costs well under a microsecond. Trees are sets of clumps, each lit as a dome by one sun from the upper left; a dab takes its colour from a ramp of mixed greens by the light of the clump it sits on, and the tree is built as a gouache painter builds it: a leafy dark underpaint, a mid-dark body, leaves breaking out across the silhouette, small clusters of lit leaves where the light is high, and a few palest dabs on top. Blossom trees are clusters of round petals sorted dark to light over shadowed petals and green leaves, with branches showing through; near branches carry individual five-petal flowers and buds. A weeping willow is a domed crown over hidden boughs with hundreds of hair-thin strands hanging in tresses, darker and bluer behind, lighter and yellower in front. The roof is a real surface S(u, v): concave slope, widening toward the eave, flaring, sharply upturned corners; it is rasterised as a quad mesh and every pixel's (u, v) is recovered by Newton steps, so roll and pan tiles, course lips, tile ends, drip tiles, the soffit with rafter ends, the eave shadow, an openwork ridge with curled ends and hip ridges running up into the flying corners are all shaded analytically. Lattice (grid, lantern frame, cracked ice) is drawn at 3× and lit on its edges; the zigzag bridge, its slabs, piers, posts and pierced panels are projected through a pinhole camera and shaded face by face. The lake mirrors the canvas above the bank line, rippled sideways, blurred vertically, darkened and mixed with the jade body colour toward the viewer; the bridge, a boat and an egret get their own reflections, and lily pads lie foreshortened on the water plane. Dappled leaf shade, a red lantern, a gilded plaque, a tiny worn seal, and a finish of slight softness, a glow around the lights and fine grain complete it |
| **Dry-brush blocks (干刷色块)** | `lib/drybrush.py` · `DryBrushBlocks` | a mid-century poster / gouache-collage illustration built from a few big dry-brushed blocks of colour on cream paper, in a strictly limited palette: forest and sage green, teal-blue, navy, a near-black, vermilion, a touch of sky blue and celadon. Every block is painted in its own brush frame: the mask is rotated so the stroke runs along +u, coverage, value and colour mix are computed there with plain arrays and rotated back, so bristle streaks, lanes and dry ends always follow the stroke. A block is laid in parallel passes of a wide brush or roller, each starting loaded and running dry toward its end by its own amount, optionally broken into overlapping strokes of different lengths and tones; the sides come out nearly straight and the ends as a comb of tines, longer at the dry end. Paint only reaches the paper's tooth where the contact pressure is high enough — the tooth texture is histogram-equalised, so pressure maps straight to coverage — which gives scumbled patches and dry stretches with the paper or the colour below showing through; an overloaded brush stays solid. The backdrop slab behind the subject is laid with a roller tooth (nearly flat, clustered speckle, a crisp loaded edge, stippled dry sides, a few fine scratches); torn-paper pieces tear only along some stretches of their outline, with a pale fibrous rim. A person is a few planes — a jacket whose lit and dark halves are brushed in different directions, a head of skin planes with a darker nose side and a warm tip, rough black glasses, a white beard in dry scumble, a hand seen from the thumb side — and bottles are vertically brushed silhouettes with one light streak and a block label. One small vermilion square sits off to the side, and the finish reproduces the painting like an offset print: slight softness, paper grain, specks knocked out of the darks, a little dust |
| **Twilight storybook (暮色微缩绘本)** | `lib/twilight.py` · `TwilightStorybook` | a tender dusk picture-book page full of miniature detail, at the hour when day turns to night. The dusk sky is a six-stop gradient (lavender, lilac, rose, peach, apricot, gold) whose stops are warped by horizontally stretched noise, so the colours lie in soft layers, with lens-shaped clouds (soft lumpy tops, flatter and crisper bottoms), thin light streaks and a pale low sun. A feathered night field N (0 dusk – 1 night) is laid across the canvas from a wandering boundary: the night gradient, the Milky Way, the stars and the moon are painted with N as their alpha, so the stars thin out across the boundary instead of stopping at a line, and the band between is re-saturated so dusk passes through mauve, violet and indigo rather than grey. Every lit thing painted later — hills, flowers, figures — is shaded by the same field through a linear 3×3 grade (desaturate, then a cool tint), so a white daisy on the night side turns moonlit blue; emissive things and the plate are painted unlit. The Milky Way is an analytic band with cloudy density, a dark rift and thousands of faint stars sampled from it; stars follow a power law, are splatted with sub-pixel accuracy, and the brightest few get four-point sparkles. Hills are misty ranges and patchwork stripes that widen toward the viewer, cut into slanted fields with crop rows and hedge lines, dotted with tiny round trees. The meadow is placed by perspective with rejection sampling — size grows with depth below the crest, density follows coverage — so the crest is thousands of specks and the bottom a few dozen big flowers of eight species, all sorted by the y of their base and rasterised in one pass into a supersampled id map. Flat, cute figures sit in it: a hooded wanderer, a jar of fireflies, a four-panel kite whose string turns from dark to silver against the sky. Over it all lies the language of a scientific plate: fine ink lines drawn at 3×, hatching, drafting dimensions, a scale bar and a circular "detail a" inset, plus tiny lowercase captions set glyph by glyph from a thin hand font; the finish adds softness, bloom, grain, a plum vignette and a torn paper edge |
+| **Hatched nocturne (排线夜景)** | `lib/nocturne.py` · `Nocturne` | a small night print built entirely from short directional strokes, the way a pastel or coloured-pencil artist hatches a nocturne, then mounted on cream paper. The sheet has an equalised tooth, mottling and fibres; the picture is underpainted dark and every mark is clipped to it like a taped edge. A stroke is a centreline integrated through an orientation field (angles mod π, so it never flips halfway), bent a little, with a blunt landing and a tapering tail; tens of thousands are rasterised at once by filling each outline with its own id into a 2× supersampled integer map, then, for every covered pixel, numpy looks up that stroke's colour, start, direction, length and width, recovers the position along and across it, and from that its bristle lane — six lanes per stroke with their own value and load, running dry toward the tail, the pigment only catching the paper where the tooth (dragged along the stroke's own direction) is below the pressure — so every stroke is streaky and grainy and the dark ground shows in hairline gaps. Fields set the "wind": the sky streams diagonally, steam rises with its column and curls only at the rims of its billows, slopes follow the fall lines of the cone, the sea drags in long horizontals that lengthen toward the viewer. Each stroke jitters a little in value and in hue (a true rotation about the grey axis). There is one warm light: point and emissive lights sum into a light map, and the glow is laid as strokes whose landing probability follows light × receptivity — added (screen) for air and glare, painted as light × receptivity for lit surfaces, so a blue-grey cloud turns red-orange rather than pink, and the hottest strokes whiten toward warm white. The hot source is a fan of yellow-white, orange and red strokes round a tiny core. Lava runs as braided rivulets — a walk with momentum that keeps turning toward its end and down the fall line, strands drifting apart, low-angle branches fading out or stopping in a bead — drawn as emission with a tight halo and light strokes on the slope; sparks fly on ballistic arcs. The sea reflects the picture above the waterline as horizontal strokes, stretched, rippled, darkened and laid only where the mirror is bright, plus a glitter column under the light. Two tiny seated figures with a red scarf and a warm rim give the scale; a plate mark, a pencilled title and a smaller note in a thin plain face, a restrained bloom and fine grain finish the print |
Ask Claude to *"draw it yourself"*, *"paint this with code"*, or *"claude绘图"*, and name a style if you like. Claude then:
@@ -359,6 +362,13 @@ Every style has a complete example: `python3 examples/<name>.py out.png --stages
- patchwork stripes in saturated, contrasting colours read as flags;
- a marker ring in a mid tone vanishes on a coral kite — draw markers and leaders in dark ink.
In the inset, keep labels inside the disc and numbers off the lines, and call `finish()` before the first stroke so the stage snapshots match the final.
+- **Hatched nocturne**: no smooth gradient anywhere — every area is several passes of short strokes along one field, a dark dense underlayer, a mid layer and a few sparse light streaks, with the dark ground showing in hairline gaps. Keep it night: deep indigo and navy with exactly one warm light, and lay that light on top as strokes that thin out into the dark, never as a blob; keep the smooth core tiny. Paint lit surfaces as light × receptivity (adding orange to a blue-grey cloud makes it pink), and let the strokes nearest the source go warm white. Inside a billow let the strokes run with the rising column and curl only at its rim, or every puff becomes a whirlpool. Watch for accidental reads:
+ - glowing threads drawn as straight segments with sharp forks are lightning — let them meander with momentum and branch at low angles; too much wander and they loop like spaghetti;
+ - pale sky dashes that are short, bright and evenly spread are falling snow — cluster them in bands and keep them only a little lighter;
+ - isolated one-pixel gaps are dirt — drag the tooth along each stroke so the gaps become streaks;
+ - a rim light on a far rock reads as more lava — keep it faint;
+ - a reflection that samples beyond the picture pulls the cream margin into the sea.
+ Keep the people a few dozen pixels tall with one small accent, and the captions small, grey and in a thin plain face.
### Roadmap
@@ -370,7 +380,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,加上一个小巧的绘图库,内置七十种画风:
| 画风 | 模块 | 为什么看起来像真的 |
|---|---|---|
@@ -443,6 +453,7 @@ Every style has a complete example: `python3 examples/<name>.py out.png --stages
| **江南园林** | `lib/jiangnan.py` · `JiangnanGarden` | 一幅繁茂、细腻的园林春景,像当代的数字水粉插画,照风景插画家的顺序从后往前画:天空、远山、雾、屋后的树、建筑、对岸、水、水上的东西、前景、垂挂的画框、印章。每个画法都带 `far`,越远颜色越往淡青绿的雾色靠、对比越低,深度层之间再铺雾带。颜料的单位是一笔:尖叶、圆花瓣、剑形叶;成千上万笔一次画完:Pillow 把每个多边形按序号填进 2 倍超采样的 id 图(后画的盖住先画的),numpy 按 id 查颜色和透明度再缩回来,一笔不到 1 微秒。树是一组团块,每块当成被左上方太阳照亮的穹顶;每一笔按它所在团块的光从一条混好的绿色色阶取色,整棵树照水粉画家的画法堆出来:叶片打的暗底、中暗的叶、穿出轮廓的叶、光强处一簇簇亮叶、顶上几笔最亮的。繁花树是一簇簇圆花瓣按明暗排序压在暗花瓣和绿叶上,枝条从缝里露出来;近处花枝是一朵朵五瓣花和花苞。垂柳是盖住枝的垂叶树冠,加几百根发丝细的柳丝一绺一绺垂下,后排暗、偏蓝,前排亮、偏黄。屋顶是一张真的曲面 S(u, v):上陡下缓、越往下越宽、翼角外甩、檐角急翘;曲面拆成网格画进 id 图,每个像素用牛顿迭代反求 (u, v),于是筒瓦板瓦、瓦口亮边、瓦当滴水、椽头和檐底、檐影、镂空花脊和卷起的脊头、一直通到翼角尖的戗脊都按解析式上色。槅扇(方格、灯笼锦、冰裂纹)在 3 倍图上画、棂条边上有明暗;九曲桥的石板、桥墩、望柱和镂空栏板经针孔相机投影、逐面上色。湖面按岸线镜像岸上的画面,横向被细浪推开、竖向模糊、压暗,越往近处越多地混进碧绿的本色;桥、船和白鹭各有自己的倒影,睡莲叶按透视压扁躺在水面上。再加墙上桥上的叶影、红灯笼、描金匾额、一方磨损的小红印,最后轻微柔化、亮部光晕和细颗粒 |
| **干刷色块** | `lib/drybrush.py` · `DryBrushBlocks` | mid-century 海报 / 水粉拼贴式的编辑插画:米白纸上几大块干笔刷出的色块,颜色严格限定:森林绿、鼠尾草绿、青蓝、藏蓝、近黑、朱红,外加一点天蓝和淡青瓷。每块颜色在自己的笔刷坐标系里刷:把遮罩转到笔触方向沿 +u,在里面用普通数组算覆盖率、明暗和混色,再转回去,所以鬃毛纹、笔道和干笔收尾永远顺着笔走。一块颜色是一道道平行的宽笔或滚筒,每道起笔饱满、往收笔各干各的,也可以打断成长短不一、各有明暗的短笔;两侧几乎是直边,两端梳成长短不一的毛齿,干的一端更长。颜料只在接触压力够的地方挂上纸纹的齿——纸纹做过直方图均衡,压力直接就是覆盖率——于是有皴擦的斑和干擦的边,露出纸色或下层颜色;蘸满的笔照样实。主体背后的大色板用滚筒刷(近乎平涂、成簇细点、起笔边干净、干的两侧、几道细刮痕);撕纸片只有部分轮廓是撕口,带一圈浅色纤维边。人物是几块面:亮暗两半朝不同方向刷的外套,几块肤色平面拼的头(更暗的鼻侧、暖色鼻头),粗黑框眼镜,干笔皴擦的白胡子,从拇指一侧看的手;瓶子是竖刷的深色剪影,一道高光、一小块标签。一旁一个小朱红方块,最后像这幅画的胶印:轻微柔化、纸纹、暗部零星白点、一点细尘 |
| **暮色微缩绘本** | `lib/twilight.py` · `TwilightStorybook` | 一页温柔的黄昏绘本,满是微缩细节,画的是白天转入黑夜的那一刻。黄昏天空是六段渐变(薰衣草紫、丁香、玫瑰、蜜桃、杏、金),分段位置被横向拉长的噪声扰动,颜色一层层是软的;云是透镜形的带(顶上软而起伏,底部更平更清),加细细的光线和一轮低垂的淡日。一条游走的边界在整幅画上定出带羽化的夜度场 N(0 黄昏 – 1 夜):夜空渐变、银河、星星和月亮按 N 当透明度铺上去,星星越过边界慢慢变稀,不会停在一条线上;交界带补饱和度,黄昏经过淡紫、紫、靛蓝再到黑,不发灰。之后画的受光的东西(山、花、人物)都按同一个场经一个 3×3 线性变换(先降饱和、再偏冷)着色,夜的一侧的白雏菊成了月光蓝;发光的东西和图版不受影响。银河是解析的带,云状密度、一条暗带,几千颗暗星按它的密度抽样;星星是幂律亮度、亚像素溅射,最亮的几颗加四芒星。山是带雾的远山和越近越宽的拼布条纹,切成斜的田,有细垄和树篱线,点着小圆树。花坡按透视拒绝采样:大小随离坡顶的深度增长,密度按覆盖率定,所以坡顶是几千个色点、底边是几十朵八种大花;所有形状按根部的 y 排序,一次光栅化进超采样的 id 图。里面坐着扁平可爱的角色:小斗篷角色、一罐萤火虫、一只四片的风筝,风筝线跟着天色从深变银。上面叠一层科学图版的语言:3 倍图上画的细墨线、排线、制图尺寸标注、比例尺和圆形的「detail a」放大图,再加逐个字母排的细手写体小写英文;最后是柔化、光晕、颗粒、梅紫色暗角和一道撕纸边 |
+| **排线夜景** | `lib/nocturne.py` · `Nocturne` | 一张全部由短方向笔触叠成的小幅夜景版画,像粉彩或彩铅画家排线画夜景,最后装在米白纸上。纸有直方图均衡过的纸纹、斑驳和纤维;画心先铺深色底,每一笔都裁在画心里,像贴了胶带。一笔是在方向场里积分出来的中心线(方向按 mod π 处理,中途不会掉头),带一点弯,落笔钝、收笔尖;几万笔一次画完:每一笔的轮廓按序号填进 2 倍超采样的整数 id 图,numpy 再对每个像素查出那一笔的颜色、起点、方向、长和宽,算出它在笔上的沿笔和横向位置,从而得到笔毛道——每笔 6 道,各有深浅和含量,越往笔尾越干,颜料只落在纸纹(沿这一笔自己的方向拖开)低于压力的地方——所以每一笔都有条纹和颗粒,深色的底从细缝里透出来。方向场定下「风」:天空斜着流,蒸汽顺着柱子往上、只在团块边上卷,山坡顺着锥形山的坡向,海面横着长拖、越近越长。每一笔的明度和色相(绕灰轴真正转色相)都抖一点。全画只有一个暖光:点光源和发光遮罩合成一张光照图,光用笔触铺,落笔的概率跟着「光 × 受光」走——空气和眩光用加光,被照亮的表面直接按「光 × 受光」上色,所以蓝灰的云变成红橙而不是粉,离热源最近的笔再偏向暖白。热源是一小撮黄白、外圈橙红的放射笔触,中间一个很小的白芯。熔岩是分股的细流:带惯性、一直转向终点并顺坡而下的游走,分股越往下分得越开,小角度的支流渐隐或停在一颗亮珠上,画成带紧贴光晕的发光线,再在山坡上铺光笔触;火星沿抛物线飞。海面把水线以上的画面镜像成横向笔触,被浪拉长、被涟漪推开、压暗,只在镜像亮的地方落笔,光源下面再拉一条碎的光柱。两个围着红围巾、带暖色轮廓光的坐着的小人给出尺度;压印的版痕、细体铅笔小标题和更小的说明、克制的辉光和细颗粒收尾 |
对 Claude 说「claude绘图」「你自己画」「用代码画」,也可以指定画风。它会:
1. **先定构图**:层次、焦点、留白,而且画面要图解内容本身;
@@ -541,6 +552,7 @@ python3 examples/bluebook_shared_umbrella.py out.jpg --stages stages/ # 蓝调
python3 examples/jiangnan_spring_water.py out.jpg --stages stages/ # 江南园林:春水园林
python3 examples/drybrush_noodle_counter.py out.jpg --stages stages/ # 干刷色块:面馆
python3 examples/twilight_paper_kite.py out.jpg --stages stages/ # 暮色微缩绘本:夜的边上
+python3 examples/nocturne_lava_sea.py out.jpg --stages stages/ # 排线夜景:熔岩入海
```
### 作画要点(Claude 交图前逐条自查)
@@ -638,6 +650,13 @@ python3 examples/twilight_paper_kite.py out.jpg --stages stages/ # 暮色微
- 饱和、对比强的拼布条纹像一面面旗;
- 中间色调的标记圈落在珊瑚色风筝上就看不见了,标记圈和引线用深墨色。
放大图里标签不出圆片、数字不压线;`finish()` 在画第一笔之前调用,阶段快照才和成品一致。
+- **排线夜景**:任何地方都不要平滑渐变——每片区域都是顺着同一个方向场的几遍短笔触:密的深色底层、中间层、少量稀疏的浅色笔道,深色的底从细缝里透出来。守住夜色:深靛蓝和藏青,只有一个暖光,光要作为一层层越往外越稀的笔触加上去,不要一团光晕;平滑的白芯要很小。被照亮的表面按「光 × 受光」直接上色(橙光加到蓝灰的云上会变粉),离热源最近的笔偏暖白。云团里的笔顺着上升的柱子走,只在团边上卷,不然每一团都是一个漩涡。小心看错:
+ - 直线段加大角度分叉的发光细丝是闪电——让它带惯性地蜿蜒、小角度分叉;游走太大又会打圈成意面;
+ - 天上又短又亮、均匀撒开的浅色笔是在下雪——成片成带地放,只比底色亮一点;
+ - 孤立的单像素缝隙是脏点——纸纹顺着每一笔拖开,缝隙才是一道道的;
+ - 远处礁石上的轮廓光会被看成也有熔岩——要很淡;
+ - 倒影取样跑出画心,会把米白纸边拉进海里。
+ 小人几十像素高、只有一点亮色,题字要小、灰、用细的普通字体。
### 计划
diff --git a/SKILL.md b/SKILL.md
index 047909f..7e8b0f8 100644
--- a/SKILL.md
+++ b/SKILL.md
@@ -1,6 +1,6 @@
---
name: claude绘图
-description: Claude 绘图 / Claude Drawing —— 不借助任何生图模型,由 Claude 用代码一笔一笔「画」出图片(程序化绘画)。内置六十九种画风:中国水墨、水彩、剪纸拼贴、韩国彩铅、日本动漫、编辑风手绘(Riso)、油画厚涂(梵高式流向笔触+颜料浮雕打光)、浮世绘木版画(晕色、木纹、墨线主版、青海波)、像素风(低分辨率+Bayer 抖动+像素字体)、黏土定格(高度图捏出的彩泥+影棚打光)、蓝晒(普鲁士蓝日光晒图,植物剪影透光)、十字绣(Aida 布十字绣+回针绣+缎面绣+法式结)、复古仪器面板(60 年代收音机/仪器正面:柚木、拉丝铝、旋钮、刻度窗、指示灯)、贴纸拼贴·小票(模切乙烯贴纸、热敏小票、和纸胶带、吊牌、橡皮章)、实验笔记本·贴纸(线圈方格本、铅笔图表、荧光笔、红笔圈、便利贴)、黑板板书(墨绿石板、粉笔颗粒、板擦残影、示意图与公式)、赛博朋克(雨夜霓虹街道、玻璃管霓虹招牌、全息广告、湿路面倒影)、卡通手绘(蓝铅笔稿、毛笔线、错位平涂、赛璐璐阴影、逐帧抖线)、等轴 2.5D(正等轴微缩模型、一个太阳照出三面明暗、悬浮数据卡)、单线画(一根不断开的线一笔画完、唯一点睛色)、柔光 3D(光线追踪的糖果色小球海和鼓鼓的软字、景深)、形变动画(一条轮廓依次变形、洋葱皮残影、缓动曲线)、报刊拼贴(牛皮纸、手撕旧报纸、网点老照片、勒索信拼贴字)、弥散玻璃(弥散渐变、磨砂玻璃卡片界面)、包豪斯几何(三原色几何、丝网印刷海报)、复古 Synthwave(切口落日、霓虹网格、镀铬字、录像带质感)、拼豆(钉板上的熔珠小管、熨烫熔合)、岩画(沙漠漆上凿出的凹坑图形、新旧凿痕、剥落)、古埃及墓室壁画(灰泥墙、红格起稿、分栏叙事、象形文字、剥落)、罗马马赛克(石子与玻璃沿轮廓一排排铺、灰缝、燕尾铭牌)、彩色玻璃花窗(哥特尖拱窗、通体着色玻璃、grisaille 彩绘与银染、铅条、透光)、泥金手抄本(羊皮纸、鹅毛笔哥特体、朱红标题、打磨金箔首字母)、达·芬奇手稿(铁胆墨水、左手排线、红粉笔、镜像手写、机械分解图)、剪影(黑纸剪出的侧影小像、薄金粉、椭圆金框)、凸版印刷海报(木活字、红黑双色错版、木刻插图)、苏联构成主义(红黑两版、斜条与楔形、西里尔大字、网点照片拼贴)、装饰艺术 Art Deco(1930 年代喷枪流线型海报、交替射线、阶梯高楼、金色 Deco 字)、黄金时代漫画(毛笔墨线、Ben-Day 网点、四色错版、新闻纸)、波普丝网(多格撞色平涂 + 错位的照相黑版)、ASCII 字符画(行式打印机、绿条连续纸、叠打)、低多边形(1999 年代 3D:平面着色、仿射贴图、逐顶点雾、15 位色抖动)、喷漆模板涂鸦(混凝土墙上多层卡纸模板喷绘、雾化与滴痕)、刺绣徽章(牛仔布上的机绣徽章:填充绣、缎面绣、锁边)、蓝图工程图(描图墨线晒成蓝底白线)、儿童蜡笔画(小孩在糙纸上的蜡笔涂抹)、绿屏终端 CRT(荧光字符画、扫描线、余辉)、热成像(先画温度场再上伪彩色)、代尔夫特蓝瓷砖(锡釉砖上的钴蓝手绘)、洞穴壁画(火光下的赭石、吹喷手印)、1-bit 早期画图软件(黑白整屏、8×8 图案填充)、古希腊黑绘陶瓶(黑釉剪影、刻线、饰带展开图)、铅笔素描(石墨排线、擦笔、边缘只剩线稿)、X 光片(安检透视、轮廓发亮、伪彩)、1930 年代黑白橡皮管动画(白手套、饼切眼、老胶片)、黑白麻胶版画(刻刀减法、手拓发花、套色错版)、VHS 家庭录像(钨丝灯偏色、色度渗色、REC)、扁平矢量(分层几何色块、七色、层间投影)、绘本角色动画(小角色挤压拉伸的真动画)、圆珠笔涂鸦(蓝红圆珠笔线稿、墨团、彩铅、页边涂鸦)、描图纸叠层(灯箱上的黑线底图 + 一张张单色描图纸叠片:正片叠底、套准十字、定位钉、绘图胶带)、粉彩界面 · Pastel UI(产品发布片式的界面画面:纯色粉彩底与大光斑、macOS 窗口卡片、胶囊与粗黑标题色条、状态标签与 ✓ / ✗ 徽章、放大镜、从卡片边探头的扁平小图标)、阅卷批改 · Exam Grading(绿毛毡桌上被红笔批改的答题卡:定位黑块、考号涂卡、得分格与阅卷栏、长尾夹夹住的标准答案卡、油墨不均的朱红印章、立体红笔、波浪线 / 圈 / 引线 / 批注 / 叉 / 圈起来的分数)、皮影戏 · Shadow Puppetry(油灯照亮的幕布上,雕空、透明染色的驴皮关节人偶:镂空纹样、阳刻空脸、雉翎盔头、线结与操纵杆、离幕时虚化的双影;雕花戏台、红漆金字牌匾、红灯笼)、钢笔淡彩 · Pen & Wash(速写小卡上的针管笔线稿 + 松散淡彩:线条抖、出头、不闭合,颜色错位出线、留白缝、干边与颗粒,不铺满的背景色块;大头、圆眼镜、点点眼、红鼻子的呆萌小人;卡片拍在木桌上,旁边放着针管笔和水笔)、复古水粉 · Retro Gouache(复古绘本风的水粉大头像:不透明水粉从暗到亮一层层盖上去,单色背景用干笔皴擦;大红鼻子、腮红、圆眼和大耳朵用几阶色值塑出来;看得见针脚的毛衣和毛线帽,一根根的头发和胡子,毛毡;最后是印刷书页的纸纹)、蓝调绘本 · Blue Picture Book(软蓝色调的现代绘本跨页:几乎只用粉蓝、矢车菊蓝、深青蓝三阶蓝加黑墨和纸白,只点一点珊瑚红、粉色腮红和芥末黄;毛笔 / 墨铅笔线干、抖、断,粗细不匀,线不闭合,暗部用快速来回的乱线排出来;颜色是干蜡笔、粉彩、干水粉,错位出线,纸纹的白点透出来;白粉笔痕压在蓝上,甩点和细尘;背景蓝块毛边、不到纸边;大圆脑袋、带高光的点点眼、点彩腮红和雀斑、火柴腿穿靴子的小人,乱线毛边的白色毛绒动物;最后印在书上:中缝和页码)、江南园林 · Jiangnan Garden(细笔园林春景,数字水粉插画:成千上万片叶形小笔触按一个太阳堆出树冠,暗芯、亮边、一簇簇的高光;白色和淡粉的繁花是一簇簇圆点花瓣,枝条从缝里露出来;垂柳是一绺一绺发丝般的细枝挂满小叶;黛瓦飞檐是真的瓦垄:筒瓦板瓦一行行、檐口瓦当滴水、翘起的翼角和卷起的脊头;粉墙月洞门、冰裂纹漏窗、翡翠绿槅扇和挂落、红灯笼、匾额;九曲石桥、石阶、小木船;碧绿湖面倒映岸上的一切,更柔、更暗,加涟漪和细竖纹;睡莲、白鹭;从前景花枝到雾里青山层层退远,墙上桥上落着叶影;最后一方小红印)、干刷色块 · Dry-Brush Blocks(mid-century 海报 / 水粉拼贴式的编辑插画:米白纸上几大块干笔或滚筒刷出的色块,颜色严格限定在森林绿、鼠尾草绿、青蓝、藏蓝、近黑和朱红,外加一点天蓝、淡青瓷和米色;每块颜色在自己的笔刷坐标系里刷:一道道平行的笔,起笔饱满、收笔干枯,两侧几乎是直边,两端梳成长短不一的毛齿,块里有顺笔的鬃毛纹、皴擦斑和露出来的纸色;背后的大色板用滚筒:近乎平涂、成簇的细点、干的两侧和几道细刮痕;色块像丝网套印或撕纸拼贴一样叠起来,撕口带一圈浅色纤维边;人物拆成几个大块面:亮暗两半朝不同方向刷的外套、几块肤色平面拼的头、粗黑框眼镜、干笔皴擦的白胡子;瓶子是竖刷的深色剪影加一道高光和小块标签;一旁一个小朱红方块;不勾线、不做渐变;最后像胶印:轻微柔化、纸纹、暗部零星白点、纸上细尘)、暮色微缩绘本 · Twilight Storybook(温柔、怀旧的黄昏绘本单页,满是微缩细节:大片粉彩黄昏天空,从顶上的薰衣草紫经玫瑰、蜜桃到地平线的暖金,柔和的平底云带、细细的光线和一轮低垂的淡日;一侧天空已经入夜:星空、带暗带的银河、弯月、流星,昼夜交界经过淡紫和靛蓝,不发灰;下面是一层层粉彩条纹的起伏山丘,拼布似的田、细细的垄、小圆树;前景是几万朵小野花铺成的坡,坡顶是色点,越往下越大:雏菊、矢车菊、虞美人、波斯菊、金盏花、毛茛、羽扇豆、勿忘我,夜的一侧整片变成月光蓝;很小、扁平、可爱的原创角色;上面叠一层科学图版的语言:圆形的「detail a」放大图,细墨线、排线、尺寸标注、标签和比例尺,几行灰色的小写英文手写字;最后是细颗粒、光晕、暗角和底边一道撕纸边)。用户说「claude绘图」「用代码画」「你自己画」「不用生图模型画」「程序化绘画」,或点名以上任一画风(含黏土、彩泥、定格动画、蓝晒、晒图、十字绣、刺绣、复古面板、老式收音机、贴纸、小票、收据、手帐拼贴、实验笔记本、方格本、荧光笔、便利贴、黑板、板书、粉笔、赛博朋克、霓虹、雨夜街道、卡通、手绘卡通、逐帧手绘、抖线、等轴、2.5D、微缩模型、单线画、一笔画、线条动画、柔光 3D、3D 渲染、C4D 风、软糖字、小球海、形变、变形动画、报刊拼贴、剪报、达达、勒索信字、网点印刷、弥散渐变、玻璃拟态、毛玻璃、包豪斯、几何构成、丝网印刷、Synthwave、蒸汽波、合成器浪潮、80 年代复古、拼豆、拼拼豆、熔珠、熨豆、豆豆画、钉板、烫豆、岩画、岩刻、凿刻、石刻、沙漠漆、史前壁刻、大角羊、古埃及、埃及壁画、墓室壁画、法老时代、象形文字、尼罗河、底比斯、罗马马赛克、马赛克镶嵌、镶嵌画、石子拼画、地砖画、古罗马地板、彩色玻璃、彩绘玻璃、花窗、玻璃花窗、教堂花窗、哥特花窗、铅条玻璃、泥金手抄本、手抄本、彩饰手抄本、中世纪手稿、羊皮纸、哥特体、花体首字母、泥金、贴金、星盘、达芬奇、达·芬奇、达芬奇手稿、手稿风、文艺复兴手稿、发明手稿、镜像字、镜像书写、扑翼机、红粉笔、钢笔排线、机械草图、分解图、剪影、剪影肖像、侧影、侧面像、黑纸剪影、剪影小像、椭圆金框、乔治时代肖像、摄政时期肖像、凸版印刷、活版印刷、木活字、铅字海报、马戏团海报、复古海报、老海报、19 世纪海报、双色套印、错版、套色错位、木刻插图、构成主义、苏联海报、苏联构成主义、俄国先锋派、罗德琴科风、红黑海报、照片蒙太奇、照片拼贴海报、西里尔字、装饰艺术、装饰风、流线型、流线型海报、1930 年代海报、旅行海报、铁路海报、火车海报、喷枪画、喷笔画、阶梯高楼、射线背景、盖茨比风、黄金时代漫画、老漫画、复古漫画、美漫封面、漫画封面、Ben-Day 网点、本戴点、网点上色、四色印刷、四色错版、新闻纸、对白框、拟声字、1940 年代漫画、波普、波普艺术、波普丝网、沃霍尔风、丝网版画头像、撞色头像、多格重复头像、六宫格撞色头像、ASCII、字符画、字符艺术、文字画、行式打印机、绿条纸、连续打印纸、针孔打印纸、老电脑打印、叠打、低多边形、低面数、低模、多边形风、千禧年 3D、90 年代 3D、复古 3D 游戏、老游戏截图、PS1 风、N64 风、平面着色、线框、游戏 HUD、飞行游戏、穿环、喷漆、模板涂鸦、镂空模板、喷漆模板、模板喷绘、街头涂鸦、街头艺术、墙绘、滴漆、班克西风格、刺绣徽章、徽章、布章、臂章、刺绣贴、绣标、锁边、牛仔外套徽章、户外徽章、营地徽章、弧形条章、蓝图、工程图、施工图、蜡笔画、儿童画、绿屏终端、CRT、显像管、热成像、热像仪、温度图、代尔夫特、荷兰蓝瓷砖、洞穴壁画、史前壁画、赭石、1-bit、黑白画图软件、MacPaint 风、黑绘、古希腊陶瓶、希腊瓶画、铅笔素描、素描、铅笔画、X 光、X 光片、安检图像、橡皮管动画、黑白卡通、老动画、麻胶版画、黑白版画、藏书票、VHS、家庭录像、录像带、扁平插画、扁平风、矢量插画、绘本动画、角色动画、挤压拉伸、圆珠笔、圆珠笔涂鸦、原子笔、页边涂鸦、课本涂鸦、手画棋盘、描图纸、硫酸纸、叠片、叠层、分色片、灯箱、拷贝台、透光台、套准、定位钉、粉彩界面、粉彩 UI、Dot 风、Dot 那种风格、产品发布会界面、发布会质感、窗口卡片、macOS 窗口、界面卡片、讲解片界面页、小图标探头、阅卷、阅卷批改、批改、判卷、改卷、改作业、答题卡、试卷、考卷、测验卷、红笔批改、红笔打分、打分数、盖章批改、朱红印章、标准答案卡、长尾夹、讲解片评测 / 打分页、皮影、皮影戏、影子戏、驴皮影、灯影戏、皮影人偶、雕花戏台、戏台牌匾、亮相、钢笔淡彩、淡彩、淡彩速写、钢笔淡彩小人、针管笔、勾线笔、针管笔加水彩、线稿上色、速写卡片、速写本小人、水彩小卡、城市速写、街头速写、水笔、自来水笔、复古水粉、水粉、水粉画、不透明水粉、哑光丙烯、复古绘本、绘本插画、绘本大头像、童书插画、复古童书、大头像、大鼻子人物、针织毛衣、麻花毛衣、毛线帽、毛毡帽、卷发、胡子、蓝调绘本、蓝色绘本、软蓝绘本、蓝调童书、软蓝童书插画、蓝色童书插画、蓝色系绘本、限色绘本、蓝白绘本、现代绘本跨页、手绘绘本跨页、绘本跨页、绘本内页、干笔墨线、墨铅笔线、粉彩蜡笔质感绘本、白色毛绒动物、毛绒白熊、点彩腮红、江南园林、园林春景、春水园林、中式园林插画、古典园林插画、国风园林插画、苏式园林、细笔园林、园林风景插画、水榭、临水茶榭、亭台楼阁、粉墙黛瓦、黛瓦白墙、飞檐翘角、翼角起翘、月洞门、漏窗、冰裂纹窗、槅扇、挂落、九曲桥、曲桥、垂柳园林、碧水倒影、园林倒影、睡莲池、数字水粉风景、细腻厚涂风景、干刷色块、干笔色块、干刷、干刷插画、干笔插画、滚筒刷、滚筒色块、色块插画、大色块插画、毛边色块、刷痕色块、粗刷笔触、mid-century、世纪中期插画、中世纪现代插画、复古编辑插画、复古海报插画、水粉拼贴、撕纸色块、限色海报、暮色微缩绘本、暮色绘本、黄昏绘本、微缩绘本、黄昏转夜、昼夜交界、日夜交界、半边黄昏半边星空、粉彩黄昏、粉紫晚霞、黄昏星空、银河插画、野花坡、野花草坡、花海插画、萤火虫、放风筝插画、拼布山丘、条纹田野、小圆树、细节放大图、局部放大图、技术细节小窗、科学图版风插画、手写英文小字、晚安绘本、治愈系绘本插画),或 "draw it yourself", "paint with code", "procedural painting", "watercolor / collage / colored pencil / anime / editorial / impasto oil / ukiyo-e / pixel art / clay / claymation / cyanotype / sun print / cross-stitch / embroidery / retro instrument panel / vintage radio / sticker collage / receipt / lab notebook / graph paper / chalkboard / blackboard / cyberpunk / neon city / cartoon / hand-drawn animation / isometric / 2.5D / continuous line / one-line drawing / soft 3D / 3D render / puffy letters / ball pit / shape morph / morphing / newspaper collage / Dada / ransom note / halftone / glassmorphism / aurora gradient / Bauhaus / geometric poster / screen print / synthwave / retrowave / outrun / perler beads / hama beads / artkal / fuse beads / melty beads / pegboard beads / petroglyph / rock art / rock carving / desert varnish / Egyptian tomb painting / ancient Egypt / hieroglyphs / Theban tomb / Roman mosaic / floor mosaic / tesserae / opus vermiculatum / Pompeii mosaic / stained glass / leaded glass / church window / Gothic window / grisaille / illuminated manuscript / medieval manuscript / book of hours / gold leaf / illuminated initial / blackletter / vellum / astrolabe / da Vinci notebook / Leonardo codex / Renaissance sketchbook / mirror writing / iron-gall ink / red chalk / sanguine / ornithopter / exploded view / inventor's sketch / silhouette / silhouette portrait / cut-paper profile / shade portrait / Georgian portrait / Regency portrait / oval gilt frame / letterpress / wood type / playbill / circus poster / Victorian poster / two-colour misregistration / woodcut poster / constructivism / constructivist poster / Soviet avant-garde / Russian avant-garde / Rodchenko style / photomontage poster / art deco / streamline moderne / 1930s travel poster / railway poster / airbrush poster / sunburst rays / Gatsby style / golden age comic / vintage comic book / comic cover / Ben-Day dots / four-color printing / newsprint / speech balloon / pulp cover / pop art / Warhol-style / pop silkscreen / silkscreen portrait / repeated pop portrait grid / ASCII art / text art / typewriter art / line printer / greenbar / fanfold paper / tractor feed / overstrike / printer plot / low poly / low-poly / retro 3D / 90s 3D game / PS1 style / N64 style / software rasterizer / flat shading / affine texture mapping / vertex fog / game HUD / stencil / stencil graffiti / spray paint stencil / street art / drips and overspray / Banksy-style stencil / embroidered patch / embroidery patch / iron-on patch / sew-on patch / merit badge / camp badge / merrow border / rocker patch / denim jacket patches / blueprint / technical drawing / crayon / kid's drawing / CRT terminal / green screen / thermal camera / thermal imaging / Delft tiles / Delft blue / cave painting / ochre / Lascaux-style / 1-bit / MacPaint-style / black-figure / Greek vase / pencil drawing / graphite / X-ray / baggage scanner / rubber hose / 1930s cartoon / linocut / lino print / VHS / home video / flat vector / flat illustration / storybook animation / squash and stretch / ballpoint / biro / ballpoint doodle / margin doodles / hand-drawn board game / overlay sheets / tracing-paper overlays / light box / colour separations / registration marks / acetate overlay / pastel UI / Dot-style product film / launch-film interface / macOS window cards / exam grading / grading an answer sheet / red-pen marking / graded test paper / rubber-stamped answer sheet / shadow puppet / shadow puppetry / Chinese shadow play / leather shadow puppets / backlit puppet screen / pen and wash / pen & wash / line and wash / ink and watercolour / ink and watercolor / fineliner sketch / fineliner and watercolour / sketchbook characters / sketch cards / urban sketching / water brush / gouache / retro gouache / gouache portrait / gouache illustration / opaque gouache / matte acrylic / picture-book portrait / vintage picture book / retro children's book illustration / mid-century children's book / big-nosed character portrait / cable-knit sweater / knitted bobble hat / blue picture book / soft blue picture book / soft-blue children's book illustration / modern picture book / limited-palette picture book / picture-book spread / scratchy ink line / dry-brush ink line / ink pencil line / crayon and pastel texture / chalky white marks / blue and coral palette / fluffy white bear / Jiangnan garden / Chinese garden / classical Chinese garden illustration / Chinese water garden / spring garden illustration / lush painterly garden / waterside pavilion / moon gate / lattice windows / zigzag bridge / weeping willow garden / upturned eaves / grey-tiled roof / blossom trees and reflections / lily pond with egrets / digital gouache landscape / dry-brush blocks / dry brush illustration / dry-brushed colour blocks / roller texture / brush-textured shapes / mid-century illustration / mid-century modern poster / mid-century editorial illustration / gouache collage / torn-paper collage poster / limited palette poster / scumbled texture / vintage book cover illustration / twilight storybook / dusk picture book / dusk to night sky / day and night split sky / pastel sunset sky / Milky Way illustration / wildflower meadow / wildflower hill / patchwork hills / tiny round trees / fireflies / paper kite / magnified detail inset / detail callout circle / scientific plate overlay / handwritten lowercase captions / cozy miniature illustration / bedtime story illustration without an image model" 时使用;也用于需要逐步画出(draw-on)动画的插画。单独说「剪纸」指剪纸拼贴、「刺绣」指十字绣、「丝网印刷 / screen print」指包豪斯几何;「打马赛克」是打码,不是马赛克画风;单说「蓝图」指蓝图工程图,「蓝晒 / 晒图」仍指蓝晒;「铅笔 / 素描」指铅笔素描,「彩铅」指韩国彩铅;「像素」仍指像素风,「1-bit / 黑白画图软件」指 1-bit 早期画图软件;「霓虹」仍指赛博朋克;「喷漆 / 街头涂鸦」仍指喷漆模板涂鸦,「圆珠笔 / 随手涂鸦 / 页边涂鸦」指圆珠笔涂鸦;「描图纸 / 硫酸纸 / 叠片 / 灯箱」指描图纸叠层(蓝图工程图那张描图布是晒成蓝图的,不是叠片);「Dot 风 / 粉彩界面 / 窗口卡片 / 发布会界面」指粉彩界面(纯色底 + 白色实心窗口卡片),要磨砂玻璃和弥散渐变仍用弥散玻璃;「阅卷 / 批改 / 答题卡 / 判卷 / 红笔打分」指阅卷批改,实验记录里的红笔圈和便利贴仍用实验笔记本,带「已付」橡皮章的小票拼贴仍用贴纸拼贴 · 小票;「皮影 / 皮影戏 / 影子戏」指皮影戏(透光的彩色驴皮人偶),黑纸剪出的侧影小像仍用剪影,彩纸剪贴仍用剪纸拼贴。「钢笔淡彩 / 淡彩速写 / 针管笔加水彩 / 线稿上色的速写小卡」指钢笔淡彩;单说「水彩」仍指水彩(风景、花卉的大片晕染),蓝铅笔稿 + 毛笔线 + 赛璐璐阴影的拟人小物仍用卡通手绘,「素描 / 铅笔」仍指铅笔素描。「水粉 / 复古水粉 / 绘本大头像 / 复古童书插画」指复古水粉(不透明水粉画的特写大头像);梵高式厚涂的风景、名画感仍用油画厚涂,扁平矢量、会挤压拉伸的小角色动画(「绘本动画」)仍用绘本角色动画,针管笔线稿加淡彩的速写小卡仍用钢笔淡彩,撞色多格的头像仍用波普丝网。「蓝调绘本 / 软蓝绘本 / 蓝色童书插画 / 绘本跨页」指蓝调绘本(软蓝限色的现代绘本跨页:干笔墨线 + 干蜡笔粉彩上色 + 白粉笔痕);单说「绘本」仍指绘本角色动画,「水粉 / 绘本大头像」仍指复古水粉,「编辑风 / Riso」仍指编辑风手绘,针管笔线稿加淡彩的速写小卡仍用钢笔淡彩,小孩自己画的蜡笔画仍用儿童蜡笔画。「江南园林 / 园林春景 / 中式园林插画 / 粉墙黛瓦 / 飞檐 / 月洞门 / 九曲桥」指江南园林(细笔数字水粉的园林春景:叶形小笔触堆出的繁茂树冠、繁花、垂柳、黛瓦飞檐、碧水倒影、层层远山);单说「水墨 / 山水」仍指水墨,单说「水彩」仍指水彩,动漫背景 / 赛璐璐天空仍指日本动漫,浮世绘仍是浮世绘;梵高式厚涂的风景仍用油画厚涂,皮影人偶的一场戏仍用皮影戏。「干刷色块 / 干笔色块 / 滚筒色块 / mid-century 海报插画」指干刷色块(米白纸上几大块干笔或滚筒刷出的限色色块,人物拆成几个大块面,背后一块纯色板、一旁一个小红方块);单说「水粉 / 绘本大头像」仍指复古水粉,「剪纸 / 彩纸拼贴」仍指剪纸拼贴,「丝网印刷 / screen print」仍指包豪斯几何,「Riso / 编辑风」仍指编辑风手绘,没有笔触的平滑几何色块仍用扁平矢量。「暮色微缩绘本 / 暮色绘本 / 黄昏转夜 / 昼夜交界 / 野花坡 / 细节放大图」指暮色微缩绘本(粉彩黄昏转入银河夜空、拼布山丘、几万朵小野花、很小的原创角色,加圆形放大图和手写小字);单说「绘本」仍指绘本角色动画,「蓝调绘本 / 软蓝绘本」仍指蓝调绘本,赛璐璐天空和夏日少年感仍用日本动漫,大片晕染的风景仍用水彩,整页的机械分解手稿仍用达·芬奇手稿,剖面和施工图仍用蓝图工程图。
+description: Claude 绘图 / Claude Drawing —— 不借助任何生图模型,由 Claude 用代码一笔一笔「画」出图片(程序化绘画)。内置七十种画风:中国水墨、水彩、剪纸拼贴、韩国彩铅、日本动漫、编辑风手绘(Riso)、油画厚涂(梵高式流向笔触+颜料浮雕打光)、浮世绘木版画(晕色、木纹、墨线主版、青海波)、像素风(低分辨率+Bayer 抖动+像素字体)、黏土定格(高度图捏出的彩泥+影棚打光)、蓝晒(普鲁士蓝日光晒图,植物剪影透光)、十字绣(Aida 布十字绣+回针绣+缎面绣+法式结)、复古仪器面板(60 年代收音机/仪器正面:柚木、拉丝铝、旋钮、刻度窗、指示灯)、贴纸拼贴·小票(模切乙烯贴纸、热敏小票、和纸胶带、吊牌、橡皮章)、实验笔记本·贴纸(线圈方格本、铅笔图表、荧光笔、红笔圈、便利贴)、黑板板书(墨绿石板、粉笔颗粒、板擦残影、示意图与公式)、赛博朋克(雨夜霓虹街道、玻璃管霓虹招牌、全息广告、湿路面倒影)、卡通手绘(蓝铅笔稿、毛笔线、错位平涂、赛璐璐阴影、逐帧抖线)、等轴 2.5D(正等轴微缩模型、一个太阳照出三面明暗、悬浮数据卡)、单线画(一根不断开的线一笔画完、唯一点睛色)、柔光 3D(光线追踪的糖果色小球海和鼓鼓的软字、景深)、形变动画(一条轮廓依次变形、洋葱皮残影、缓动曲线)、报刊拼贴(牛皮纸、手撕旧报纸、网点老照片、勒索信拼贴字)、弥散玻璃(弥散渐变、磨砂玻璃卡片界面)、包豪斯几何(三原色几何、丝网印刷海报)、复古 Synthwave(切口落日、霓虹网格、镀铬字、录像带质感)、拼豆(钉板上的熔珠小管、熨烫熔合)、岩画(沙漠漆上凿出的凹坑图形、新旧凿痕、剥落)、古埃及墓室壁画(灰泥墙、红格起稿、分栏叙事、象形文字、剥落)、罗马马赛克(石子与玻璃沿轮廓一排排铺、灰缝、燕尾铭牌)、彩色玻璃花窗(哥特尖拱窗、通体着色玻璃、grisaille 彩绘与银染、铅条、透光)、泥金手抄本(羊皮纸、鹅毛笔哥特体、朱红标题、打磨金箔首字母)、达·芬奇手稿(铁胆墨水、左手排线、红粉笔、镜像手写、机械分解图)、剪影(黑纸剪出的侧影小像、薄金粉、椭圆金框)、凸版印刷海报(木活字、红黑双色错版、木刻插图)、苏联构成主义(红黑两版、斜条与楔形、西里尔大字、网点照片拼贴)、装饰艺术 Art Deco(1930 年代喷枪流线型海报、交替射线、阶梯高楼、金色 Deco 字)、黄金时代漫画(毛笔墨线、Ben-Day 网点、四色错版、新闻纸)、波普丝网(多格撞色平涂 + 错位的照相黑版)、ASCII 字符画(行式打印机、绿条连续纸、叠打)、低多边形(1999 年代 3D:平面着色、仿射贴图、逐顶点雾、15 位色抖动)、喷漆模板涂鸦(混凝土墙上多层卡纸模板喷绘、雾化与滴痕)、刺绣徽章(牛仔布上的机绣徽章:填充绣、缎面绣、锁边)、蓝图工程图(描图墨线晒成蓝底白线)、儿童蜡笔画(小孩在糙纸上的蜡笔涂抹)、绿屏终端 CRT(荧光字符画、扫描线、余辉)、热成像(先画温度场再上伪彩色)、代尔夫特蓝瓷砖(锡釉砖上的钴蓝手绘)、洞穴壁画(火光下的赭石、吹喷手印)、1-bit 早期画图软件(黑白整屏、8×8 图案填充)、古希腊黑绘陶瓶(黑釉剪影、刻线、饰带展开图)、铅笔素描(石墨排线、擦笔、边缘只剩线稿)、X 光片(安检透视、轮廓发亮、伪彩)、1930 年代黑白橡皮管动画(白手套、饼切眼、老胶片)、黑白麻胶版画(刻刀减法、手拓发花、套色错版)、VHS 家庭录像(钨丝灯偏色、色度渗色、REC)、扁平矢量(分层几何色块、七色、层间投影)、绘本角色动画(小角色挤压拉伸的真动画)、圆珠笔涂鸦(蓝红圆珠笔线稿、墨团、彩铅、页边涂鸦)、描图纸叠层(灯箱上的黑线底图 + 一张张单色描图纸叠片:正片叠底、套准十字、定位钉、绘图胶带)、粉彩界面 · Pastel UI(产品发布片式的界面画面:纯色粉彩底与大光斑、macOS 窗口卡片、胶囊与粗黑标题色条、状态标签与 ✓ / ✗ 徽章、放大镜、从卡片边探头的扁平小图标)、阅卷批改 · Exam Grading(绿毛毡桌上被红笔批改的答题卡:定位黑块、考号涂卡、得分格与阅卷栏、长尾夹夹住的标准答案卡、油墨不均的朱红印章、立体红笔、波浪线 / 圈 / 引线 / 批注 / 叉 / 圈起来的分数)、皮影戏 · Shadow Puppetry(油灯照亮的幕布上,雕空、透明染色的驴皮关节人偶:镂空纹样、阳刻空脸、雉翎盔头、线结与操纵杆、离幕时虚化的双影;雕花戏台、红漆金字牌匾、红灯笼)、钢笔淡彩 · Pen & Wash(速写小卡上的针管笔线稿 + 松散淡彩:线条抖、出头、不闭合,颜色错位出线、留白缝、干边与颗粒,不铺满的背景色块;大头、圆眼镜、点点眼、红鼻子的呆萌小人;卡片拍在木桌上,旁边放着针管笔和水笔)、复古水粉 · Retro Gouache(复古绘本风的水粉大头像:不透明水粉从暗到亮一层层盖上去,单色背景用干笔皴擦;大红鼻子、腮红、圆眼和大耳朵用几阶色值塑出来;看得见针脚的毛衣和毛线帽,一根根的头发和胡子,毛毡;最后是印刷书页的纸纹)、蓝调绘本 · Blue Picture Book(软蓝色调的现代绘本跨页:几乎只用粉蓝、矢车菊蓝、深青蓝三阶蓝加黑墨和纸白,只点一点珊瑚红、粉色腮红和芥末黄;毛笔 / 墨铅笔线干、抖、断,粗细不匀,线不闭合,暗部用快速来回的乱线排出来;颜色是干蜡笔、粉彩、干水粉,错位出线,纸纹的白点透出来;白粉笔痕压在蓝上,甩点和细尘;背景蓝块毛边、不到纸边;大圆脑袋、带高光的点点眼、点彩腮红和雀斑、火柴腿穿靴子的小人,乱线毛边的白色毛绒动物;最后印在书上:中缝和页码)、江南园林 · Jiangnan Garden(细笔园林春景,数字水粉插画:成千上万片叶形小笔触按一个太阳堆出树冠,暗芯、亮边、一簇簇的高光;白色和淡粉的繁花是一簇簇圆点花瓣,枝条从缝里露出来;垂柳是一绺一绺发丝般的细枝挂满小叶;黛瓦飞檐是真的瓦垄:筒瓦板瓦一行行、檐口瓦当滴水、翘起的翼角和卷起的脊头;粉墙月洞门、冰裂纹漏窗、翡翠绿槅扇和挂落、红灯笼、匾额;九曲石桥、石阶、小木船;碧绿湖面倒映岸上的一切,更柔、更暗,加涟漪和细竖纹;睡莲、白鹭;从前景花枝到雾里青山层层退远,墙上桥上落着叶影;最后一方小红印)、干刷色块 · Dry-Brush Blocks(mid-century 海报 / 水粉拼贴式的编辑插画:米白纸上几大块干笔或滚筒刷出的色块,颜色严格限定在森林绿、鼠尾草绿、青蓝、藏蓝、近黑和朱红,外加一点天蓝、淡青瓷和米色;每块颜色在自己的笔刷坐标系里刷:一道道平行的笔,起笔饱满、收笔干枯,两侧几乎是直边,两端梳成长短不一的毛齿,块里有顺笔的鬃毛纹、皴擦斑和露出来的纸色;背后的大色板用滚筒:近乎平涂、成簇的细点、干的两侧和几道细刮痕;色块像丝网套印或撕纸拼贴一样叠起来,撕口带一圈浅色纤维边;人物拆成几个大块面:亮暗两半朝不同方向刷的外套、几块肤色平面拼的头、粗黑框眼镜、干笔皴擦的白胡子;瓶子是竖刷的深色剪影加一道高光和小块标签;一旁一个小朱红方块;不勾线、不做渐变;最后像胶印:轻微柔化、纸纹、暗部零星白点、纸上细尘)、暮色微缩绘本 · Twilight Storybook(温柔、怀旧的黄昏绘本单页,满是微缩细节:大片粉彩黄昏天空,从顶上的薰衣草紫经玫瑰、蜜桃到地平线的暖金,柔和的平底云带、细细的光线和一轮低垂的淡日;一侧天空已经入夜:星空、带暗带的银河、弯月、流星,昼夜交界经过淡紫和靛蓝,不发灰;下面是一层层粉彩条纹的起伏山丘,拼布似的田、细细的垄、小圆树;前景是几万朵小野花铺成的坡,坡顶是色点,越往下越大:雏菊、矢车菊、虞美人、波斯菊、金盏花、毛茛、羽扇豆、勿忘我,夜的一侧整片变成月光蓝;很小、扁平、可爱的原创角色;上面叠一层科学图版的语言:圆形的「detail a」放大图,细墨线、排线、尺寸标注、标签和比例尺,几行灰色的小写英文手写字;最后是细颗粒、光晕、暗角和底边一道撕纸边)、排线夜景 · Hatched Nocturne(彩铅 / 色粉排线式的小幅夜景版画:天空、云、山和海全由密密的短笔触叠成,每片区域的笔触顺着同一股「风」走——天空斜着流、蒸汽绕着云团卷、山坡顺着坡向、海面横着长拖,每一笔色相和明度都差一点,笔毛分道、拖干的笔尾、纸纹里漏出的细缝,没有一处平滑渐变;深靛蓝、藏青、冷灰蓝的夜色里只有一个暖色光源,光是一层层加上去的发光笔触:核心黄白、外圈橙红、再外是被照亮的笔触,被照亮的蒸汽按「光 × 受光」上色,所以是红橙而不是粉;发光的细丝(会蜿蜒、分股、末端亮珠)、火星、星点;海面上被横向笔触打碎的倒影和光柱;几十像素高的小人靠一点亮色(围巾)点出来;最后装裱成小版画:米白纸边、压印的版痕、左下铅笔小标题、右下更小的说明,用细的普通字体)。用户说「claude绘图」「用代码画」「你自己画」「不用生图模型画」「程序化绘画」,或点名以上任一画风(含黏土、彩泥、定格动画、蓝晒、晒图、十字绣、刺绣、复古面板、老式收音机、贴纸、小票、收据、手帐拼贴、实验笔记本、方格本、荧光笔、便利贴、黑板、板书、粉笔、赛博朋克、霓虹、雨夜街道、卡通、手绘卡通、逐帧手绘、抖线、等轴、2.5D、微缩模型、单线画、一笔画、线条动画、柔光 3D、3D 渲染、C4D 风、软糖字、小球海、形变、变形动画、报刊拼贴、剪报、达达、勒索信字、网点印刷、弥散渐变、玻璃拟态、毛玻璃、包豪斯、几何构成、丝网印刷、Synthwave、蒸汽波、合成器浪潮、80 年代复古、拼豆、拼拼豆、熔珠、熨豆、豆豆画、钉板、烫豆、岩画、岩刻、凿刻、石刻、沙漠漆、史前壁刻、大角羊、古埃及、埃及壁画、墓室壁画、法老时代、象形文字、尼罗河、底比斯、罗马马赛克、马赛克镶嵌、镶嵌画、石子拼画、地砖画、古罗马地板、彩色玻璃、彩绘玻璃、花窗、玻璃花窗、教堂花窗、哥特花窗、铅条玻璃、泥金手抄本、手抄本、彩饰手抄本、中世纪手稿、羊皮纸、哥特体、花体首字母、泥金、贴金、星盘、达芬奇、达·芬奇、达芬奇手稿、手稿风、文艺复兴手稿、发明手稿、镜像字、镜像书写、扑翼机、红粉笔、钢笔排线、机械草图、分解图、剪影、剪影肖像、侧影、侧面像、黑纸剪影、剪影小像、椭圆金框、乔治时代肖像、摄政时期肖像、凸版印刷、活版印刷、木活字、铅字海报、马戏团海报、复古海报、老海报、19 世纪海报、双色套印、错版、套色错位、木刻插图、构成主义、苏联海报、苏联构成主义、俄国先锋派、罗德琴科风、红黑海报、照片蒙太奇、照片拼贴海报、西里尔字、装饰艺术、装饰风、流线型、流线型海报、1930 年代海报、旅行海报、铁路海报、火车海报、喷枪画、喷笔画、阶梯高楼、射线背景、盖茨比风、黄金时代漫画、老漫画、复古漫画、美漫封面、漫画封面、Ben-Day 网点、本戴点、网点上色、四色印刷、四色错版、新闻纸、对白框、拟声字、1940 年代漫画、波普、波普艺术、波普丝网、沃霍尔风、丝网版画头像、撞色头像、多格重复头像、六宫格撞色头像、ASCII、字符画、字符艺术、文字画、行式打印机、绿条纸、连续打印纸、针孔打印纸、老电脑打印、叠打、低多边形、低面数、低模、多边形风、千禧年 3D、90 年代 3D、复古 3D 游戏、老游戏截图、PS1 风、N64 风、平面着色、线框、游戏 HUD、飞行游戏、穿环、喷漆、模板涂鸦、镂空模板、喷漆模板、模板喷绘、街头涂鸦、街头艺术、墙绘、滴漆、班克西风格、刺绣徽章、徽章、布章、臂章、刺绣贴、绣标、锁边、牛仔外套徽章、户外徽章、营地徽章、弧形条章、蓝图、工程图、施工图、蜡笔画、儿童画、绿屏终端、CRT、显像管、热成像、热像仪、温度图、代尔夫特、荷兰蓝瓷砖、洞穴壁画、史前壁画、赭石、1-bit、黑白画图软件、MacPaint 风、黑绘、古希腊陶瓶、希腊瓶画、铅笔素描、素描、铅笔画、X 光、X 光片、安检图像、橡皮管动画、黑白卡通、老动画、麻胶版画、黑白版画、藏书票、VHS、家庭录像、录像带、扁平插画、扁平风、矢量插画、绘本动画、角色动画、挤压拉伸、圆珠笔、圆珠笔涂鸦、原子笔、页边涂鸦、课本涂鸦、手画棋盘、描图纸、硫酸纸、叠片、叠层、分色片、灯箱、拷贝台、透光台、套准、定位钉、粉彩界面、粉彩 UI、Dot 风、Dot 那种风格、产品发布会界面、发布会质感、窗口卡片、macOS 窗口、界面卡片、讲解片界面页、小图标探头、阅卷、阅卷批改、批改、判卷、改卷、改作业、答题卡、试卷、考卷、测验卷、红笔批改、红笔打分、打分数、盖章批改、朱红印章、标准答案卡、长尾夹、讲解片评测 / 打分页、皮影、皮影戏、影子戏、驴皮影、灯影戏、皮影人偶、雕花戏台、戏台牌匾、亮相、钢笔淡彩、淡彩、淡彩速写、钢笔淡彩小人、针管笔、勾线笔、针管笔加水彩、线稿上色、速写卡片、速写本小人、水彩小卡、城市速写、街头速写、水笔、自来水笔、复古水粉、水粉、水粉画、不透明水粉、哑光丙烯、复古绘本、绘本插画、绘本大头像、童书插画、复古童书、大头像、大鼻子人物、针织毛衣、麻花毛衣、毛线帽、毛毡帽、卷发、胡子、蓝调绘本、蓝色绘本、软蓝绘本、蓝调童书、软蓝童书插画、蓝色童书插画、蓝色系绘本、限色绘本、蓝白绘本、现代绘本跨页、手绘绘本跨页、绘本跨页、绘本内页、干笔墨线、墨铅笔线、粉彩蜡笔质感绘本、白色毛绒动物、毛绒白熊、点彩腮红、江南园林、园林春景、春水园林、中式园林插画、古典园林插画、国风园林插画、苏式园林、细笔园林、园林风景插画、水榭、临水茶榭、亭台楼阁、粉墙黛瓦、黛瓦白墙、飞檐翘角、翼角起翘、月洞门、漏窗、冰裂纹窗、槅扇、挂落、九曲桥、曲桥、垂柳园林、碧水倒影、园林倒影、睡莲池、数字水粉风景、细腻厚涂风景、干刷色块、干笔色块、干刷、干刷插画、干笔插画、滚筒刷、滚筒色块、色块插画、大色块插画、毛边色块、刷痕色块、粗刷笔触、mid-century、世纪中期插画、中世纪现代插画、复古编辑插画、复古海报插画、水粉拼贴、撕纸色块、限色海报、暮色微缩绘本、暮色绘本、黄昏绘本、微缩绘本、黄昏转夜、昼夜交界、日夜交界、半边黄昏半边星空、粉彩黄昏、粉紫晚霞、黄昏星空、银河插画、野花坡、野花草坡、花海插画、萤火虫、放风筝插画、拼布山丘、条纹田野、小圆树、细节放大图、局部放大图、技术细节小窗、科学图版风插画、手写英文小字、晚安绘本、治愈系绘本插画、排线夜景、排线风夜景、彩铅夜景、色粉夜景、粉彩排线、短笔触夜景、笔触夜空、方向笔触、夜景版画、小版画、限量版画风、版画装裱、版痕、纸边标题、铅笔题字、夜景插画、夜空插画、深蓝夜景、靛蓝夜空、冷暖对比夜景、唯一暖光、夜里的火光、发光的云、被照亮的云、红色精灵闪电、精灵闪电、火山夜景、熔岩入海、熔岩、岩浆、火山喷发插画、海上风暴、海面倒影、光柱倒影、火星飞溅、星点、看海的人、礁石上的人、远处的小人、小人比例尺、雪夜篝火、渔火),或 "draw it yourself", "paint with code", "procedural painting", "watercolor / collage / colored pencil / anime / editorial / impasto oil / ukiyo-e / pixel art / clay / claymation / cyanotype / sun print / cross-stitch / embroidery / retro instrument panel / vintage radio / sticker collage / receipt / lab notebook / graph paper / chalkboard / blackboard / cyberpunk / neon city / cartoon / hand-drawn animation / isometric / 2.5D / continuous line / one-line drawing / soft 3D / 3D render / puffy letters / ball pit / shape morph / morphing / newspaper collage / Dada / ransom note / halftone / glassmorphism / aurora gradient / Bauhaus / geometric poster / screen print / synthwave / retrowave / outrun / perler beads / hama beads / artkal / fuse beads / melty beads / pegboard beads / petroglyph / rock art / rock carving / desert varnish / Egyptian tomb painting / ancient Egypt / hieroglyphs / Theban tomb / Roman mosaic / floor mosaic / tesserae / opus vermiculatum / Pompeii mosaic / stained glass / leaded glass / church window / Gothic window / grisaille / illuminated manuscript / medieval manuscript / book of hours / gold leaf / illuminated initial / blackletter / vellum / astrolabe / da Vinci notebook / Leonardo codex / Renaissance sketchbook / mirror writing / iron-gall ink / red chalk / sanguine / ornithopter / exploded view / inventor's sketch / silhouette / silhouette portrait / cut-paper profile / shade portrait / Georgian portrait / Regency portrait / oval gilt frame / letterpress / wood type / playbill / circus poster / Victorian poster / two-colour misregistration / woodcut poster / constructivism / constructivist poster / Soviet avant-garde / Russian avant-garde / Rodchenko style / photomontage poster / art deco / streamline moderne / 1930s travel poster / railway poster / airbrush poster / sunburst rays / Gatsby style / golden age comic / vintage comic book / comic cover / Ben-Day dots / four-color printing / newsprint / speech balloon / pulp cover / pop art / Warhol-style / pop silkscreen / silkscreen portrait / repeated pop portrait grid / ASCII art / text art / typewriter art / line printer / greenbar / fanfold paper / tractor feed / overstrike / printer plot / low poly / low-poly / retro 3D / 90s 3D game / PS1 style / N64 style / software rasterizer / flat shading / affine texture mapping / vertex fog / game HUD / stencil / stencil graffiti / spray paint stencil / street art / drips and overspray / Banksy-style stencil / embroidered patch / embroidery patch / iron-on patch / sew-on patch / merit badge / camp badge / merrow border / rocker patch / denim jacket patches / blueprint / technical drawing / crayon / kid's drawing / CRT terminal / green screen / thermal camera / thermal imaging / Delft tiles / Delft blue / cave painting / ochre / Lascaux-style / 1-bit / MacPaint-style / black-figure / Greek vase / pencil drawing / graphite / X-ray / baggage scanner / rubber hose / 1930s cartoon / linocut / lino print / VHS / home video / flat vector / flat illustration / storybook animation / squash and stretch / ballpoint / biro / ballpoint doodle / margin doodles / hand-drawn board game / overlay sheets / tracing-paper overlays / light box / colour separations / registration marks / acetate overlay / pastel UI / Dot-style product film / launch-film interface / macOS window cards / exam grading / grading an answer sheet / red-pen marking / graded test paper / rubber-stamped answer sheet / shadow puppet / shadow puppetry / Chinese shadow play / leather shadow puppets / backlit puppet screen / pen and wash / pen & wash / line and wash / ink and watercolour / ink and watercolor / fineliner sketch / fineliner and watercolour / sketchbook characters / sketch cards / urban sketching / water brush / gouache / retro gouache / gouache portrait / gouache illustration / opaque gouache / matte acrylic / picture-book portrait / vintage picture book / retro children's book illustration / mid-century children's book / big-nosed character portrait / cable-knit sweater / knitted bobble hat / blue picture book / soft blue picture book / soft-blue children's book illustration / modern picture book / limited-palette picture book / picture-book spread / scratchy ink line / dry-brush ink line / ink pencil line / crayon and pastel texture / chalky white marks / blue and coral palette / fluffy white bear / Jiangnan garden / Chinese garden / classical Chinese garden illustration / Chinese water garden / spring garden illustration / lush painterly garden / waterside pavilion / moon gate / lattice windows / zigzag bridge / weeping willow garden / upturned eaves / grey-tiled roof / blossom trees and reflections / lily pond with egrets / digital gouache landscape / dry-brush blocks / dry brush illustration / dry-brushed colour blocks / roller texture / brush-textured shapes / mid-century illustration / mid-century modern poster / mid-century editorial illustration / gouache collage / torn-paper collage poster / limited palette poster / scumbled texture / vintage book cover illustration / twilight storybook / dusk picture book / dusk to night sky / day and night split sky / pastel sunset sky / Milky Way illustration / wildflower meadow / wildflower hill / patchwork hills / tiny round trees / fireflies / paper kite / magnified detail inset / detail callout circle / scientific plate overlay / handwritten lowercase captions / cozy miniature illustration / bedtime story illustration / hatched nocturne / hatched night scene / pastel hatching night / coloured-pencil nocturne / directional strokes / short brush strokes sky / night print with margins / small art print / plate mark / pencilled title and caption / indigo night with one warm light / glowing cloud lit from below / red sprites / lava entering the sea / volcano at night / glowing threads and sparks / broken reflection on the sea / tiny figures for scale without an image model" 时使用;也用于需要逐步画出(draw-on)动画的插画。单独说「剪纸」指剪纸拼贴、「刺绣」指十字绣、「丝网印刷 / screen print」指包豪斯几何;「打马赛克」是打码,不是马赛克画风;单说「蓝图」指蓝图工程图,「蓝晒 / 晒图」仍指蓝晒;「铅笔 / 素描」指铅笔素描,「彩铅」指韩国彩铅;「像素」仍指像素风,「1-bit / 黑白画图软件」指 1-bit 早期画图软件;「霓虹」仍指赛博朋克;「喷漆 / 街头涂鸦」仍指喷漆模板涂鸦,「圆珠笔 / 随手涂鸦 / 页边涂鸦」指圆珠笔涂鸦;「描图纸 / 硫酸纸 / 叠片 / 灯箱」指描图纸叠层(蓝图工程图那张描图布是晒成蓝图的,不是叠片);「Dot 风 / 粉彩界面 / 窗口卡片 / 发布会界面」指粉彩界面(纯色底 + 白色实心窗口卡片),要磨砂玻璃和弥散渐变仍用弥散玻璃;「阅卷 / 批改 / 答题卡 / 判卷 / 红笔打分」指阅卷批改,实验记录里的红笔圈和便利贴仍用实验笔记本,带「已付」橡皮章的小票拼贴仍用贴纸拼贴 · 小票;「皮影 / 皮影戏 / 影子戏」指皮影戏(透光的彩色驴皮人偶),黑纸剪出的侧影小像仍用剪影,彩纸剪贴仍用剪纸拼贴。「钢笔淡彩 / 淡彩速写 / 针管笔加水彩 / 线稿上色的速写小卡」指钢笔淡彩;单说「水彩」仍指水彩(风景、花卉的大片晕染),蓝铅笔稿 + 毛笔线 + 赛璐璐阴影的拟人小物仍用卡通手绘,「素描 / 铅笔」仍指铅笔素描。「水粉 / 复古水粉 / 绘本大头像 / 复古童书插画」指复古水粉(不透明水粉画的特写大头像);梵高式厚涂的风景、名画感仍用油画厚涂,扁平矢量、会挤压拉伸的小角色动画(「绘本动画」)仍用绘本角色动画,针管笔线稿加淡彩的速写小卡仍用钢笔淡彩,撞色多格的头像仍用波普丝网。「蓝调绘本 / 软蓝绘本 / 蓝色童书插画 / 绘本跨页」指蓝调绘本(软蓝限色的现代绘本跨页:干笔墨线 + 干蜡笔粉彩上色 + 白粉笔痕);单说「绘本」仍指绘本角色动画,「水粉 / 绘本大头像」仍指复古水粉,「编辑风 / Riso」仍指编辑风手绘,针管笔线稿加淡彩的速写小卡仍用钢笔淡彩,小孩自己画的蜡笔画仍用儿童蜡笔画。「江南园林 / 园林春景 / 中式园林插画 / 粉墙黛瓦 / 飞檐 / 月洞门 / 九曲桥」指江南园林(细笔数字水粉的园林春景:叶形小笔触堆出的繁茂树冠、繁花、垂柳、黛瓦飞檐、碧水倒影、层层远山);单说「水墨 / 山水」仍指水墨,单说「水彩」仍指水彩,动漫背景 / 赛璐璐天空仍指日本动漫,浮世绘仍是浮世绘;梵高式厚涂的风景仍用油画厚涂,皮影人偶的一场戏仍用皮影戏。「干刷色块 / 干笔色块 / 滚筒色块 / mid-century 海报插画」指干刷色块(米白纸上几大块干笔或滚筒刷出的限色色块,人物拆成几个大块面,背后一块纯色板、一旁一个小红方块);单说「水粉 / 绘本大头像」仍指复古水粉,「剪纸 / 彩纸拼贴」仍指剪纸拼贴,「丝网印刷 / screen print」仍指包豪斯几何,「Riso / 编辑风」仍指编辑风手绘,没有笔触的平滑几何色块仍用扁平矢量。「暮色微缩绘本 / 暮色绘本 / 黄昏转夜 / 昼夜交界 / 野花坡 / 细节放大图」指暮色微缩绘本(粉彩黄昏转入银河夜空、拼布山丘、几万朵小野花、很小的原创角色,加圆形放大图和手写小字);单说「绘本」仍指绘本角色动画,「蓝调绘本 / 软蓝绘本」仍指蓝调绘本,赛璐璐天空和夏日少年感仍用日本动漫,大片晕染的风景仍用水彩,整页的机械分解手稿仍用达·芬奇手稿,剖面和施工图仍用蓝图工程图。「排线夜景 / 彩铅或色粉夜景 / 短笔触夜空 / 夜景小版画 / 熔岩入海 / 精灵闪电 / 被照亮的云」指排线夜景(满画面顺着风向的短笔触、深蓝夜色里只有一个暖光、发光的丝和火星、碎的倒影、很小的人,装成带纸边和铅笔字的小版画);梵高式的厚涂漩涡和颜料浮雕仍用油画厚涂,明亮可爱的彩铅甜品仍用韩国彩铅,黑白石墨排线仍用铅笔素描,粉彩黄昏转入银河星空、满坡小野花仍用暮色微缩绘本,霓虹雨夜街道仍用赛博朋克。
---
# Claude 绘图
@@ -83,6 +83,7 @@ description: Claude 绘图 / Claude Drawing —— 不借助任何生图模型
| 江南园林 · Jiangnan Garden | `lib/jiangnan.py` · `JiangnanGarden` | `examples/jiangnan_spring_water.py` 春水园林 · Spring Water Garden(一幅横幅的江南园林春景,从前景的花枝和柳丝之间望进去:画面中间是一池碧绿的春水,岸上的一切都倒映在里面,更柔、更暗,带涟漪和细竖纹;一座带镂空石栏板的九曲石桥折了三折,穿过水面通向一道粉墙,墙上的月洞门里露出另一个洒满阳光的小院(竹子、粉色花树、一块湖石、远处又一道白墙),旁边一扇冰裂纹漏窗,墙上落着叶影;粉墙旁是一座临水茶榭,黛瓦歇山顶、翼角高高翘起、脊头卷起,翡翠绿的槅扇门和灯笼锦窗、檐下挂落、一对红灯笼、一块写着「听雨」的小匾,台基上几盆花;茶榭右边一棵开满白花的树下,一条小木船系在石阶边;左岸一棵大垂柳,墙后一棵层层托盘的松树和一片深浅不一的树冠,再后面是雾里的青山;近处水面上一丛丛睡莲叶和几朵粉色睡莲,一只白鹭站在水中的石头上,另一只从松树前掠过;前景左下是深绿的灌木、白色小花和弯弯的鸢尾叶,右下一丛粉色杜鹃,左上垂下几缕近处的柳丝,右上一枝粉色花枝,花瓣在空中飘、在水面上漂;右下角一方小红印「春水」;照风景插画家的顺序从后往前画:天空和远山、远树和雾、建筑、对岸的园子、水和倒影、桥和船、睡莲和白鹭、前景草木、垂挂的画框,最后是印章和收尾的柔化、光晕、颗粒;`--stages` 出 9 个阶段加成品:天空和远山、远树、建筑、对岸、水、桥和船、睡莲和白鹭、前景、画框) | 约 6 秒 |
| 干刷色块 · Dry-Brush Blocks | `lib/drybrush.py` · `DryBrushBlocks` | `examples/drybrush_noodle_counter.py` 面馆 · Noodle Counter(一张 4:3 的 mid-century 海报:小面馆柜台前,一位白色平头、粗黑框眼镜、白胡子的老人,穿藏青工装,一手用筷子从碗里挑起面,一手扶着碗;外套亮的一半是青蓝、暗的一半近黑,两半朝不同方向刷,袖子顺着胳膊刷;头是几块肤色平面:亮面、本色、暗面,更暗的鼻侧和暖色鼻头、腮红、暖色的耳朵;手是从拇指一侧看的几条手指,手腕露一截米色袖口;碗里是面、一块红油和葱花;身后一大块滚筒刷的鼠尾草绿色板,右边柜台上一个醋瓶、一个酱油瓶和一杯茶,衬着一块青蓝色块;米白纸上大片留白,右下一个小朱红方块;照参考海报的做法画:纸 → 大色块 → 几块面的外套和袖子 → 头 → 眼镜、胡子、筷子、近处的手 → 静物 → 红方块 → 印刷;`--stages` 出 7 个阶段加成品:纸、色块、外套、头、细节、静物、红方块) | 约 5 秒 |
| 暮色微缩绘本 · Twilight Storybook | `lib/twilight.py` · `TwilightStorybook` | `examples/twilight_paper_kite.py` 夜的边上 · The Kite at the Edge of Night(2000×1100 的一页黄昏绘本:一个穿蓝色毡子斗篷、软帽尖带绒球、圆脸点点眼、戴黄手套的原创小角色坐在野花坡顶上,把一只纸风筝放向天空入夜的地方;左边是粉彩黄昏:薰衣草紫、玫瑰、蜜桃、暖金,柔和的云带、细细的光线,一轮淡日正落到雾紫色的远山后面,一群飞鸟、几颗飘着的蒲公英种子;右边已经入夜:满天星、带暗带的银河、弯月、一颗流星,远山上一间小屋亮着一扇窗;中间是粉彩条纹的拼布山丘和小圆树,前景几万朵野花,入夜的一侧变成月光蓝,坡顶衬着天空几丛带穗的高草,花间有蝴蝶和蜻蜓;角色身边一罐萤火虫照亮一圈草,萤火虫往暗处飘;天空中间一个圆形「detail a」放大图,引线连到风筝上,用细技术图的画法画风筝骨架交叉处的绑扎和提线结(排线、ø 6 标注、标签、比例尺);两行小写手写字「the evening waits for us.」「just a little further.」;照顺序画:黄昏天空 → 夜 → 山 → 花坡 → 角色和风筝 → 萤火虫 → 图版和手写字;`--stages` 出 6 个阶段加成品:黄昏天空、夜、山、花坡、角色和风筝、萤火虫) | 约 2 秒 |
+| 排线夜景 · Hatched Nocturne | `lib/nocturne.py` · `Nocturne` | `examples/nocturne_lava_sea.py` 熔岩入海 · Lava Meets the Sea(一张装在米白纸边里的 16:9 小幅夜景版画:黎明前的火山海岸,熔岩从深色的火山坡上一缕缕淌下来,蜿蜒、分股,到海边散成一片细流,流进海里的地方是全画唯一的暖光——海水被激成蒸汽,一柱云团往上翻、顺风往左歪,从下往上被照亮:水边黄白,往上橙红,再往上是暖灰,到顶上是冷的石板蓝;火星往上飞,坡上几处停住的熔岩前锋还亮着小珠;海面上一条被横向笔触打碎的暖色光柱一直拉到画面底边,云团的红光也碎碎地映在水里;远处一座低矮的岛,海中间的一块小礁石上坐着两个看它的人(四十来像素高),其中一个围着红围巾;靛蓝的天空顺着风斜着流,零星几颗星;天、云、山、海全是顺着各自方向的短笔触,每笔色相明度都差一点,留着底色的细缝;画心外一道压印的版痕,左下铅笔小字「Forty seconds」,右下更小的「lava meeting the sea before dawn」;照画家的顺序画:纸和深色底、天空、远岛和火山、冷色的蒸汽、亮光(被照亮的云、天空和山坡上的光笔触、热源)、熔岩细流和火星、海、倒影、礁石和小人、装裱和题字;`--stages` 出 9 个阶段加成品) | 约 9 秒 |
各画风共用 `lib/core.py` 里的底层工具:噪声、模糊、样条曲线、多边形遮罩、有机轮廓 `blob_pts`、毛笔 `bristle_stroke`、中文字体查找;新四种还用到补零平移 `shift`、文字遮罩 `text_mask`、西文字体查找 `latin_font`/`load_font`,以及高度图打光 `height_normals`、`height_shadow`(沿光线步进的投影)、`ambient_occlusion`。
@@ -155,7 +156,8 @@ description: Claude 绘图 / Claude Drawing —— 不借助任何生图模型
- 温柔又好笑的小故事、绘本跨页或内页、童书封面和插页、「一个小角色帮另一个」这类有情节的一幕,下雨、下雪、夜晚这类安静的天气,要一眼就是「手画的现代绘本」,颜色只要一种主色(软蓝)加一点点睛色 → 蓝调绘本(要单人特写大头像、看得见毛衣针脚用复古水粉;要速写小卡上的针管笔线稿加淡彩用钢笔淡彩;要真的动起来的扁平小角色用绘本角色动画;要小孩自己画的蜡笔画用儿童蜡笔画;要网点和套色的观点插画用编辑风手绘);
- 中国古典园林、江南春景、亭台楼阁和水、旅行与城市文化里的「园林 / 古镇 / 春天」,节气和节日(春分、清明、谷雨)的配图和海报,要繁茂、细腻、一眼就是「精心画出来的插画」的风景,讲解片里的「中国传统 / 生活美学 / 春天」页 → 江南园林(要留白的写意山水用水墨;要大片松散的晕染用水彩;要赛璐璐天空和夏日少年感用日本动漫;要木版套色和海浪用浮世绘;要皮影人物的一场戏用皮影戏);
- 人物和日常小场景(吃一碗面、喝茶、做手艺、街坊小店)、杂志 / 书籍 / 唱片的复古封面、餐饮和饮品海报,要「色少而准、有手感、有态度」的编辑插画和 mid-century 海报感,讲解片里「这个人 / 这家店 / 这一口」的特写页 → 干刷色块(要剪刀剪的彩纸童趣用剪纸拼贴;要不透明水粉一层层塑形的大头像用复古水粉;要 Riso 网点和套色错版用编辑风手绘;要三原色几何的丝网海报用包豪斯几何;要干净、没有笔触的矢量色块用扁平矢量);
-- 温柔、怀旧、带一点点孤独的小故事和情绪(「一天结束了」「出发」「再走一点点」),晚安故事、童书封面和插页,季节和节日的夜晚(夏夜、萤火虫、星空、七夕、中秋),原创小角色或吉祥物的「远方」主视觉,要在一张画里同时放「风景 + 一个零件 / 一个结 / 一处构造的放大图 + 手写小字」的讲解页 → 暮色微缩绘本(要软蓝限色、乱线墨线的绘本跨页用蓝调绘本;要真的动起来的小角色用绘本角色动画;要赛璐璐天空和夏日少年感用日本动漫;要大片松散晕染的风景用水彩;要整页的机械分解手稿用达·芬奇手稿)。
+- 温柔、怀旧、带一点点孤独的小故事和情绪(「一天结束了」「出发」「再走一点点」),晚安故事、童书封面和插页,季节和节日的夜晚(夏夜、萤火虫、星空、七夕、中秋),原创小角色或吉祥物的「远方」主视觉,要在一张画里同时放「风景 + 一个零件 / 一个结 / 一处构造的放大图 + 手写小字」的讲解页 → 暮色微缩绘本(要软蓝限色、乱线墨线的绘本跨页用蓝调绘本;要真的动起来的小角色用绘本角色动画;要赛璐璐天空和夏日少年感用日本动漫;要大片松散晕染的风景用水彩;要整页的机械分解手稿用达·芬奇手稿);
+- 夜里的一个瞬间:一处火光、闪电、极光、篝火、渔火、熔岩、烟花,配一大片深蓝的天和水,要一眼就是「手画的小幅版画」、有满画面的笔触感和一点孤独,讲解片里的「一个极短的瞬间」「远处发生的大事」「自然现象」页,文章配图和海报 → 排线夜景(要梵高式厚涂漩涡和颜料浮雕用油画厚涂;要粉彩黄昏转入银河、满坡野花用暮色微缩绘本;要霓虹雨夜街道用赛博朋克;要黑白石墨排线用铅笔素描;要明亮可爱的彩铅小物用韩国彩铅)。
每种画风一幅范例作为质量基准(范例都不用禅意主题);水墨另加一幅「月印万川」(留白托月、水面倒影)。
@@ -1180,6 +1182,28 @@ from core import spline, curve, blob_pts, fbm1d, blur, polygon_mask
- 收尾:`finish(grain, vignette, bloom, soft, edge)`;`render()`、`composite()`、`stage(name)`、`save(path, stages_dir)`;`save('x.jpg')` 默认 quality 88、4:4:4 色度。
- 颜色用 `COLOURS` 里的名字(天空 lavender lilac rose peach apricot gold sun cloud cloud_low streak;夜 night night_low indigo star moon milk;地面 mauve mauve_dark haze rim silver meadow meadow_far meadow_near grass tree tree_light trunk field_sage field_lav field_wheat field_green field_rose;线和纸 ink pencil caption paper pale;花 daisy cornflower poppy cosmos marigold buttercup lupine forgetmenot eye stem;角色 cloak cloak_dark face cheek boot mitten kite kite_cream spar string lantern firefly glass)或 '#rrggbb';花种见 `SPECIES`。
+**排线夜景 `Nocturne`**:
+- 思路:照粉彩 / 彩铅画家的顺序画一张小幅夜景(纸和深色底 → 天空 → 远处的陆地 → 冷色的云 → 加光 → 发光的细丝和火星 → 海 → 倒影 → 小人 → 装裱和题字),整张画只由一笔一笔的短笔触组成,暖光是最后一层层「加」上去的笔触。
+ - 纸:直方图均衡过的纸纹 `T`(0–1 均匀分布)、低频斑驳和几百根纤维;画心先铺一层深色底,以后每一笔都裁在画心里(像贴了胶带),纸边始终干净。另外预先算好沿 8 个方向拖开的纸纹,每一笔按自己的方向取,漏掉的纸纹顺着笔拉成短道,不是孤立的黑点。
+ - 一笔:中心线在一个方向场里积分出来(方向按 mod π 处理,一笔中途不会掉头),再带一点弯,落笔钝、收笔尖。几万笔一次画完:Pillow 把每一笔的轮廓按序号填进 2 倍超采样的整数 id 图(后画的盖住先画的),numpy 对每个像素查出那一笔的颜色、起点、方向、长和宽,算出像素在笔上的位置(沿笔 u、横向 v),由 v 得到笔毛道:每笔 6 道,各有自己的深浅和含量,越往笔尾越干(`dry`),颜料只落在纸纹低于压力的地方(`pressure`),所以每一笔都有笔毛条纹和颗粒,深色的底从细缝里透出来;再缩回 1 倍。同一批里最上面那笔说了算(不会糊成一团),层次靠多遍叠。
+ - 颜色:一笔取一个颜色——一个颜料、一条色阶按明度场取,或任意 f(x, y);再加每笔自己的明度抖动(`value`)和色相抖动(`hue`,绕灰轴真正转色相);`lit` 把光照图加到笔上,所以光里的笔触本身是暖的。
+ - 方向场:`flow(角度, 扰动, 尺度)` 整片的风向;`radial(cx, cy)` 从一点放射(锥形山的坡向、光的放射);`contour(密度)` 顺着等高线(绕着云团、沿着山脊);`blend(f1, f2, w)` 用双倍角混合(0 和 π 是同一个方向)。云团里的笔顺着上升的柱子走,只在团边上绕着卷,处处都绕会卷成漩涡。
+ - 光:`light()` 点光源、`light_from()` 发光的遮罩(熔岩细流)合成一张光照图。`glow()` 铺光笔触:落笔的概率跟着「光 × 受光」走、颜色取光照图,所以光是越往外越稀的暖色笔触,不是一团平滑的光晕。空气和眩光用加光(screen);被照亮的表面用 `blend='paint'` 按「光 × 受光」直接上色——蓝灰的云加上橙光会变粉,直接画成被照亮的颜色才是红橙;`whiten` 让离热源最近的那些笔偏向暖白(白色的蒸汽)。
+ - 热源 `source()`:一小撮黄白的笔、一圈圈往外放射的橙、红笔触,一个很小的白芯和很小的辉光。
+ - 细丝:`threads()` 是带惯性、一直转向终点(并顺着坡离开山顶)的游走,所以是蜿蜒的细流不是折线闪电;分股的细丝越往末端分得越开,小角度的支流分出去后渐隐或停在一颗亮珠上,亮度一段段有结壳的暗处,前锋最热。`filaments()` 把它们画进 2 倍浮点发光缓冲:细线、紧贴的光晕、照到旁边东西上的光笔触、末端和沿途的亮珠。`sparks()` 是抛物线飞出的火星:一小段渐淡的拖尾和一个热的头。
+ - 水:`reflect()` 在海面上铺横向笔触,颜色取水线以上画面的镜像(被浪拉长、被涟漪横推、压暗并混进海色),只在镜像亮的地方落笔,所以倒影是碎的;`glitter()` 是水线上的光源朝观者拉出的光柱:近处热而窄,往下变宽、变红、更碎。
+ - 小人和剪影:`figure()` 是几十像素高的坐着的小人(头、躯干、屈起的腿、搭在膝上的手),剪影色,一点亮色(围巾、帽子),朝光的一侧一道暖色轮廓光;`silhouette()` 用笔触画深色的块(礁石、岛、山),可选朝光一侧的轮廓光。
+ - 装裱:`mount()` 在画心外压一道版痕(凹槽的上沿和左沿暗、下沿和右沿亮);`caption()` 用细的普通字体(Helvetica Neue Light / Thin 一类,不用手写体)逐字写铅笔小字,基线和角度有一点点抖,石墨在纸纹上发虚。收尾 `bloom()` 只给画心里最亮的光一点克制的辉光,`grain()` 细颗粒。
+- 构造:`Nocturne(W, H, seed, keep_stages=True, stages_dir=None)`(总像素不超过 4096²),先 `sheet(box=(x0, y0, x1, y1), paper, ground)`。坐标是整张画布的像素;方向场是弧度,`flow()` 的角度用度(屏幕 y 朝下,正角度向右下斜)。
+- 遮罩:`poly(pts, smooth)`、`ellipse(cx, cy, rx, ry, rot)`、`blob(cx, cy, rx, ry, rough)`、`below(xs, ys, invert)`(一条样条线以下)返回画布大小的浮点遮罩;`value(top, bottom, y0, y1, mottle, scale)` 竖向明度场加低频斑驳。
+- 笔触:`hatch(region, field, colour, length, width, density, jitter, bend, value, hue, alpha, pressure, dry, lanes, lit, mode='paint'|'light', taper, clip)`。`region` 是落笔概率遮罩或 (x0, y0, x1, y1);`density` 约等于把区域铺几遍;`length` / `width` 给 (最小, 最大)、一个数或 f(x, y)(海面越近越长);`colour` 给颜料、(色阶, 明度场或 f(x, y)) 或 f(x, y) → (N, 3)。
+- 光:`light(x, y, r, colour, power, squash)`、`light_from(emission, spread, colour, power)`、`lightmap()`;`glow(receptivity, field, length, width, density, power, reach, blend='light'|'paint', ambient, whiten)`;`source(x, y, r, power, field, squash, core)`。
+- 细丝和点:`threads(start, ends, wander, strands, spread, branches, branch_len, width, fall, heat)` 返回路径;`filaments(paths, gain, halo, light, receptivity, field, beads)`;`sparks(x, y, n, spread, speed, streak)`;`embers(region, n)`;`stars(region, n, size, bright)`。
+- 水:`reflect(waterline, region, src, stretch, ripple, darken, mixw, thr, length, width, density)`(`src` 传画海之前的画布,`waterline` 可以是逐列的数组);`glitter(x, y_water, y_end, w0, w1, power)`。
+- 剪影和小人:`silhouette(mask, ramp_, field, val, density, rim, rim_from)`;`figure(x, y, h, facing, accent, accent2, legs='knees'|'dangle', lean, rim_from, rim, hat)` 返回小人的遮罩。
+- 收尾:`mount(plate, depth)`、`caption(text, x, y, size, anchor, weight='light'|'thin', alpha, jitter)`、`bloom(amount)`、`grain(amount)`;`render()`、`composite()`、`stage(name)`、`save(path, stages_dir)`;`save('x.jpg')` 默认 quality 88、4:4:4 色度。
+- 颜色用 `PAINTS` 里的名字(paper pencil ground night indigo navy dusk haze starlight mist slate steam steam_lit rock rock_lit sea sea_deep glint blood ember lava flame core scarf star warmstar)或 '#rrggbb';色阶用 `RAMPS` 里的名字(fire ember sky sea steam land isle)或自己给一串颜色。
+
**顺序**:都是先远后近、先大后小,文字最后叠加。水墨的雾要画在它该吞没的东西之后;水彩的叶梗要先画,并且只画在叶子外面。
## 三、毛病清单(都真实出现过)
@@ -2292,6 +2316,27 @@ from core import spline, curve, blob_pts, fbm1d, blur, polygon_mask
| 拼布条纹田像一面面旗 | 田的颜色降饱和、彼此更接近,山脊起伏加大,树篱线 0.45,底部渐隐 |
| 阶段快照没有颗粒、暗角和撕纸边,和成品对不上 | `finish()` 只记参数、在 render 里加,改到画第一笔之前调用 |
+**排线夜景**
+
+| 问题 | 改法 |
+|---|---|
+| 云团里一圈圈同心的漩涡,像梵高的星空 | 笔触处处沿团块的切线走:团块里面改成顺着上升柱子的方向(顶上顺着风),只在团块边缘(半径 0.55–0.97)混进切线,最多 0.75 |
+| 海面和云里满是孤立的黑点,像脏了 | 纸纹缝隙是一个个孤立像素,深色的底从里面透出来:纸纹沿 8 个方向拖开,每笔按自己的方向取,漏白顺着笔成短道;默认压力 0.9 → 0.95,海面、倒影 0.96–0.975;底色从 #0a0f27 提到 #0d1331 |
+| 熔岩细流像一道道闪电劈向海面 | 直线段加大角度的分叉、黄白色:改成带惯性的游走(一直转向终点、顺坡离开山顶),支流只分 0.18–0.5 弧度;发光的颜色在色阶上压到 0.3–0.92(主要是橙红),只有亮珠和前锋发黄 |
+| 改成游走后细流打圈、像一团意面 | 转向噪声太大、拉向终点太弱:每步转角 0.035·wander(0.85 衰减),拉力 0.16–0.46 |
+| 熔岩入海处是一个平滑的大白团,像爆炸 | 光改成一圈圈放射的笔触(黄白 → 橙 → 红,色阶起点 0.28–0.72);平滑的白芯缩到 0.11 r、辉光 0.18;横向压扁(0.6);沿入海的一排细流再放两个小热源 |
+| 被照亮的云是一片鲑鱼粉 | 橙光用 screen 加到蓝灰的云上就是粉:受光的云改用 `glow(blend='paint')`,颜色 = 光 × 受光 + 一点暗的环境色,才是红橙;另一层很淡的加光只给最亮的底部 |
+| 云柱底部像一丛火苗 | 往上走的长笔触、饱和的黄橙、中间的暗缝:近热源的笔 `whiten` 0.6 偏暖白(蒸汽是白的),底部的小团块多混一点切线(卷起来),亮笔触压力 0.97、密度 1.8 |
+| 天空的浅色短笔像在下雪 | 浅色笔触太多、太亮、太短:只落在噪声的高处(成片成带),密度 0.35 → 0.16,长 18–42、宽 1.1–1.7,明度只比底色高 0.3 |
+| 天空是饱和的宝蓝,不是夜色 | 天和海的色阶整体压暗、去饱和,往靛蓝和冷灰蓝靠;天顶明度 0.04、地平线 0.6 |
+| 倒影两侧边缘一道道白横线 | 镜像取样被涟漪推到了画心外的米白纸边:取样坐标限制在画心里 |
+| 礁石上一块块橙红,像也有熔岩 | 礁石离热源远,轮廓光太强:rim 0.9 → 0.14;小人的轮廓光 0.45 |
+| 版痕的线一直延伸到纸的边上 | 用的是到四条无限长直线的距离:改成到矩形的距离,上沿和左沿的暗线也只在矩形范围内 |
+| 成品一步画心边缘多了一圈褐色 | 辉光把画心外米白纸边的亮度也模糊进来了:辉光只取画心里的亮度 |
+| 远处的岛看不见 | 太矮、颜色和地平线的天一样:岛加高 10–15 px,改用最暗的陆地色阶 |
+| 两个小人在深色海面上看不出来 | 他们身后加一小片浅色波光(横向短笔,只在礁石外),剪影才立起来;小人 40–44 px,围巾是唯一的亮色 |
+| 熔岩路径有 NaN | float32 里 sin(π) 是一个很小的负数,`** 0.8` 得到 NaN:先 clip 到 0–1 |
+
## 四、做成动画
- 各画风都有 `stage(name)` 和 `save(path, stages_dir)`,按阶段依次淡入叠化,就是「一幅画被逐步画出来」。README 里的动图就是这样做的。
@@ -2346,6 +2391,11 @@ from core import spline, curve, blob_pts, fbm1d, blur, polygon_mask
- 8×8 Bayer:别处 ±2.4 级,交界带(夜改动过、又不是近黑的天空)加到 ±6.4 级,调色板再密也还差几级的地方靠它抹平。
- 和屏上已显示颜色差不到 7 级(叠化帧)或 4 级(关键帧)的像素沿用上一帧,末帧精确发送。
- 结果:37 帧、10.7 秒、约 0.87 MB,按解码结果逐帧自检,末帧 p99 误差 16;交界带模糊 1.5 px 后和原图比 p99 7 级。
+- 排线夜景的动图(脚本在 `claude_drawing/nocturne_work/make_gif_nocturne.py`):
+ - 阶段:米白纸和深色底 → 斜向的天空笔触和星星 → 远岛和火山 → 冷色的蒸汽云团 → 亮光(云被照亮、天空和山坡上的光笔触、热源)→ 熔岩细流、亮珠和火星 → 海面笔触 → 碎的倒影和光柱 → 礁石和两个小人 → 版痕、题字、辉光和颗粒(成品)。每段 900 毫秒 + 5 帧叠化。
+ - 调色板:第一帧(纸和平涂的深色底)只给 12 色;228 色从和它不同的像素切(末帧 ×3),按夜景的需要加权:深蓝 ×2(占满画面,色位不够时排线变成一块块平色、天顶到地平线出色带)、饱和的暖色 ×3(熔岩、被照亮的云、倒影)、浅米色 ×1.5(题字后面的纸);再留 14 色,其中 3 个是强制的(最深的底色藏青、题字的铅笔灰、白热的芯),另外 11 色只从末帧误差最大(> 16 级)的像素里切。
+ - 固定 4×4 Bayer。和屏上已显示颜色差不到 7 级(叠化帧)或 4 级(关键帧)的像素沿用上一帧,末帧精确发送。
+ - 结果:55 帧、14.75 秒、约 1.18 MB,按解码结果逐帧自检,末帧 p99 误差 18。
- 绘本角色动画的动图是真动画,不是阶段叠化:`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 遮罩按顺序显现。这个还没做成现成接口。
@@ -2423,6 +2473,7 @@ lib/bluebook.py 蓝调绘本(直方图均衡的纸纹与 8 个方向拖
lib/jiangnan.py 江南园林(叶形小笔触的 id 图光栅化:Pillow 按序号填多边形、numpy 查色表、2 倍超采样;按团块穹顶光照取色的树冠:暗底、穿出轮廓的叶、成簇的高光、最亮的几笔;花簇按明暗排序的繁花树、五瓣花的近景花枝;一绺绺细枝的垂柳、托盘松、弯曲的鸢尾叶;网格反求 (u, v) 的歇山瓦顶:筒瓦板瓦、瓦当滴水、飞檐翼角、卷脊头、檐下阴影;粉墙、叶影、方格 / 灯笼锦 / 冰裂纹槅扇、挂落、月洞门和漏窗、石作、台阶、针孔相机投影的九曲桥;湖面、按岸线镜像的倒影、自带倒影的桥船白鹭、横向笔触、涟漪和细竖纹、睡莲;红灯笼、匾额、小红印;柔化、光晕、颗粒)
lib/drybrush.py 干刷色块(笔刷坐标系:遮罩转到笔触方向再算、再转回;周期的鬃毛条纹 / 干笔齿 / 滚筒细点 / 梳齿边 / 笔道 / 斑驳纹理;一道道平行的笔或打断的短笔:起笔饱满、收笔干枯、梳齿般的两端、近直的两侧、皴擦、顺笔两侧的干擦边、多遍覆盖、同笔混色、蘸满的笔;滚筒大色板和细刮痕;部分撕口带纤维边的纸片;沿路径的干笔和散撒的短干笔;几块面拼的人物:头、眼镜、白胡子、外套、袖子、手;瓶、碗、杯;朱红小方块;胶印收尾:柔化、纸纹、暗部白点、细尘)
lib/twilight.py 暮色微缩绘本(被噪声扰动成软层的六段黄昏渐变、透镜形云带、光线和淡日;羽化的夜度场:按它铺夜空、银河、星星和月亮,交界补饱和度,后面受光的东西按它压成月光蓝,发光的东西不受影响;解析的银河带和暗带、幂律星场、亚像素溅射、四芒星、弯月、流星;远山、拼布条纹山丘、细垄、树篱、小圆树;按透视拒绝采样的花坡:八种花和草叶,按根部排序一次光栅化进 id 图;小斗篷角色、萤火虫罐、风筝和随天色变色的风筝线、萤火虫、蝴蝶、蜻蜓、蒲公英种子、飞鸟、带穗高草;3 倍图上的细墨线、排线、尺寸标注、比例尺、淡彩、圆形放大图;逐字母抖动的手写小字;柔化、光晕、颗粒、暗角、撕纸边)
+lib/nocturne.py 排线夜景(直方图均衡的纸纹与沿 8 个方向拖开的纸纹;在方向场里积分出中心线的短笔触:落笔钝、收笔尖、带一点弯;id 图光栅化:Pillow 按序号填轮廓、2 倍超采样,numpy 逐像素查回这一笔的位置和方向,算出沿笔 / 横向坐标、6 道笔毛的深浅与含量、越往笔尾越干、颜料只落在纸纹低于压力处;每笔的明度抖动和绕灰轴的色相旋转;风向、放射、等高线方向场与双倍角混合;点光源和发光遮罩合成光照图,加光(screen)或「光 × 受光」上色的光笔触,暖白化;放射笔触的热源;带惯性游走的蜿蜒细流、分股、支流、结壳的亮度和前锋亮珠,2 倍浮点发光缓冲与紧贴的光晕;抛物线火星、零星火星、星点;镜像取样的碎倒影、光柱;笔触画的剪影和朝光轮廓光、几十像素高的坐着的小人和围巾;米白纸边、纤维、胶带边、压印版痕、细体铅笔小字;画心内的克制辉光、细颗粒)
examples/*.py 范例脚本;*.jpg 成品;drawing_*.gif 逐步画出的动图
中文字体:自动找 Kaiti/Songti(macOS)、Noto CJK(Linux)、KaiTi/SimSun(Windows),或设 INKPAINT_FONT
西文字体(后来新增的画风用):core.latin_font(style) 按 sans / sans_bold / rounded / script / hand / typewriter 等找系统字体,可用 INKPAINT_FONT_<STYLE> 指定;字体文件不要放进仓库
diff --git a/examples/drawing_nocturne_lava_sea.gif b/examples/drawing_nocturne_lava_sea.gif
new file mode 100644
index 0000000..f4556da
Binary files /dev/null and b/examples/drawing_nocturne_lava_sea.gif differ
diff --git a/examples/nocturne_lava_sea.jpg b/examples/nocturne_lava_sea.jpg
new file mode 100644
index 0000000..b109f2e
Binary files /dev/null and b/examples/nocturne_lava_sea.jpg differ
diff --git a/examples/nocturne_lava_sea.py b/examples/nocturne_lava_sea.py
new file mode 100644
index 0000000..e23c1cd
--- /dev/null
+++ b/examples/nocturne_lava_sea.py
@@ -0,0 +1,289 @@
+"""Example (hatched nocturne): 熔岩入海 · Lava Meets the Sea -- a small night print laid entirely in short strokes.
+
+Before dawn on a volcanic coast. Lava trickles down the dark flank of a volcano in glowing threads that braid and
+fan out toward the shore; where they reach the sea, the water flashes to steam: a column of billows rises and leans
+away on the wind, lit from below -- yellow-white at the waterline, orange and red above, warm grey further up,
+cold slate at the top. Sparks fly; a few lava fronts stopped on the slope still glow as beads. The sea carries a
+broken warm column back toward us. Far off, a low island; on a small reef in the middle of the water two people
+sit side by side watching it, one in a red scarf. Indigo sky with stars, streaming diagonally with the wind.
+
+Every area is built from short directional strokes (sky diagonal, steam round its billows, slopes down the fall
+lines, sea in long horizontals), each a little different in hue and value, with hairline gaps of the dark ground;
+the one warm light is added on top as light strokes. Mounted as a small print: cream margins, plate mark, a pencilled
+title and note in a thin plain face.
+
+Painted in this order: paper and dark ground -> sky -> far island and volcano -> steam -> the light (glow strokes and
+the hot source) -> lava threads, sparks -> sea -> reflection -> reef and figures -> mount and captions.
+--stages writes those steps as snapshots for the draw-on. No image model.
+python3 nocturne_lava_sea.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 nocturne import Nocturne
+from core import blur, spline, smoothstep, fbm1d, noise2d, blob_pts
+
+W, H = 1920, 1080
+BOX = (80, 56, 1840, 966)
+HZ = 604 # the open-sea horizon
+EX, EY = 1150, 614 # where the lava meets the sea: the one warm light
+RIDGE = [(880, 606), (960, 596), (1040, 578), (1120, 551), (1200, 516), (1280, 474), (1360, 426), (1430, 375),
+ (1490, 325), (1530, 287), (1552, 266), (1572, 262), (1588, 272), (1604, 274), (1620, 263), (1640, 266),
+ (1672, 290), (1720, 324), (1780, 360), (1860, 400)]
+ISLE = [(130, 608), (180, 590), (240, 574), (300, 566), (350, 563), (410, 570), (470, 584), (530, 597), (590, 608)]
+ISLE2 = [(640, 608), (680, 596), (726, 591), (772, 598), (812, 608)]
+REEF = (490, 772) # the reef with the two watchers (centre, waterline)
+
+
+def waterline():
+ """per-column waterline: the open horizon, then the volcano's coast coming a little nearer toward the right,
+ with the lava delta bulging out where the threads reach the sea"""
+ x = np.arange(W, dtype=np.float32)
+ c = HZ + np.clip(x - 900, 0, None) * 0.031 + 1.5 * np.sin(x / 37.0) * (x > 900)
+ c = c + 6 * np.exp(-((x - 1168) / 95.0) ** 2)
+ return c.astype(np.float32)
+
+
+class Scene:
+ def __init__(self, n):
+ self.n = n
+ self.wl = waterline()
+ X, Y = n.XX, n.YY
+ self.sea = np.clip(Y - self.wl[None] + 0.5, 0, 1).astype(np.float32)
+ self.sky = n.below(None, HZ + 3, invert=True)
+ ridge = np.array(RIDGE, np.float32)
+ self.land = n.below(ridge[:, 0], ridge[:, 1]) * (1 - np.clip(Y - self.wl[None] - 2.5, 0, 1))
+ i1, i2 = np.array(ISLE, np.float32), np.array(ISLE2, np.float32)
+ self.isle = np.maximum(n.below(i1[:, 0], i1[:, 1]) * ((X > 140) & (X < 580)), n.below(i2[:, 0], i2[:, 1]) * ((X > 630) & (X < 806)))
+ self.isle = self.isle * (1 - np.clip(Y - HZ - 3, 0, 1))
+ self.puffs()
+
+ # ------------------------------------------------------------ the steam column as billows
+ def puffs(self):
+ n = self.n
+ r = np.random.default_rng(41)
+ axis = spline([(EX, EY + 2), (EX - 18, 548), (EX - 60, 466), (EX - 125, 384), (EX - 200, 304), (EX - 275, 240),
+ (EX - 335, 200)], 20)
+ seg = np.linalg.norm(np.diff(axis, axis=0), axis=1); s = np.concatenate([[0], np.cumsum(seg)]); s /= s[-1]
+ tang = np.arctan2(np.gradient(axis[:, 1]), np.gradient(axis[:, 0]))
+ wind = np.deg2rad(16)
+ P = []
+ for t in np.sort(r.random(64)) ** 1.15:
+ cx, cy = np.interp(t, s, axis[:, 0]), np.interp(t, s, axis[:, 1])
+ rad = (16 + 112 * t ** 0.85) * r.uniform(0.72, 1.12)
+ P.append((cx + r.uniform(-0.55, 0.55) * rad, cy + r.uniform(-0.25, 0.25) * rad, rad, t, np.interp(t, s, tang)))
+ for _ in range(16): # the head spreading downwind
+ cx = r.uniform(650, 1060); cy = 226 + r.uniform(-28, 28) + (cx - 860) * 0.1
+ P.append((cx, cy, r.uniform(48, 88), 1.0, wind))
+ for bx in (1080, 1236): # two smaller jets that join the column
+ for k in range(7):
+ t = k / 7
+ P.append((bx - 30 * t - 8 * t * t + r.normal(0, 5), EY - 4 - 115 * t, 9 + 34 * t, 0.12 * t, -np.pi / 2 - 0.3))
+ r.shuffle(P)
+ P.sort(key=lambda p: p[3] < 0.15) # the low, hot billows in front
+ H_, W_ = n.H, n.W
+ D = np.zeros((H_, W_), np.float32); U = np.zeros((H_, W_), np.float32); RR = np.zeros((H_, W_), np.float32)
+ A = np.zeros((H_, W_), np.float32); AX = np.zeros((H_, W_), np.float32); TT = np.zeros((H_, W_), np.float32)
+ for i, (cx, cy, rad, t, ax) in enumerate(P):
+ x0, x1 = int(max(0, cx - rad * 1.3)), int(min(W_, cx + rad * 1.3))
+ y0, y1 = int(max(0, cy - rad * 1.3)), int(min(H_, cy + rad * 1.3))
+ if x1 <= x0 or y1 <= y0: continue
+ yy, xx = np.mgrid[y0:y1, x0:x1].astype(np.float32)
+ th = np.arctan2(yy - cy, xx - cx)
+ wob = 1 + 0.14 * np.sin(5 * th + i) + 0.08 * np.sin(9 * th + 2 * i)
+ d = np.sqrt((xx - cx) ** 2 + (yy - cy) ** 2) / (rad * wob)
+ dome = np.sqrt(np.clip(1 - d * d, 0, 1))
+ on = dome > 0.02
+ sl = (slice(y0, y1), slice(x0, x1))
+ D[sl] = np.maximum(D[sl], dome)
+ U[sl] = np.where(on, np.clip(0.5 + 0.6 * (yy - cy) / rad, 0, 1), U[sl])
+ A[sl] = np.where(on, th + np.pi / 2, A[sl])
+ AX[sl] = np.where(on, ax, AX[sl])
+ RR[sl] = np.where(on, d, RR[sl])
+ TT[sl] = np.where(on, t, TT[sl])
+ self.D = np.clip(blur(D, 2.0) * 1.25, 0, 1)
+ self.U, self.TT = U, TT
+ # inside a billow the strokes stream with the rising column (with the wind in the head); only near its rim
+ # do they curl round it -- curling everywhere makes whirlpools
+ curl = smoothstep(0.55, 0.97, RR) * 0.75 + (1 - smoothstep(0.1, 0.35, TT)) * smoothstep(0.3, 0.8, RR) * 0.25
+ self.steam_field = n.blend(AX, A, np.clip(curl, 0, 0.9))
+
+ # ------------------------------------------------------------ 1 sky
+ def sky_phase(self):
+ n = self.n
+ sky = self.sky
+ self.sky_field = f = n.blend(n.flow(15, 8, 320, seed=1), self.steam_field, smoothstep(0.0, 0.5, blur(self.D, 18)) * 0.6)
+ v = n.value(0.04, 0.6, 56, HZ, 0.08, 240, seed=2)
+ n.hatch(sky, f, ('sky', np.clip(v - 0.12, 0, 1)), (22, 44), (2.4, 3.4), 1.5, value=0.1, hue=0.05, pressure=0.97, dry=0.25, seed=3)
+ n.hatch(sky, f, ('sky', v), (18, 38), (1.8, 2.8), 1.7, value=0.11, hue=0.06, pressure=0.95, dry=0.35, seed=4)
+ streaks = np.clip(n.value(0, 0, 0, H, 0.5, 90, seed=5) - 0.5, 0, 1) * 3.0 * sky
+ n.hatch(streaks, f, ('sky', np.clip(v + 0.3, 0, 1)), (18, 42), (1.1, 1.7), 0.16, value=0.14, hue=0.05,
+ pressure=0.93, dry=0.6, alpha=0.7, seed=6)
+ n.hatch(sky * 0.5, f, ('sky', np.clip(v + 0.45, 0, 1)), (12, 26), (1.0, 1.4), 0.015, value=0.1, pressure=0.92,
+ dry=0.65, alpha=0.65, seed=7)
+ clear = sky * np.clip(1 - self.D * 3, 0, 1)
+ n.stars(clear, 190, (0.55, 1.3), bright=0.07, seed=8)
+
+ # ------------------------------------------------------------ 2 far island and the volcano
+ def land_phase(self):
+ n = self.n
+ n.silhouette(self.isle, 'land', n.flow(4, 6, 120, seed=11), val=n.value(0.3, 0.42, 560, 610, 0.08, 60, seed=12),
+ density=2.4, length=(10, 22), width=(1.8, 2.8), seed=13)
+ self.land_field = lf = n.blend(n.radial(1580, 250, turb=8, seed=14), n.flow(8, 4, 200, seed=15),
+ np.clip((n.YY - 560) / 60, 0, 1) * 0.8)
+ v = n.value(0.42, 0.18, 260, 640, 0.1, 80, seed=16)
+ n.silhouette(self.land, 'land', lf, val=v, density=2.6, length=(12, 30), width=(2.0, 3.2), seed=17)
+ # the ridge catches a little sky: a few lighter strokes along the skyline
+ ridge = np.array(RIDGE, np.float32)
+ edge = np.clip(self.land - n.below(ridge[:, 0], ridge[:, 1] + 7), 0, 1)
+ n.hatch(edge, n.contour(self.land, 3), '#2a3150', (10, 22), (1.4, 2.2), 0.5, value=0.12, pressure=0.85, dry=0.5, seed=18)
+
+ # ------------------------------------------------------------ 3 steam, unlit (cold slate, a little starlight on the tops)
+ def steam_phase(self):
+ n = self.n
+ D, U = self.D, self.U
+ top = 1 - U
+ v = np.clip(0.1 + 0.32 * top * D + 0.1 * (noise2d(H, W, 60, 3, 21) - 0.5), 0, 1)
+ n.hatch(D ** 0.8, self.steam_field, ('steam', v), (14, 30), (2.0, 3.2), 2.2, jitter=0.08, bend=0.08, value=0.1,
+ hue=0.04, pressure=0.96, dry=0.3, seed=22)
+ n.hatch(D * top, self.steam_field, ('steam', np.clip(v + 0.18, 0, 1)), (10, 24), (1.6, 2.4), 0.45, jitter=0.1,
+ bend=0.1, value=0.12, pressure=0.92, dry=0.5, alpha=0.9, seed=23)
+ n.hatch(np.clip(D * 2.5, 0, 1) * (D < 0.4), self.steam_field, ('steam', v * 0.8), (16, 34), (1.4, 2.2), 0.6,
+ jitter=0.2, value=0.1, pressure=0.85, dry=0.6, alpha=0.75, seed=24)
+
+ # ------------------------------------------------------------ 4 the light: glow strokes and the hot source
+ def lights(self):
+ n = self.n
+ n.light(EX, EY - 6, 210, 'ember', 1.25, squash=0.85)
+ n.light(EX - 40, EY - 120, 600, '#c2320e', 0.2)
+ self.lava = self.lava_paths()
+ E = n._emission(self.lava)
+ n.light_from(E, 22, 'ember', 0.45)
+
+ def glow_phase(self):
+ n = self.n
+ D, U = self.D, self.U
+ rec = D * (0.18 + 0.82 * U ** 1.3)
+ n.glow(rec, self.steam_field, (12, 26), (1.8, 3.0), 1.8, power=1.65, reach=2.2, blend='paint', ambient='#1c2038',
+ whiten=0.6, alpha=0.93, jitter=0.08, pressure=0.97, dry=0.3, seed=31)
+ n.glow(rec * U, self.steam_field, (8, 18), (1.6, 2.6), 0.8, power=0.8, reach=2.4, jitter=0.1, seed=32)
+ n.glow(self.sky * (1 - D) * 0.3, self.sky_field, (16, 34), (1.6, 2.6), 0.9, power=0.6, reach=1.4, seed=33)
+ n.glow(self.land * 0.45, self.land_field, (10, 24), (1.6, 2.6), 1.0, power=0.75, reach=1.6, seed=34)
+ n.source(EX, EY - 3, 40, power=0.9, seed=35)
+ n.source(EX - 52, EY - 3, 18, power=0.7, core=0.6, seed=36)
+ n.source(EX + 74, EY + 1, 20, power=0.75, core=0.6, seed=37)
+
+ # ------------------------------------------------------------ 5 lava threads, sparks
+ def lava_paths(self):
+ n = self.n
+ top = (1580, 250)
+ vent = (1408, 470)
+ P = n.threads((1556, 290), [vent, (1440, 452)], wander=1.0, strands=2, spread=3, branches=2, branch_len=(20, 50),
+ width=(1.6, 1.4), fall=top, heat=(0.3, 0.65), seed=51)
+ ends = [(1066, 610), (1104, 612), (1142, 614), (1180, 616), (1222, 617), (1266, 618)]
+ P += n.threads(vent, ends, wander=1.0, strands=4, spread=5.0, branches=14, branch_len=(24, 80), width=(1.6, 1.2),
+ fall=top, heat=(0.35, 0.75), seed=52)
+ P += n.threads((1600, 292), [(1650, 508), (1716, 556)], wander=1.0, strands=2, spread=3, branches=4,
+ branch_len=(16, 44), width=(1.4, 1.0), fall=top, heat=(0.3, 0.6), seed=53)
+ P += n.threads((1505, 352), [(1336, 562)], wander=1.2, strands=2, spread=3, branches=3, width=(1.3, 1.0), fall=top,
+ heat=(0.25, 0.55), seed=54)
+ mask = np.clip(blur(self.land, 1.0) * 1.4, 0, 1)
+ for p in P: # lava stays on the slope
+ inside = mask[np.clip(p['pts'][:, 1].astype(int), 0, H - 1), np.clip(p['pts'][:, 0].astype(int), 0, W - 1)]
+ p['i'] = (p['i'] * smoothstep(0.3, 0.9, inside)).astype(np.float32)
+ return P
+
+ def threads_phase(self):
+ n = self.n
+ n.filaments(self.lava, gain=1.05, halo=1.0, light=0.55, receptivity=self.land, field=self.land_field, beads=0.5, seed=61)
+ n.sparks(EX, EY - 8, 46, spread=0.55, speed=(30, 120), streak=(5, 16), seed=62)
+ n.sparks(EX - 60, EY - 6, 14, spread=0.5, speed=(20, 70), seed=63)
+ n.embers(n.ellipse(EX - 30, EY - 120, 110, 130) * self.D, 50, seed=64)
+
+ # ------------------------------------------------------------ 6 sea
+ def sea_phase(self):
+ n = self.n
+ self.src = n.C.copy()
+ sea = self.sea
+ f = n.flow(0, 1.5, 300, seed=71)
+ dep = lambda x, y: np.clip(y - HZ, 0, None)
+ L = lambda x, y: 18 + 0.24 * dep(x, y)
+ Wd = lambda x, y: 1.9 + 0.0045 * dep(x, y)
+ v = n.value(0.62, 0.16, HZ, 966, 0.1, 160, seed=72)
+ n.hatch(sea, f, ('sea', np.clip(v - 0.14, 0, 1)), L, Wd, 1.7, jitter=0.03, bend=0.01, value=0.1, hue=0.04,
+ pressure=0.975, dry=0.3, lit=0.18, seed=73)
+ n.hatch(sea, f, ('sea', v), lambda x, y: 0.85 * L(x, y), lambda x, y: 0.85 * Wd(x, y), 1.4, jitter=0.03,
+ bend=0.01, value=0.12, hue=0.05, pressure=0.96, dry=0.4, lit=0.3, seed=74)
+ waves = smoothstep(0.55, 0.75, noise2d(H, W, 22, 3, 75) * 0.6 + 0.4 * np.sin(n.YY / (3 + 0.03 * np.clip(n.YY - HZ, 0, None))) * 0.5 + 0.2)
+ near_h = np.exp(-np.clip(n.YY - HZ, 0, None) / 90)
+ glint = sea * np.clip(waves * 0.35 * (1 - 0.6 * np.clip((n.YY - HZ) / 360, 0, 1)) + near_h * 0.4, 0, 1)
+ n.hatch(glint, f, ('sea', np.clip(v + 0.4, 0, 1)), lambda x, y: 0.5 * L(x, y), lambda x, y: 0.6 * Wd(x, y), 0.24,
+ jitter=0.03, bend=0.01, value=0.14, pressure=0.88, dry=0.55, alpha=0.85, lit=0.2, seed=76)
+ band = sea * (n.YY < HZ + 6) * (n.XX < 960)
+ n.hatch(band, 0.0, '#8597c4', (30, 80), (1.6, 2.4), 0.8, jitter=0.01, bend=0.0, value=0.12, pressure=0.85, dry=0.5,
+ alpha=0.8, seed=77)
+
+ # ------------------------------------------------------------ 7 reflection
+ def reflection_phase(self):
+ n = self.n
+ n.reflect(self.wl, self.sea, self.src, stretch=1.3, ripple=5, darken=0.85, mixw=0.25, thr=0.1,
+ length=lambda x, y: 16 + 0.2 * np.clip(y - HZ, 0, None), width=(2.0, 3.2), density=1.4, seed=81)
+ n.glitter(EX, self.wl[EX] + 1, 966, w0=14, w1=150, power=1.0, density=1.5, seed=82)
+
+ # ------------------------------------------------------------ 8 reef and the two watchers
+ def figures_phase(self):
+ n = self.n
+ cx, wy = REEF
+ pts = [(cx - 150, wy + 2), (cx - 128, wy - 8), (cx - 92, wy - 16), (cx - 52, wy - 22), (cx - 14, wy - 25), (cx + 30, wy - 24),
+ (cx + 66, wy - 18), (cx + 98, wy - 12), (cx + 124, wy - 6), (cx + 146, wy + 2)]
+ reef = n.poly(pts, smooth=True)
+ reef = reef * (n.YY < wy + 2)
+ behind = n.ellipse(cx + 20, wy - 30, 230, 34) * self.sea * (1 - reef) # a few glints to silhouette them
+ n.hatch(behind * 0.7, 0.0, '#6c7eac', (14, 40), (1.4, 2.2), 0.4, jitter=0.02, value=0.12, pressure=0.92, dry=0.5,
+ alpha=0.75, seed=90)
+ n.silhouette(reef, 'land', n.flow(-6, 10, 60, seed=91), val=n.value(0.32, 0.12, wy - 26, wy, 0.1, 30, seed=92),
+ density=2.6, length=(6, 16), width=(1.6, 2.6), rim=0.14, rim_from=(EX, EY - 40), seed=93)
+ under = n.poly([(cx - 156, wy + 1), (cx + 152, wy + 1), (cx + 120, wy + 16), (cx - 120, wy + 16)]) * self.sea
+ n.hatch(under, 0.0, '#0a1129', (20, 60), (1.8, 2.6), 1.4, jitter=0.02, value=0.1, pressure=0.9, alpha=0.8, seed=94)
+ surf = n.poly([(cx - 160, wy - 1), (cx + 160, wy - 1), (cx + 160, wy + 3), (cx - 160, wy + 3)]) * (1 - reef * 0.7)
+ n.hatch(surf * 0.5, 0.0, '#7d8db8', (6, 18), (1.2, 1.8), 0.5, value=0.1, pressure=0.88, dry=0.5, alpha=0.7, seed=95)
+ n.figure(cx + 4, wy - 23, 44, facing=1, accent='scarf', legs='knees', rim_from=(EX, EY), rim=0.45, seed=96)
+ n.figure(cx + 37, wy - 22, 40, facing=1, accent=None, legs='knees', lean=0.18, rim_from=(EX, EY), rim=0.45,
+ hat=True, accent2='#2b2f45', seed=97)
+
+ def finish(self):
+ n = self.n
+ n.mount(plate=16, depth=0.06)
+ x0, y0, x1, y1 = BOX
+ n.caption('Forty seconds', x0 + 2, y1 + 58, 27, anchor='ls', weight='light', seed=101)
+ n.caption('lava meeting the sea before dawn', x1 - 2, y1 + 58, 19, anchor='rs', weight='light', alpha=0.75, seed=102)
+ n.bloom(1.0); n.grain(1.0)
+
+
+PHASES = (('sky', 'sky_phase'), ('land', 'land_phase'), ('steam', 'steam_phase'), ('glow', 'glow_phase'),
+ ('threads', 'threads_phase'), ('sea', 'sea_phase'), ('reflection', 'reflection_phase'), ('figures', 'figures_phase'))
+
+
+def main():
+ out = sys.argv[1] if len(sys.argv) > 1 and not sys.argv[1].startswith('--') else 'nocturne_lava_sea.jpg'
+ stages = sys.argv[sys.argv.index('--stages') + 1] if '--stages' in sys.argv else None
+ T0 = time.time()
+ tick = (lambda name: print(f'{name:10s} {time.time() - T0:5.1f}s')) if os.environ.get('NC_TIMING') else (lambda n: None)
+ n = Nocturne(W, H, seed=12, keep_stages=bool(stages), stages_dir=stages)
+ n.sheet(BOX)
+ n.stage('sheet')
+ sc = Scene(n)
+ sc.lights()
+ tick('setup')
+ for name, ph in PHASES:
+ getattr(sc, ph)()
+ tick(name)
+ n.stage(name)
+ sc.finish()
+ n.save(out, stages_dir=stages)
+ tick('saved')
+ print('saved', out, f'{time.time() - T0:.1f}s', n.n_strokes, 'strokes')
+
+
+if __name__ == '__main__':
+ main()
diff --git a/lib/nocturne.py b/lib/nocturne.py
new file mode 100644
index 0000000..9f3c63b
--- /dev/null
+++ b/lib/nocturne.py
@@ -0,0 +1,989 @@
+"""nocturne — 排线夜景 / Hatched Nocturne: a small night-scene print built entirely from short directional strokes
+(numpy + Pillow only).
+
+The look: a contemporary pastel / coloured-pencil nocturne printed small on cream paper. Sky, cloud, land and sea
+are all laid with dense short strokes, like pastel hatching or a dry brush dragged across the sheet; the strokes of
+one area all follow one "wind" (the sky streams diagonally, steam curls round its billows, the sea drags in long
+horizontals), each stroke a hair different in hue and value, with fine dark gaps of the underpaint between them. The
+palette is a deep indigo / navy / cold grey-blue night with exactly one warm light (red-orange); where that light
+falls, more strokes are laid on top by adding light (yellow-white at the core, orange then red further out, then
+the strokes of whatever it lights). Glowing filaments with bright tips, scattered sparks, a broken warm reflection
+on the water, a tiny figure for scale, and the whole thing mounted as a small print: cream margins with paper tooth,
+an embossed plate mark, a pencilled title bottom left and a smaller note bottom right in a thin plain face.
+
+Physical model
+ sheet Cream paper with an equalised tooth `T` (uniform 0..1), low mottling and a few fibres. The picture area
+ is underpainted with a dark ground; every mark later is clipped to the picture (a taped edge), so the
+ margins stay clean. `mount()` presses a plate mark round the picture (a soft groove: dark on the top
+ and left walls, a light lip at the bottom and right), `caption()` pencils the text.
+ strokes The unit of paint is one short stroke: a centreline integrated through an orientation field (angles
+ mod pi, so a stroke never flips direction halfway), bent a little, outlined with a blunt landing and a
+ tapering tail. Tens of thousands are rasterised at once: Pillow fills each outline with its own id into
+ a 2x supersampled integer map (later ids cover earlier ones), and for every covered pixel numpy looks
+ up that stroke's colour, start, direction, length and width, recovers the pixel's position along the
+ stroke (u) and across it (v), and from v its bristle lane: each stroke has six lanes with their own
+ value and load, lanes run dry toward the tail (`dry`), and the pigment only catches the paper where the
+ tooth is below the pressure (`pressure`), so every stroke is streaky and grainy and the dark ground
+ shows through in hairline gaps. Then it is box-averaged back to 1x. Within one batch the top stroke
+ wins (no muddy accumulation); the layers come from several passes.
+ colour A stroke takes one colour: a paint, a ramp indexed by a value field, or any function of position; then
+ its own value (`value`) and hue (`hue`, a true rotation about the grey axis) jitter, and `lit` adds the
+ light map at its centre, so strokes inside the glow are themselves warm.
+ light Lights are registered (`light()` for a point, `light_from()` for an emitting mask such as lava
+ threads) and summed into a light map. `glow()` lays light strokes: they land with a probability that
+ follows (light x receptivity), coloured by the light map, so a glow is many warm strokes thinning out
+ into the dark, never a smooth blob. Receptivity says what catches the light: the undersides of steam
+ billows most, sky a little, slopes near the lava. Air and glare are added (screen); a lit surface is
+ painted as light x receptivity (`blend='paint'`) -- adding orange to a blue-grey cloud turns it pink,
+ painting it turns it red-orange -- and `whiten` pulls the hottest of those toward a warm white.
+ source `source()` is the hot point: a tight cluster of white-yellow strokes, a fan of orange then red strokes
+ radiating from it, a tiny white core and a small bloom.
+ filaments `threads()` grows braided rivulets: a walk with momentum that keeps turning toward its end (and down
+ the fall line away from a summit), so it meanders instead of zig-zagging like lightning; sub-strands
+ drift apart toward the end, low-angle side branches peel off and fade out or stop in a bead, and the
+ intensity is patchy (crusted stretches), hottest at the fronts.
+ `filaments()` draws them as emission into a 2x float buffer (thin lines whose intensity follows crusted
+ patches), adds a tight halo, lays light strokes on whatever they light, and puts bright beads on the
+ tips. `sparks()` throws ballistic sparks as short fading streaks with a hot head.
+ water `reflect()` paints horizontal strokes on the sea whose colour is the mirrored picture above the
+ waterline (stretched by the waves, pushed sideways by ripples, darkened toward the sea colour), and
+ only where that mirror is bright, so the reflection is broken into strokes; `glitter()` is the column
+ a light on the waterline throws toward the viewer: hot near the source, widening and breaking up.
+ figures `figure()` is a tiny seated silhouette (a few dozen px): head, torso, bent legs, arms, an accent
+ (scarf, hat) and a warm rim on the side that faces the light. `silhouette()` paints a dark mass (rock,
+ island, mountain) with strokes and an optional lit rim.
+ finish `render()` adds a restrained bloom round the brightest light and a fine pastel grain.
+
+API (canvas pixel coordinates; angles of fields in radians, `flow()` takes degrees; colours are PAINTS names,
+ '#rrggbb' or RGB triples; ramps are RAMPS names or lists)
+ surface Nocturne(W, H, seed, keep_stages, stages_dir); sheet(box, paper, ground); poly(pts) / ellipse(cx, cy,
+ rx, ry) / blob(cx, cy, rx, ry, rough) / below(xs, ys) masks
+ fields flow(angle_deg, turb, scale); radial(cx, cy, offset, turb); contour(density, sigma); blend(f1, f2, w);
+ value(top, bottom, y0, y1, mottle, scale) value fields
+ strokes hatch(region, field, colour, length, width, density, jitter, bend, value, hue, alpha, pressure, dry,
+ lanes, lit, mode='paint'|'light', taper, clip)
+ light light(x, y, r, colour, power, squash); light_from(emission, spread, colour, power); lightmap();
+ glow(receptivity, field, length, width, density, power, reach, blend='light'|'paint', ambient,
+ whiten); source(x, y, r, power, field, squash, core)
+ threads threads(start, ends, wander, strands, spread, branches, branch_len, width, fall, heat) -> paths;
+ filaments(paths, gain, halo, light, receptivity, field, beads); sparks(x, y, n, spread, speed);
+ embers(region, n); stars(region, n, size, bright)
+ water reflect(waterline, region, src, stretch, ripple, darken, thr, ...); glitter(x, y_water, y_end, w0, w1)
+ figures silhouette(mask, ramp, field, rim, rim_from); figure(x, y, h, facing, accent, legs, rim_from)
+ finish mount(plate, depth); caption(text, x, y, size, anchor, weight); bloom(amount); grain(amount);
+ render(); composite(); stage(name); save(path, stages_dir)
+
+ import sys; sys.path.insert(0, 'lib')
+ from nocturne import Nocturne
+ n = Nocturne(1920, 1080, seed=3)
+ n.sheet((80, 56, 1840, 966))
+ sky = n.below(None, 600, invert=True)
+ n.hatch(sky, n.flow(14), ('sky', n.value(0.15, 0.7, 56, 600)), density=2.2)
+ n.light(1150, 610, 240, 'ember', 1.2); n.source(1150, 610, 40)
+ n.mount(); n.caption('Forty seconds', 80, 1030, 27); n.save('night.jpg')
+"""
+import io
+import os
+import glob
+import numpy as np
+from PIL import Image, ImageDraw, ImageFont
+from core import blur, fbm1d, noise2d, smoothstep, spline, blob_pts, load_font
+
+
+PAINTS = {
+ 'paper': '#e8dfcb', 'pencil': '#57544f', 'ground': '#0d1331',
+ 'night': '#111842', 'indigo': '#18225a', 'navy': '#15204c', 'dusk': '#2a386b', 'haze': '#46557f',
+ 'starlight': '#9eaed6', 'mist': '#7383b0', 'slate': '#363f62', 'steam': '#585e7c', 'steam_lit': '#dcc6b3',
+ 'rock': '#0a0d1b', 'rock_lit': '#232842', 'sea': '#13204a', 'sea_deep': '#0b1334', 'glint': '#8ea1d0',
+ 'blood': '#a51f0c', 'ember': '#ff5a1a', 'lava': '#ff8a2a', 'flame': '#ffbf5e', 'core': '#fff3d2',
+ 'scarf': '#e8502a', 'star': '#eef2ff', 'warmstar': '#ffe6c4',
+}
+
+RAMPS = {
+ 'fire': ['#2a0602', '#781505', '#c42e0a', '#f25814', '#ff8a2a', '#ffc05c', '#ffe8a6', '#fffbea'],
+ 'ember': ['#3a0804', '#7d1607', '#b8280a', '#e2470f', '#f86e1d', '#ff9a3c'],
+ 'sky': ['#0b1130', '#11183e', '#17204a', '#1f2a55', '#2c3863', '#414f78', '#66769c', '#95a2c2'],
+ 'sea': ['#080d27', '#0d1434', '#121c41', '#1a264e', '#25335c', '#364772', '#5a6c98', '#8c9cc1'],
+ 'steam': ['#161b38', '#232947', '#343a5a', '#4d5371', '#6c708b', '#9192a8'],
+ 'land': ['#050714', '#080b1d', '#0c1025', '#11162e', '#191f39', '#232a47'],
+ 'isle': ['#0c1230', '#111839', '#172042', '#1e284c', '#273257', '#323e63'],
+}
+
+NL = 6 # bristle lanes per stroke
+
+
+def hexc(c):
+ """'#rrggbb', a PAINTS name or an RGB triple -> float32 RGB in 0..1"""
+ if not isinstance(c, str): return np.asarray(c, np.float32)
+ h = PAINTS.get(c, c).lstrip('#')[:6]
+ return np.array([int(h[i:i + 2], 16) for i in (0, 2, 4)], np.float32) / 255
+
+
+def ramp(spec):
+ """a RAMPS name or a list of colours -> (K, 3) array, dark -> light"""
+ if isinstance(spec, np.ndarray): return spec.astype(np.float32)
+ if isinstance(spec, str): spec = RAMPS[spec]
+ return np.stack([hexc(c) for c in spec]).astype(np.float32)
+
+
+def ramp_at(R, l):
+ """colour at 0..1 positions l along ramp R (vectorised)"""
+ l = np.clip(np.asarray(l, np.float32), 0, 1) * (len(R) - 1)
+ i = np.minimum(l.astype(np.int32), len(R) - 2)
+ f = (l - i)[..., None]
+ return R[i] * (1 - f) + R[i + 1] * f
+
+
+def hue_rotate(c, theta):
+ """rotate RGB colours (N, 3) about the grey axis by theta radians (N,): a real hue shift, value kept"""
+ cs, sn = np.cos(theta)[:, None], np.sin(theta)[:, None]
+ m = c.mean(1, keepdims=True)
+ cr = np.stack([c[:, 2] - c[:, 1], c[:, 0] - c[:, 2], c[:, 1] - c[:, 0]], 1) / np.sqrt(3)
+ return (c * cs + cr * sn + m * (1 - cs)).astype(np.float32)
+
+
+def _equalise(a):
+ """rank-equalise to a uniform 0..1 distribution"""
+ flat = a.ravel()
+ o = np.argsort(flat, kind='stable')
+ out = np.empty(flat.size, np.float32)
+ out[o] = np.linspace(0, 1, flat.size, dtype=np.float32)
+ return out.reshape(a.shape)
+
+
+def _lookup(field, x, y):
+ if np.ndim(field) == 0: return np.full(len(x), float(field), np.float32)
+ H, W = field.shape[:2]
+ return field[np.clip(y.astype(np.int32), 0, H - 1), np.clip(x.astype(np.int32), 0, W - 1)]
+
+
+def _font(weight, size):
+ """a thin plain face (no script / handwriting): Helvetica Neue Light / Thin, Avenir Light, DejaVu ExtraLight..."""
+ cands = {'light': [('/System/Library/Fonts/HelveticaNeue.ttc', 7), ('/System/Library/Fonts/Avenir.ttc', 6),
+ ('/usr/share/fonts/**/DejaVuSans-ExtraLight.ttf', 0), ('/usr/share/fonts/**/Lato-Light.ttf', 0),
+ ('C:/Windows/Fonts/segoeuil.ttf', 0), ('C:/Windows/Fonts/arial.ttf', 0)],
+ 'thin': [('/System/Library/Fonts/HelveticaNeue.ttc', 12), ('/System/Library/Fonts/Avenir Next.ttc', 10),
+ ('/usr/share/fonts/**/DejaVuSans-ExtraLight.ttf', 0), ('/usr/share/fonts/**/Lato-Hairline.ttf', 0),
+ ('C:/Windows/Fonts/segoeuisl.ttf', 0), ('C:/Windows/Fonts/arial.ttf', 0)]}
+ env = os.environ.get('INKPAINT_FONT_' + weight.upper())
+ if env and os.path.exists(env): return ImageFont.truetype(env, int(size))
+ for pat, idx in cands.get(weight, cands['light']):
+ for p in glob.glob(pat, recursive=True):
+ try: return ImageFont.truetype(p, int(size), index=idx)
+ except OSError: pass
+ return load_font('sans', size)
+
+
+class Nocturne:
+ PAINTS = PAINTS
+ RAMPS = RAMPS
+
+ def __init__(self, W=1920, H=1080, seed=0, keep_stages=True, stages_dir=None):
+ if W * H > 4096 * 4096: raise ValueError('canvas larger than 4096 x 4096')
+ self.W, self.H, self.seed = W, H, seed
+ self.rng = np.random.default_rng(seed)
+ self.keep_stages, self.stages_dir = keep_stages, stages_dir
+ self.stages, self._n_stages = [], 0
+ self.C = np.empty((H, W, 3), np.float32); self.C[:] = hexc('paper')
+ r = np.random.default_rng(seed + 101)
+ z = lambda a: (a - a.mean()) / (a.std() + 1e-6)
+ g1 = blur(r.random((H, W)).astype(np.float32), 0.6)
+ g2 = noise2d(H, W, 2.4, 2, seed + 102)
+ g3 = noise2d(H, W, 8.0, 2, seed + 103)
+ self.T = _equalise(0.55 * z(g1) + 0.35 * z(g2) + 0.2 * z(g3)) # paper tooth, uniform 0..1
+ self.TD = None # tooth dragged along 8 directions (lazy)
+ self.YY, self.XX = np.mgrid[0:H, 0:W].astype(np.float32)
+ self.pic = None; self.box = (0, 0, W, H)
+ self.lights = []; self._L = None
+ self.bloom_amt = 0.0; self.grain_amt = 0.0
+ self.n_strokes = 0
+
+ def _r(self, seed=None):
+ return np.random.default_rng(int(self.rng.integers(1 << 30)) if seed is None else seed)
+
+ # ================================================================== masks
+ def poly(self, pts, smooth=False, ss=2):
+ """filled polygon -> canvas-sized float mask (smooth=True runs a Catmull-Rom spline through the points)"""
+ P = spline(pts, 10) if smooth else np.asarray(pts, np.float32)
+ im = Image.new('L', (self.W * ss, self.H * ss), 0)
+ ImageDraw.Draw(im).polygon([(float(x) * ss, float(y) * ss) for x, y in P], fill=255)
+ return np.asarray(im.resize((self.W, self.H), Image.BOX), np.float32) / 255
+
+ def ellipse(self, cx, cy, rx, ry=None, rot=0.0):
+ ry = rx if ry is None else ry
+ c, s = np.cos(rot), np.sin(rot)
+ dx, dy = self.XX - cx, self.YY - cy
+ u, v = (dx * c + dy * s) / rx, (-dx * s + dy * c) / ry
+ d = np.sqrt(u * u + v * v)
+ return np.clip((1 - d) * min(rx, ry) + 0.5, 0, 1).astype(np.float32)
+
+ def blob(self, cx, cy, rx, ry, rough=0.12, seed=None, rot=0.0):
+ return self.poly(blob_pts(cx, cy, rx, ry, rough, 120, int(self._r(seed).integers(1 << 30)), rot))
+
+ def below(self, xs, ys, invert=False):
+ """mask of everything below a line through (xs, ys) (spline), or a constant y if xs is None"""
+ if xs is None:
+ m = np.clip(self.YY - float(ys) + 0.5, 0, 1)
+ else:
+ x = np.arange(self.W, dtype=np.float32)
+ P = spline(np.stack([xs, ys], 1), 12)
+ o = np.argsort(P[:, 0])
+ yl = np.interp(x, P[o, 0], P[o, 1]).astype(np.float32)
+ m = np.clip(self.YY - yl[None] + 0.5, 0, 1)
+ return (1 - m if invert else m).astype(np.float32)
+
+ def _mask(self, region):
+ if isinstance(region, np.ndarray): return region.astype(np.float32, copy=False)
+ x0, y0, x1, y1 = (int(round(v)) for v in region)
+ M = np.zeros((self.H, self.W), np.float32)
+ M[max(0, y0):max(0, y1), max(0, x0):max(0, x1)] = 1
+ return M
+
+ # ================================================================== fields
+ def flow(self, angle=0.0, turb=10.0, scale=260.0, seed=None):
+ """orientation field: `angle` degrees (screen y down: positive tilts down to the right), +-turb degrees
+ of low-frequency wander at `scale` px"""
+ n = noise2d(self.H, self.W, scale, 3, int(self._r(seed).integers(1 << 30))) - 0.5
+ return np.deg2rad(angle + 2 * turb * n).astype(np.float32)
+
+ def radial(self, cx, cy, offset=0.0, turb=6.0, scale=120.0, seed=None):
+ """strokes pointing away from (cx, cy) (fall lines of a cone, rays of a light), offset in degrees"""
+ a = np.arctan2(self.YY - cy, self.XX - cx) + np.deg2rad(offset)
+ if turb:
+ a = a + np.deg2rad(2 * turb * (noise2d(self.H, self.W, scale, 3, int(self._r(seed).integers(1 << 30))) - 0.5))
+ return a.astype(np.float32)
+
+ def contour(self, density, sigma=6.0):
+ """strokes running along the contours of a density (round a billow, along a ridge)"""
+ d = blur(density, sigma)
+ gy, gx = np.gradient(d)
+ return (np.arctan2(gy, gx) + np.pi / 2).astype(np.float32)
+
+ @staticmethod
+ def blend(f1, f2, w):
+ """blend two orientation fields (doubled-angle average, so 0 and pi are the same orientation)"""
+ w = np.asarray(w, np.float32)
+ c = (1 - w) * np.cos(2 * f1) + w * np.cos(2 * f2)
+ s = (1 - w) * np.sin(2 * f1) + w * np.sin(2 * f2)
+ return (0.5 * np.arctan2(s, c)).astype(np.float32)
+
+ def value(self, top=0.15, bottom=0.7, y0=0, y1=None, mottle=0.08, scale=200.0, seed=None):
+ """a 0..1 value field: a vertical ramp from `top` at y0 to `bottom` at y1, with low-frequency mottling"""
+ y1 = self.H if y1 is None else y1
+ t = np.clip((self.YY - y0) / max(1, y1 - y0), 0, 1)
+ v = top + (bottom - top) * t
+ if mottle:
+ v = v + 2 * mottle * (noise2d(self.H, self.W, scale, 3, int(self._r(seed).integers(1 << 30))) - 0.5)
+ return v.astype(np.float32)
+
+ # ================================================================== the sheet
+ def sheet(self, box=None, paper='paper', ground='ground', edge=0.5, fibres=220, seed=None):
+ """cream paper with tooth, mottling and fibres; the picture area `box` underpainted with a dark ground"""
+ H, W = self.H, self.W
+ r = self._r(seed)
+ if box is None:
+ mx, my = int(W * 0.042), int(H * 0.052)
+ box = (mx, my, W - mx, H - int(H * 0.105))
+ self.box = tuple(int(v) for v in box)
+ x0, y0, x1, y1 = self.box
+ mot = noise2d(H, W, 150, 4, int(r.integers(1 << 30))) - 0.5
+ C = hexc(paper)[None, None] * (1 + 0.03 * mot[..., None] - 0.022 * (self.T[..., None] - 0.5))
+ im = Image.new('L', (W, H), 0); d = ImageDraw.Draw(im)
+ for _ in range(fibres):
+ px, py = r.uniform(0, W), r.uniform(0, H)
+ a = r.uniform(0, np.pi); L = r.uniform(6, 26)
+ pts = [(px + np.cos(a) * L * t + r.normal(0, 1.2), py + np.sin(a) * L * t + r.normal(0, 1.2)) for t in np.linspace(-0.5, 0.5, 5)]
+ d.line(pts, fill=int(r.uniform(40, 110)), width=1)
+ fib = blur(np.asarray(im, np.float32) / 255, 0.5)
+ C = C * (1 - 0.05 * fib[..., None])
+ # the taped picture edge: crisp, with a hair of wobble
+ wob_x = fbm1d(H, 40, 3, int(r.integers(1 << 30))) * edge
+ wob_y = fbm1d(W, 40, 3, int(r.integers(1 << 30))) * edge
+ X, Y = self.XX, self.YY
+ dl = X - (x0 + wob_x[:, None]); dr = (x1 + wob_x[::-1, None]) - X
+ dt = Y - (y0 + wob_y[None]); db = (y1 + wob_y[None, ::-1]) - Y
+ self.pic = np.clip(np.minimum(np.minimum(dl, dr), np.minimum(dt, db)) + 0.5, 0, 1).astype(np.float32)
+ g = hexc(ground)[None, None] * (1 + 0.08 * mot[..., None])
+ self.C = (C * (1 - self.pic[..., None]) + g * self.pic[..., None]).astype(np.float32)
+
+ # ================================================================== strokes
+ def _dragged(self, drag=6):
+ """the tooth smeared along 8 stroke directions: a dry stroke skips the paper in short streaks along itself"""
+ if self.TD is None:
+ T = self.T
+ TD = np.empty((8, self.H, self.W), np.float32)
+ ks = np.arange(-drag, drag + 1); wk = 1.0 - np.abs(ks) / (drag + 1.0)
+ for b in range(8):
+ a = np.pi * b / 8
+ acc = np.zeros_like(T)
+ for k, w in zip(ks, wk):
+ acc += w * np.roll(T, (int(round(k * np.sin(a))), int(round(k * np.cos(a)))), axis=(0, 1))
+ TD[b] = _equalise(0.3 * T + 0.7 * acc / wk.sum())
+ self.TD = TD
+ return self.TD
+
+ def _sizes(self, spec, x, y, r):
+ n = len(x)
+ if callable(spec):
+ return (np.asarray(spec(x, y), np.float32) * r.uniform(0.75, 1.25, n)).astype(np.float32)
+ if np.ndim(spec) == 0: return np.full(n, float(spec), np.float32) * r.uniform(0.85, 1.15, n).astype(np.float32)
+ return r.uniform(spec[0], spec[1], n).astype(np.float32)
+
+ def _colours(self, spec, x, y, r):
+ n = len(x)
+ if callable(spec): return np.asarray(spec(x, y), np.float32).reshape(n, 3).copy()
+ if isinstance(spec, tuple) and len(spec) == 2 and not np.isscalar(spec[1]):
+ R = ramp(spec[0]); f = spec[1]
+ v = f(x, y) if callable(f) else _lookup(f, x, y)
+ return ramp_at(R, v).astype(np.float32)
+ return np.broadcast_to(hexc(spec), (n, 3)).astype(np.float32).copy()
+
+ def _centrelines(self, x, y, L, field, jit, bend, k):
+ n = len(x)
+ P = np.zeros((n, k, 2), np.float32)
+ c = k // 2
+ P[:, c, 0] = x; P[:, c, 1] = y
+ st = L / (k - 1)
+ a0 = _lookup(field, x, y) + jit
+ d0 = np.stack([np.cos(a0), np.sin(a0)], 1).astype(np.float32)
+ for sgn in (1, -1):
+ px, py = x.copy(), y.copy()
+ prev = d0 * sgn
+ for j in range(1, k - c if sgn > 0 else c + 1):
+ a = _lookup(field, px, py) + jit + sgn * bend * j
+ v = np.stack([np.cos(a), np.sin(a)], 1).astype(np.float32)
+ flip = (v * prev).sum(1) < 0
+ v[flip] *= -1
+ px = px + v[:, 0] * st; py = py + v[:, 1] * st
+ P[:, c + sgn * j, 0] = px; P[:, c + sgn * j, 1] = py
+ prev = v
+ return P
+
+ @staticmethod
+ def _outline(P, Wd, taper):
+ n, k, _ = P.shape
+ t = np.linspace(0, 1, k, dtype=np.float32)
+ Tg = np.gradient(P, axis=1)
+ Tg /= np.linalg.norm(Tg, axis=2, keepdims=True) + 1e-6
+ Nn = np.stack([-Tg[..., 1], Tg[..., 0]], -1)
+ s0, s1 = taper
+ prof = np.minimum(np.clip(s0 + (1 - s0) * t / 0.22, 0, 1), np.clip(s1 + (1 - s1) * (1 - t) / 0.5, 0, 1)) ** 0.8
+ hw = (Wd[:, None] * 0.5) * prof[None]
+ left = P + Nn * hw[..., None]; right = P - Nn * hw[..., None]
+ return np.concatenate([left, right[:, ::-1]], 1)
+
+ def hatch(self, region, field=0.0, colour='indigo', length=(16, 34), width=(2.2, 3.4), density=1.0,
+ jitter=0.1, bend=0.06, value=0.08, hue=0.04, alpha=0.95, pressure=0.95, dry=0.35, lanes=0.14,
+ lit=0.0, mode='paint', taper=(0.5, 0.12), clip=None, seed=None):
+ """lay strokes over `region` (mask = landing probability, or a box) following orientation `field`.
+ density ~ how many times the strokes would tile the region; length / width: (lo, hi), a number or
+ f(x, y); colour: paint, (ramp, value field or f(x, y)) or f(x, y) -> (N, 3); value / hue: per-stroke
+ jitter; pressure: how far the pigment sinks into the tooth (1 = solid); dry: lanes running out toward the
+ tail; lanes: value spread between bristle lanes; lit: add the light map; mode 'paint' covers,
+ 'light' adds light (screen)."""
+ r = self._r(seed)
+ M = self._mask(region)
+ rows = np.flatnonzero(M.max(1) > 0.004); cols_ = np.flatnonzero(M.max(0) > 0.004)
+ if not len(rows) or not len(cols_): return 0
+ bx0, bx1, by0, by1 = cols_[0], cols_[-1] + 1, rows[0], rows[-1] + 1
+ area = float(M[by0:by1, bx0:bx1].sum())
+ if area < 1: return 0
+ px_ = r.uniform(bx0, bx1, 4000).astype(np.float32); py_ = r.uniform(by0, by1, 4000).astype(np.float32)
+ keep = r.random(4000) < _lookup(M, px_, py_)
+ if keep.sum() < 10: keep[:] = True
+ Lm = float(self._sizes(length, px_[keep], py_[keep], r).mean()); Wm = float(self._sizes(width, px_[keep], py_[keep], r).mean())
+ n = int(density * area / (0.62 * Lm * Wm))
+ if n < 1: return 0
+ cand = int(n * (bx1 - bx0) * (by1 - by0) / area * 1.02) + 8
+ x = r.uniform(bx0, bx1, cand).astype(np.float32); y = r.uniform(by0, by1, cand).astype(np.float32)
+ ok = r.random(cand) < _lookup(M, x, y)
+ x, y = x[ok], y[ok]
+ n = len(x)
+ if not n: return 0
+ L = self._sizes(length, x, y, r); Wd = self._sizes(width, x, y, r)
+ cols = self._colours(colour, x, y, r)
+ if value: cols *= (1 + value * r.normal(0, 1, n).astype(np.float32))[:, None]
+ if hue: cols = hue_rotate(cols, (hue * r.normal(0, 1, n)).astype(np.float32))
+ if lit: cols += lit * _lookup(self.lightmap(), x, y)
+ cols = np.clip(cols, 0, 1)
+ k = 5 if Lm < 48 else 7
+ P = self._centrelines(x, y, L, field, (jitter * r.normal(0, 1, n)).astype(np.float32),
+ (bend * r.normal(0, 1, n)).astype(np.float32), k)
+ poly = self._outline(P, Wd, taper)
+ al = np.broadcast_to(np.asarray(alpha, np.float32), (n,)) * r.uniform(0.88, 1.0, n).astype(np.float32)
+ pr = np.broadcast_to(np.asarray(pressure, np.float32), (n,)) * r.uniform(0.95, 1.03, n).astype(np.float32)
+ self._raster(poly, P[:, 0], P[:, -1], Wd, cols, al, pr, dry, lanes, mode, clip, r)
+ self.n_strokes += n
+ return n
+
+ def _raster(self, poly, s, e, Wd, cols, al, pr, dry, lanes, mode, clip, r, ss=2):
+ n = len(poly)
+ lo = poly.reshape(-1, 2).min(0); hi = poly.reshape(-1, 2).max(0)
+ x0, y0 = max(0, int(np.floor(lo[0])) - 1), max(0, int(np.floor(lo[1])) - 1)
+ x1, y1 = min(self.W, int(np.ceil(hi[0])) + 2), min(self.H, int(np.ceil(hi[1])) + 2)
+ if x1 <= x0 or y1 <= y0: return
+ w, h = x1 - x0, y1 - y0
+ im = Image.new('I', (w * ss, h * ss), 0)
+ d = ImageDraw.Draw(im)
+ Q = ((poly - np.array([x0, y0], np.float32)) * ss).reshape(n, -1).tolist()
+ for i, q in enumerate(Q): d.polygon(q, fill=i + 1)
+ ids = np.asarray(im)
+ dv = e - s
+ Ls = np.linalg.norm(dv, axis=1) + 1e-3
+ dv = dv / Ls[:, None]
+ tab = np.zeros((n + 1, 12), np.float32)
+ tab[1:, :3] = cols; tab[1:, 3] = al; tab[1:, 4:6] = s; tab[1:, 6:8] = dv
+ tab[1:, 8] = 1 / Ls; tab[1:, 9] = 1 / np.maximum(Wd, 0.5); tab[1:, 10] = pr; tab[1:, 11] = dry
+ BIN = np.zeros(n + 1, np.int32)
+ BIN[1:] = np.round(np.mod(np.arctan2(dv[:, 1], dv[:, 0]), np.pi) / np.pi * 8).astype(np.int32) % 8
+ TD = self._dragged()
+ LN = np.zeros((n + 1, NL), np.float32); LN[1:] = r.random((n, NL))
+ Cs = self.C[y0:y1, x0:x1]
+ CH = max(4, int(6e5 / (w * ss * ss)))
+ xx = (x0 + (np.arange(w * ss, dtype=np.float32) + 0.5) / ss)[None, :]
+ for r0 in range(0, h, CH):
+ r1 = min(h, r0 + CH)
+ sub = ids[r0 * ss:r1 * ss]
+ if not sub.any(): continue
+ tb = tab[sub]
+ yy = (y0 + (np.arange(r0 * ss, r1 * ss, dtype=np.float32) + 0.5) / ss)[:, None]
+ qx = xx - tb[..., 4]; qy = yy - tb[..., 5]
+ u = np.clip((qx * tb[..., 6] + qy * tb[..., 7]) * tb[..., 8], 0, 1)
+ v = (qy * tb[..., 6] - qx * tb[..., 7]) * tb[..., 9] + 0.5
+ li = np.clip((v * NL).astype(np.int32), 0, NL - 1)
+ lv = LN[sub, li]
+ cover = np.clip((lv - tb[..., 11] * u ** 1.5) * 7 + 0.5, 0, 1)
+ iy = (y0 + np.arange(r0 * ss, r1 * ss) // ss)[:, None]; ix = (x0 + np.arange(w * ss) // ss)[None, :]
+ Tt = TD[BIN[sub], iy, ix]
+ grain = np.clip((tb[..., 10] * (0.97 + 0.06 * lv) - Tt) * 9 + 0.5, 0, 1)
+ A = tb[..., 3] * cover * grain * (1 - 0.22 * u * u)
+ Pm = tb[..., :3] * ((1 + lanes * (lv - 0.5) * 2) * A)[..., None]
+ hh = r1 - r0
+ A1 = A.reshape(hh, ss, w, ss).mean((1, 3))
+ P1 = Pm.reshape(hh, ss, w, ss, 3).mean((1, 3))
+ f = None
+ if self.pic is not None: f = self.pic[y0 + r0:y0 + r1, x0:x1]
+ if clip is not None:
+ cf = clip[y0 + r0:y0 + r1, x0:x1]
+ f = cf if f is None else f * cf
+ if f is not None: A1 = A1 * f; P1 = P1 * f[..., None]
+ seg = Cs[r0:r1]
+ if mode == 'light':
+ seg += P1 * (1 - seg)
+ else:
+ seg[:] = seg * (1 - A1[..., None]) + P1
+
+ # ================================================================== light
+ def light(self, x, y, r, colour='ember', power=1.0, squash=1.0):
+ """register a point light (falloff 1 / (1 + (d / r)^2)^1.2; squash < 1 flattens it vertically)"""
+ self.lights.append(('pt', float(x), float(y), float(r), hexc(colour), float(power), float(squash)))
+ self._L = None
+
+ def light_from(self, emission, spread=20.0, colour='ember', power=1.0):
+ """register an emitting mask (lava threads, a lit window) as a soft area light"""
+ b = blur(emission.astype(np.float32), spread)
+ b = b / (b.max() + 1e-6)
+ self.lights.append(('em', b, hexc(colour), float(power)))
+ self._L = None
+
+ def lightmap(self):
+ if self._L is None:
+ L = np.zeros((self.H, self.W, 3), np.float32)
+ for lt in self.lights:
+ if lt[0] == 'pt':
+ _, x, y, rr, col, pw, sq = lt
+ d2 = ((self.XX - x) / rr) ** 2 + ((self.YY - y) / (rr * sq)) ** 2
+ L += (pw / (1 + d2) ** 1.2)[..., None] * col
+ else:
+ _, b, col, pw = lt
+ L += (pw * b)[..., None] * col
+ self._L = L
+ return self._L
+
+ def glow(self, receptivity, field=0.0, length=(12, 28), width=(2.0, 3.2), density=1.2, power=1.0, reach=1.6,
+ value=0.14, hue=0.05, pressure=0.86, dry=0.45, alpha=1.0, blend='light', ambient=None, whiten=0.0,
+ seed=None, **kw):
+ """light strokes: land where light x receptivity is high (thinning out into the dark), coloured by the light
+ map -- a glow made of strokes. blend='light' adds them (screen: air, glare); blend='paint' lays them as lit
+ paint, colour = light x receptivity (+ `ambient`), so a lit cloud turns red-orange instead of the pink you
+ get from adding orange to blue-grey; `whiten` pulls the most strongly lit strokes toward a warm white (a
+ white thing near a hot light)"""
+ Lm = self.lightmap()
+ rec = self._mask(receptivity) if not isinstance(receptivity, np.ndarray) else receptivity
+ prob = np.clip(rec * Lm.max(-1) * reach, 0, 1) ** 0.75
+ amb = None if ambient is None else hexc(ambient)
+
+ def col(x, y):
+ c = _lookup(Lm, x, y) * _lookup(rec, x, y)[:, None] * power
+ if whiten:
+ mx = c.max(1, keepdims=True)
+ c = c + (np.minimum(mx, 1.0) * np.array([1.0, 0.93, 0.84], np.float32) - c) * whiten * smoothstep(0.7, 1.6, mx)
+ if amb is not None: c = c + amb * np.clip(1 - c.max(1, keepdims=True) * 1.5, 0, 1)
+ return np.clip(c, 0, 1)
+ return self.hatch(prob, field, col, length, width, density, value=value, hue=hue, pressure=pressure, dry=dry,
+ alpha=alpha, mode='light' if blend == 'light' else 'paint', seed=seed, **kw)
+
+ def source(self, x, y, r=40.0, power=1.0, field=None, squash=0.6, core=1.0, seed=None):
+ """the hot point: a fan of red -> orange -> yellow-white light strokes, a tiny white core, a small bloom"""
+ rr = self._r(seed)
+ f = self.radial(x, y, turb=10, seed=int(rr.integers(1 << 30))) if field is None else field
+ R = ramp('fire')
+ dist = np.sqrt((self.XX - x) ** 2 + ((self.YY - y) / squash) ** 2)
+ for k, (reach, dens, ln, wd, lo) in enumerate([(3.2, 1.0, (10, 26), (1.8, 3.0), 0.28), (2.0, 1.3, (8, 20), (1.6, 2.6), 0.42),
+ (1.1, 1.6, (5, 13), (1.4, 2.2), 0.58), (0.55, 2.0, (3, 8), (1.2, 2.0), 0.72)]):
+ prob = np.clip(1 - dist / (r * reach), 0, 1) ** 1.3
+
+ def col(xs, ys, reach=reach, lo=lo):
+ dd = _lookup(dist, xs, ys) / (r * reach)
+ return ramp_at(R, lo + (1 - lo) * (1 - dd) ** 1.6) * power
+ self.hatch(prob, f, col, ln, wd, dens, jitter=0.25, value=0.12, hue=0.03, pressure=0.85, dry=0.4,
+ mode='light', seed=int(rr.integers(1 << 30)))
+ cr = np.exp(-(dist / (r * 0.11)) ** 2) * core
+ halo = blur(np.clip(1 - dist / (r * 0.8), 0, 1) ** 2, r * 0.25)
+ add = cr[..., None] * hexc('core') * 0.9 + halo[..., None] * hexc('lava') * 0.18 * power * core
+ if self.pic is not None: add *= self.pic[..., None]
+ self.C += add * (1 - self.C)
+
+ # ================================================================== threads, filaments, sparks, stars
+ def _walk(self, p, target, step, wander, fall, r, max_len=None):
+ """a walk with momentum that keeps turning toward `target` (and away from `fall`, a summit, if given):
+ meanders like a rivulet, never zig-zags like a spark"""
+ p = np.asarray(p, np.float32).copy(); tgt = np.asarray(target, np.float32)
+ d = tgt - p; d /= np.linalg.norm(d) + 1e-6
+ pts = [p.copy()]; turn = 0.0; L = 0.0
+ D0 = float(np.linalg.norm(tgt - p))
+ for _ in range(4000):
+ to = tgt - p; dist = float(np.linalg.norm(to))
+ if dist < step * 1.5 or (max_len and L >= max_len): break
+ to /= dist
+ if fall is not None:
+ fl = p - np.asarray(fall, np.float32); fl /= np.linalg.norm(fl) + 1e-6
+ k = 0.4 * min(1.0, dist / (0.5 * D0 + 1e-6))
+ to = (1 - k) * to + k * fl; to /= np.linalg.norm(to) + 1e-6
+ turn = 0.85 * turn + r.normal(0, wander * 0.035)
+ pull = 0.16 + 0.3 * (1 - min(1.0, dist / (D0 + 1e-6)))
+ d = (1 - pull) * d + pull * to
+ c, s_ = np.cos(turn), np.sin(turn)
+ d = np.array([d[0] * c - d[1] * s_, d[0] * s_ + d[1] * c], np.float32); d /= np.linalg.norm(d) + 1e-6
+ p = p + d * step; L += step
+ pts.append(p.copy())
+ if not max_len: pts.append(tgt)
+ return np.array(pts, np.float32)
+
+ def threads(self, start, ends, wander=1.0, strands=3, spread=4.0, branches=8, branch_len=(30, 110),
+ width=(1.6, 1.1), step=2.5, fall=None, heat=(0.35, 0.8), seed=None):
+ """meandering, braided paths from `start` to each of `ends`; returns a list of path dicts
+ {'pts', 'w': (w0, w1), 'i': intensity per point, 'tip': bead brightness at the end (0 = fades out)}.
+ Sub-strands drift apart and cross (a braid); low-angle side branches peel off and fade or stop in a bead;
+ intensity is patchy (crusted stretches) between heat[0] and heat[1], hottest at the fronts."""
+ r = self._r(seed)
+ out = []
+ for e in ends:
+ main = self._walk(start, e, step, wander, fall, r)
+ m = len(main)
+ t = np.linspace(0, 1, m, dtype=np.float32)
+ tg = np.gradient(main, axis=0); tg /= np.linalg.norm(tg, axis=1, keepdims=True) + 1e-6
+ nn = np.stack([-tg[:, 1], tg[:, 0]], 1)
+ crust = smoothstep(-0.3, 0.3, fbm1d(m, max(4, m / 6), 3, int(r.integers(1 << 30))))
+ for s_ in range(strands):
+ so = fbm1d(m, max(4, m / 4), 2, int(r.integers(1 << 30))) * spread * (0.2 + 1.3 * t) * (s_ > 0)
+ pts = main + nn * so[:, None]
+ it = (heat[0] + (heat[1] - heat[0]) * crust) * (0.5 + 0.5 * smoothstep(0.0, 0.08, t)) * r.uniform(0.8, 1.0)
+ it = it * (1 + 0.45 * smoothstep(0.9, 1.0, t)) * (1.0 if s_ == 0 else r.uniform(0.6, 0.85))
+ out.append({'pts': pts, 'w': (width[0] * (1 if s_ == 0 else 0.7), width[1] * (1 if s_ == 0 else 0.7)),
+ 'i': it.astype(np.float32), 'tip': 1.0 if s_ == 0 else r.uniform(0.0, 0.6)})
+ for _ in range(max(0, branches // max(1, len(ends)))):
+ i0 = int(r.uniform(0.15, 0.85) * (m - 1))
+ ang = np.arctan2(tg[i0, 1], tg[i0, 0]) + r.choice([-1, 1]) * r.uniform(0.18, 0.5)
+ bl = r.uniform(*branch_len)
+ tgt = main[i0] + np.array([np.cos(ang), np.sin(ang)], np.float32) * bl
+ pts = self._walk(main[i0], tgt, step, wander * 1.2, fall, r, max_len=bl)
+ mb = len(pts)
+ if mb < 3: continue
+ tt = np.linspace(0, 1, mb, dtype=np.float32)
+ bead = r.random() < 0.5
+ it = (heat[0] + (heat[1] - heat[0]) * 0.6) * r.uniform(0.6, 0.95) * (1 - (0 if bead else 1) * smoothstep(0.45, 1.0, tt))
+ out.append({'pts': pts, 'w': (width[1] * 0.8, width[1] * 0.5), 'i': it.astype(np.float32),
+ 'tip': r.uniform(0.5, 0.9) if bead else 0.0})
+ return out
+
+ def _emission(self, paths, ss=2):
+ im = Image.new('F', (self.W * ss, self.H * ss), 0.0)
+ d = ImageDraw.Draw(im)
+ for p in sorted(paths, key=lambda p: float(np.mean(p['i']))):
+ P = p['pts'] * ss; it = p['i']; m = len(P)
+ ws = np.linspace(p['w'][0], p['w'][1], m) * ss
+ for j in range(m - 1):
+ d.line([tuple(P[j]), tuple(P[j + 1])], fill=float(0.5 * (it[j] + it[j + 1])), width=max(1, int(round(ws[j]))))
+ E = np.asarray(im, np.float32).reshape(self.H, ss, self.W, ss).mean((1, 3))
+ return E
+
+ def _emit(self, E, gain=1.0, halo=1.0, colour_ramp='fire'):
+ """composite an emission buffer: a tight halo, then the hot lines (screen)"""
+ R = ramp(colour_ramp)
+ h1 = blur(E, 1.5); h2 = blur(E, 4.5)
+ add = (np.clip(h1 * 0.9 * halo, 0, 1)[..., None] * hexc('ember') * 0.45
+ + np.clip(h2 * 0.9 * halo, 0, 1)[..., None] * hexc('blood') * 0.4)
+ lvl = np.clip(E * gain, 0, 1)
+ add = add + ramp_at(R, 0.3 + 0.62 * lvl ** 1.4) * np.clip(E * gain * 2.0, 0, 1)[..., None]
+ add = np.clip(add, 0, 1)
+ if self.pic is not None: add *= self.pic[..., None]
+ self.C += add * (1 - self.C)
+
+ def filaments(self, paths, gain=1.0, halo=1.0, light=0.0, receptivity=None, field=0.0, beads=0.35, seed=None):
+ """glowing threads: light strokes on what they light (if `light`), a tight halo, hot lines, bright tips"""
+ r = self._r(seed)
+ E = self._emission(paths)
+ if light:
+ rec = np.ones((self.H, self.W), np.float32) if receptivity is None else receptivity
+ g = blur(E, 14.0); g = g / (g.max() + 1e-6)
+ prob = np.clip(g * rec * 2.2, 0, 1) ** 0.8
+ R = ramp('ember')
+
+ def col(x, y):
+ gv = _lookup(g, x, y)
+ return ramp_at(R, 0.2 + 0.8 * np.clip(gv * 1.6, 0, 1)) * (light * np.clip(gv * 2.0, 0, 1))[:, None]
+ self.hatch(prob, field, col, (8, 22), (1.6, 2.8), 1.0, jitter=0.2, value=0.15, pressure=0.85, dry=0.45,
+ mode='light', seed=int(r.integers(1 << 30)))
+ self._emit(E, gain, halo)
+ # tips and beads: small hot dots
+ T = np.zeros((self.H, self.W), np.float32)
+ for p in paths:
+ P = p['pts']
+ if p['tip'] > 0: self._dot(T, P[-1][0], P[-1][1], 1.4 + 1.2 * p['tip'], p['tip'] * 1.2)
+ nb = r.poisson(beads * len(P) / 25)
+ for _ in range(nb):
+ j = int(r.integers(0, len(P)))
+ self._dot(T, P[j][0] + r.normal(0, 1.5), P[j][1] + r.normal(0, 1.5), r.uniform(0.6, 1.3), r.uniform(0.3, 0.8) * p['i'][j])
+ self._emit(T, 1.2, 0.8)
+ return E
+
+ @staticmethod
+ def _dot(buf, x, y, rad, amp):
+ H, W = buf.shape
+ k = int(rad * 3 + 2)
+ ix, iy = int(x), int(y)
+ if ix < k or iy < k or ix >= W - k or iy >= H - k: return
+ yy, xx = np.mgrid[-k:k + 1, -k:k + 1].astype(np.float32)
+ g = np.exp(-((xx - (x - ix)) ** 2 + (yy - (y - iy)) ** 2) / (2 * (rad * 0.6) ** 2)) * amp
+ sl = buf[iy - k:iy + k + 1, ix - k:ix + k + 1]
+ np.maximum(sl, g, out=sl)
+
+ def sparks(self, x, y, n=60, spread=0.7, speed=(30, 120), up=-np.pi / 2, gravity=90.0, streak=(5, 18),
+ size=(0.5, 1.2), lean=0.0, seed=None):
+ """ballistic sparks thrown from (x, y): short fading streaks with a hot head"""
+ r = self._r(seed)
+ paths = []
+ for _ in range(n):
+ a = up + lean + spread * r.normal(0, 1)
+ v = r.uniform(*speed)
+ tf = r.uniform(0.25, 1.2)
+ ts = np.linspace(max(0, tf - r.uniform(*streak) / max(v, 1)), tf, 6)
+ px = x + np.cos(a) * v * ts + r.normal(0, 3)
+ py = y + np.sin(a) * v * ts + 0.5 * gravity * ts ** 2
+ it = np.linspace(0.1, 1, 6).astype(np.float32) * r.uniform(0.5, 1.0)
+ paths.append({'pts': np.stack([px, py], 1).astype(np.float32), 'w': (r.uniform(*size), r.uniform(*size) * 1.2),
+ 'i': it, 'tip': r.uniform(0.3, 0.9)})
+ E = self._emission(paths)
+ self._emit(E, 1.1, 0.7)
+ T = np.zeros((self.H, self.W), np.float32)
+ for p in paths: self._dot(T, p['pts'][-1][0], p['pts'][-1][1], 0.9, p['tip'])
+ self._emit(T, 1.2, 0.6)
+
+ def embers(self, region, n=80, size=(0.5, 1.1), heat=(0.4, 1.0), seed=None):
+ """scattered single hot specks (sparks caught in the air)"""
+ r = self._r(seed)
+ M = self._mask(region)
+ ys, xs = np.nonzero(M > 0.02)
+ if not len(xs): return
+ T = np.zeros((self.H, self.W), np.float32)
+ idx = r.choice(len(xs), size=min(n * 4, len(xs)))
+ cnt = 0
+ for i in idx:
+ if r.random() > M[ys[i], xs[i]]: continue
+ self._dot(T, xs[i] + r.random(), ys[i] + r.random(), r.uniform(*size), r.uniform(*heat))
+ cnt += 1
+ if cnt >= n: break
+ self._emit(T, 1.0, 0.7)
+
+ def stars(self, region, n=150, size=(0.5, 1.5), bright=0.06, colour='star', warm=0.15, seed=None):
+ """a few pinpricks of light on top of the sky strokes; `bright` of them larger with a faint halo"""
+ r = self._r(seed)
+ M = self._mask(region)
+ ys, xs = np.nonzero(M > 0.05)
+ if not len(xs): return
+ S = np.zeros((self.H, self.W), np.float32); Sw = np.zeros((self.H, self.W), np.float32)
+ cnt = 0
+ for i in r.choice(len(xs), size=min(n * 5, len(xs))):
+ if r.random() > M[ys[i], xs[i]]: continue
+ big = r.random() < bright
+ rad = r.uniform(*size) * (1.7 if big else 1.0)
+ amp = r.uniform(0.45, 1.0) * (1.0 if big else 0.8)
+ self._dot(Sw if r.random() < warm else S, xs[i] + r.random(), ys[i] + r.random(), rad, amp)
+ if big: self._dot(S, xs[i] + 0.5, ys[i] + 0.5, rad * 4, 0.12)
+ cnt += 1
+ if cnt >= n: break
+ for buf, c in ((S, colour), (Sw, 'warmstar')):
+ a = np.clip(buf, 0, 1)
+ if self.pic is not None: a = a * self.pic
+ self.C += (hexc(c) - self.C) * a[..., None]
+
+ # ================================================================== water
+ def reflect(self, waterline, region, src, stretch=1.3, ripple=5.0, darken=0.7, tint='sea', mixw=0.35, thr=0.1,
+ length=(30, 80), width=(2.2, 3.4), density=1.3, alpha=0.9, seed=None, **kw):
+ """horizontal strokes coloured by the mirrored picture above the waterline (stretched, rippled, darkened),
+ laid only where that mirror is bright -- a reflection broken into strokes"""
+ r = self._r(seed)
+ wl = np.asarray(waterline, np.float32)
+ if wl.ndim == 0: wl = np.full(self.W, float(wl), np.float32)
+ M = self._mask(region)
+ rip = fbm1d(self.W, 30, 3, int(r.integers(1 << 30)))
+ rows = fbm1d(self.H, 9, 3, int(r.integers(1 << 30)))
+ depth = np.clip(self.YY - wl[None], 0, None)
+ bx0, by0, bx1, by1 = self.box
+ sx = np.clip(self.XX + ripple * rows[:, None] * (1 + depth / 60) + ripple * 0.5 * rip[None], bx0 + 2, bx1 - 3)
+ sy = np.clip(wl[None] - depth / stretch, by0 + 2, self.H - 1)
+ Mi = src[sy.astype(np.int32), sx.astype(np.int32)]
+ lum = Mi.max(-1)
+ prob = M * smoothstep(thr, thr * 3.0, lum) * (depth > 0)
+ tc = hexc(tint)
+ Mi = (Mi * darken) * (1 - mixw) + tc * mixw
+
+ def col(x, y): return _lookup(Mi, x, y)
+ return self.hatch(prob.astype(np.float32), 0.0, col, length, width, density, jitter=0.03, bend=0.01,
+ value=0.12, hue=0.03, alpha=alpha, pressure=0.96, dry=0.4, seed=int(r.integers(1 << 30)), **kw)
+
+ def glitter(self, x, y_water, y_end, w0=10.0, w1=140.0, power=1.0, density=1.6, length=(18, 70), width=(2.0, 3.4),
+ seed=None):
+ """the broken column a light on the waterline throws toward the viewer: hot and narrow near the source,
+ widening, redder and more broken further down"""
+ r = self._r(seed)
+ t = np.clip((self.YY - y_water) / max(1.0, y_end - y_water), 0, 1)
+ hw = w0 + (w1 - w0) * t
+ wob = fbm1d(self.H, 14, 3, int(r.integers(1 << 30)))[:, None] * (6 + 30 * t)
+ dx = np.abs(self.XX - x - wob) / hw
+ prob = (np.exp(-dx ** 2 * 1.6) * (1 - 0.55 * t) * (self.YY > y_water)).astype(np.float32)
+ brk = noise2d(self.H, self.W, 7, 2, int(r.integers(1 << 30)))
+ prob = prob * smoothstep(0.25, 0.6, brk + 0.25 * (1 - t))
+ R = ramp('fire')
+ level = np.clip((1 - t) ** 1.4 * np.exp(-dx ** 2 * 0.9), 0, 1)
+
+ def col(xs, ys): return ramp_at(R, 0.25 + 0.75 * _lookup(level, xs, ys)) * power
+ self.hatch(prob, 0.0, col, length, width, density, jitter=0.03, bend=0.01, value=0.15, hue=0.04,
+ pressure=0.96, dry=0.4, alpha=0.95, seed=int(r.integers(1 << 30)))
+ hot = (prob * level ** 1.5).astype(np.float32)
+
+ def col2(xs, ys): return ramp_at(R, 0.5 + 0.5 * _lookup(level, xs, ys)) * power * 0.8
+ self.hatch(hot, 0.0, col2, (10, 40), (1.6, 2.6), 0.9, jitter=0.03, bend=0.01, value=0.1, pressure=0.85,
+ dry=0.5, mode='light', seed=int(r.integers(1 << 30)))
+
+ # ================================================================== masses and figures
+ def silhouette(self, mask, ramp_='land', field=0.0, val=None, density=2.2, length=(12, 28), width=(2.2, 3.4),
+ rim=0.0, rim_from=None, rim_colour='ember', seed=None):
+ """a dark mass (rock, island, mountain) painted in strokes: a dense dark body, a sparser lighter pass, and
+ optionally a warm rim on the edge that faces a light at rim_from = (x, y)"""
+ r = self._r(seed)
+ v = self.value(0.25, 0.45, 0, self.H, 0.12, 90, seed=int(r.integers(1 << 30))) if val is None else val
+ self.hatch(mask, field, (ramp_, v), length, width, density, value=0.1, hue=0.04, pressure=0.93,
+ dry=0.3, seed=int(r.integers(1 << 30)))
+ self.hatch(mask * 0.5, field, (ramp_, np.clip(v + 0.3, 0, 1)), (8, 20), (1.6, 2.4), 0.35, value=0.12,
+ pressure=0.85, dry=0.5, seed=int(r.integers(1 << 30)))
+ if rim and rim_from is not None:
+ lx, ly = rim_from
+ dx, dy = lx - self.XX, ly - self.YY
+ dn = np.sqrt(dx * dx + dy * dy) + 1e-3
+ m = mask
+ sh = np.zeros_like(m)
+ # how much of the mask lies toward the light within a few px: an edge facing the light
+ for k in (2, 4):
+ ox = np.round(dx / dn * k).astype(np.int32); oy = np.round(dy / dn * k).astype(np.int32)
+ yy = np.clip(self.YY.astype(np.int32) + oy, 0, self.H - 1); xx = np.clip(self.XX.astype(np.int32) + ox, 0, self.W - 1)
+ sh = np.maximum(sh, m - m[yy, xx])
+ edge = np.clip(sh, 0, 1) * m
+ Lm = self.lightmap().max(-1)
+ prob = np.clip(blur(edge, 1.0) * 2.5 * np.clip(Lm * 2, 0, 1), 0, 1)
+ R = ramp('ember')
+
+ def col(x, y): return ramp_at(R, 0.3 + 0.7 * _lookup(np.clip(Lm, 0, 1), x, y)) * rim
+ self.hatch(prob, field, col, (5, 12), (1.2, 2.0), 1.2, value=0.15, pressure=0.85, dry=0.4, mode='light',
+ seed=int(r.integers(1 << 30)))
+
+ def figure(self, x, y, h=44.0, facing=1, accent='scarf', accent2=None, legs='dangle', lean=0.12, body='#0b0d19',
+ coat='#151a2c', rim_from=None, rim=0.7, hat=False, seed=None):
+ """a tiny seated person (h px from the seat to the top of the head), silhouette-dark with one small accent
+ (`accent` scarf colour, `accent2` hat colour) and a warm rim on the side facing rim_from = (x, y).
+ Returns the figure's mask."""
+ ss = 4
+ s = h / 10.0
+ pad = int(h * 1.2)
+ ox, oy = x - pad, y - pad * 1.4
+ Wl, Hl = int(pad * 2), int(pad * 2.2)
+ F = lambda px, py: ((px - ox) * ss, (py - oy) * ss)
+ def canvas(): return Image.new('L', (Wl * ss, Hl * ss), 0)
+ def caps(d, pts, w):
+ q = [F(*p) for p in pts]
+ d.line(q, fill=255, width=int(w * ss), joint='curve')
+ for p in (q[0], q[-1]):
+ d.ellipse([p[0] - w * ss / 2, p[1] - w * ss / 2, p[0] + w * ss / 2, p[1] + w * ss / 2], fill=255)
+ f = facing
+ hip = (x, y - 0.6 * s)
+ sh = (x + f * lean * 7.0 * s, y - 7.2 * s)
+ head = (sh[0] + f * 0.5 * s, sh[1] - 1.75 * s)
+ knee = (x + f * 3.9 * s, y - (2.2 * s if legs == 'knees' else 0.5 * s))
+ foot = (knee[0] + f * (0.9 * s if legs == 'knees' else 0.4 * s), y + (0.2 * s if legs == 'knees' else 3.9 * s))
+ im_b = canvas(); d = ImageDraw.Draw(im_b)
+ # torso: a tapered quad from shoulders to hips, rounded by caps
+ tw0, tw1 = 2.9 * s, 2.5 * s
+ nx_, ny_ = (hip[1] - sh[1]), -(hip[0] - sh[0]); nl = np.hypot(nx_, ny_); nx_, ny_ = nx_ / nl, ny_ / nl
+ quad = [F(sh[0] + nx_ * tw0 / 2, sh[1] + ny_ * tw0 / 2), F(hip[0] + nx_ * tw1 / 2, hip[1] + ny_ * tw1 / 2),
+ F(hip[0] - nx_ * tw1 / 2, hip[1] - ny_ * tw1 / 2), F(sh[0] - nx_ * tw0 / 2, sh[1] - ny_ * tw0 / 2)]
+ d.polygon(quad, fill=255)
+ caps(d, [sh, (sh[0] + f * 0.2 * s, sh[1] + 0.3 * s)], 2.9 * s)
+ caps(d, [hip, knee], 1.9 * s)
+ caps(d, [knee, foot], 1.4 * s)
+ caps(d, [(foot[0] - f * 0.1 * s, foot[1]), (foot[0] + f * 0.8 * s, foot[1] + 0.1 * s)], 0.9 * s)
+ # arm resting on the knee
+ caps(d, [(sh[0] + f * 0.4 * s, sh[1] + 0.6 * s), (sh[0] + f * 1.6 * s, sh[1] + 3.6 * s), (knee[0] - f * 0.4 * s, knee[1] - 0.6 * s)], 1.1 * s)
+ hr = 1.05 * s
+ hx, hy = F(*head)
+ d.ellipse([hx - hr * ss, hy - hr * ss * 1.08, hx + hr * ss, hy + hr * ss * 1.08], fill=255)
+ im_a = canvas(); da = ImageDraw.Draw(im_a) # scarf: a band round the neck and a short tail
+ nk = (sh[0] + f * 0.25 * s, sh[1] - 0.35 * s)
+ caps(da, [(nk[0] - f * 1.0 * s, nk[1] + 0.1 * s), (nk[0] + f * 1.0 * s, nk[1] - 0.05 * s)], 0.95 * s)
+ caps(da, [(nk[0] - f * 0.5 * s, nk[1] + 0.2 * s), (nk[0] - f * 0.9 * s, nk[1] + 2.0 * s)], 0.75 * s)
+ im_h = canvas(); dh = ImageDraw.Draw(im_h)
+ if hat or accent2 is not None:
+ dh.pieslice([hx - hr * ss * 1.08, hy - hr * ss * 1.25, hx + hr * ss * 1.08, hy + hr * ss * 0.75], 180, 360, fill=255)
+ down = lambda im: np.asarray(im.resize((Wl, Hl), Image.BOX), np.float32) / 255
+ mb, ma, mh = down(im_b), down(im_a) * (1.0 if accent else 0.0), down(im_h)
+ m_all = np.maximum(np.maximum(mb, ma), mh)
+ # place into the canvas
+ x0, y0 = int(round(ox)), int(round(oy))
+ sl = (slice(max(0, y0), min(self.H, y0 + Hl)), slice(max(0, x0), min(self.W, x0 + Wl)))
+ ly = slice(sl[0].start - y0, sl[0].stop - y0); lx = slice(sl[1].start - x0, sl[1].stop - x0)
+ Cs = self.C[sl]
+ r = self._r(seed)
+ tex = 1 + 0.12 * (r.random(mb[ly, lx].shape) - 0.5)
+ base = np.where((np.arange(Hl)[:, None] * 1.0 + oy < sh[1] + 2.5 * s), 1.0, 0.0)[ly, lx]
+ cbody = hexc(coat) * base[..., None] + hexc(body) * (1 - base[..., None])
+ Cs[:] = Cs * (1 - mb[ly, lx, None]) + cbody * tex[..., None] * mb[ly, lx, None]
+ if accent2 is not None:
+ Cs[:] = Cs * (1 - mh[ly, lx, None]) + hexc(accent2) * mh[ly, lx, None]
+ if accent:
+ ac = hexc(accent) * (0.92 + 0.16 * (r.random(ma[ly, lx].shape) - 0.5))[..., None]
+ Cs[:] = Cs * (1 - ma[ly, lx, None]) + ac * ma[ly, lx, None]
+ if rim_from is not None and rim:
+ lx_, ly_ = rim_from
+ ang = np.arctan2(ly_ - y, lx_ - x)
+ ddx, ddy = np.cos(ang), np.sin(ang)
+ m = m_all
+ Hm, Wm = m.shape
+ yy, xx = np.mgrid[0:Hm, 0:Wm]
+ sh1 = m[np.clip(yy + int(round(ddy * 1.3)), 0, Hm - 1), np.clip(xx + int(round(ddx * 1.3)), 0, Wm - 1)]
+ edge = np.clip(m - sh1, 0, 1) * m
+ rc = hexc('ember') * 0.9 + hexc('flame') * 0.1
+ a = np.clip(edge * rim, 0, 1)[ly, lx]
+ Cs[:] = Cs + (rc - Cs) * a[..., None] * 0.8
+ full = np.zeros((self.H, self.W), np.float32); full[sl] = m_all[ly, lx]
+ return full
+
+ # ================================================================== the mount and the pencil text
+ def mount(self, plate=16, depth=0.06, seed=None):
+ """press a plate mark round the picture: a soft groove `plate` px outside it, the plate area a touch smoother"""
+ x0, y0, x1, y1 = self.box
+ X, Y = self.XX, self.YY
+ px0, py0, px1, py1 = x0 - plate, y0 - plate, x1 + plate, y1 + plate
+ sd = np.minimum(np.minimum(X - px0, px1 - X), np.minimum(Y - py0, py1 - Y)) # signed: + inside the plate
+ ox = np.maximum(np.maximum(px0 - X, X - px1), 0); oy = np.maximum(np.maximum(py0 - Y, Y - py1), 0)
+ dist = np.where(sd >= 0, sd, np.sqrt(ox * ox + oy * oy))
+ inside = np.clip(sd + 0.5, 0, 1)
+ groove = np.exp(-(dist / 1.4) ** 2) * inside
+ # walls: the top and left walls of the recess face away from the light (dark), the bottom and right catch it
+ top_left = (((np.abs(Y - py0) < 4) & (X > px0 - 4) & (X < px1 + 4)) | ((np.abs(X - px0) < 4) & (Y > py0 - 4) & (Y < py1 + 4))).astype(np.float32)
+ lip = np.exp(-((dist - 2.2) / 1.2) ** 2) * (1 - inside)
+ shade = groove * (0.55 + 0.45 * top_left) * depth * 2.2
+ light = lip * (1 - top_left) * depth * 1.4
+ pm = 1 - (self.pic if self.pic is not None else 0)
+ smooth = inside * pm * 0.012
+ f = (1 - shade + light + smooth) * pm + (1 - pm)
+ self.C *= f[..., None]
+
+ def caption(self, text, x, y, size=26, anchor='ls', colour='pencil', weight='light', alpha=0.82, jitter=0.45,
+ tracking=0.6, seed=None):
+ """pencilled text in a thin plain face, glyph by glyph with a hair of baseline / angle wobble, the graphite
+ skipping on the paper tooth"""
+ r = self._r(seed)
+ f = _font(weight, size * 3)
+ adv = [f.getlength(ch) / 3 + tracking for ch in text]
+ total = sum(adv) - tracking
+ x0 = x - total * {'l': 0.0, 'm': 0.5, 'r': 1.0}[anchor[0]]
+ acc = np.zeros((self.H, self.W), np.float32)
+ cx = x0
+ for ch, a in zip(text, adv):
+ if ch.strip():
+ gw, gh = int(a * 3 + size * 3), int(size * 3 * 2)
+ g = Image.new('L', (gw, gh), 0)
+ ImageDraw.Draw(g).text((size * 1.5, gh * 0.7), ch, font=f, fill=255, anchor='ls')
+ g = g.rotate(r.normal(0, jitter * 1.6), resample=Image.BICUBIC, center=(size * 1.5, gh * 0.7))
+ g = g.resize((gw // 3, gh // 3), Image.BOX)
+ gx = int(round(cx - size * 0.5 + r.normal(0, jitter * 0.3))); gy = int(round(y - gh / 3 * 0.7 + r.normal(0, jitter * 0.5)))
+ ga = np.asarray(g, np.float32) / 255 * r.uniform(0.85, 1.0)
+ ys_, xs_ = slice(max(0, gy), min(self.H, gy + ga.shape[0])), slice(max(0, gx), min(self.W, gx + ga.shape[1]))
+ acc[ys_, xs_] = np.maximum(acc[ys_, xs_], ga[ys_.start - gy:ys_.stop - gy, xs_.start - gx:xs_.stop - gx])
+ cx += a
+ tooth = np.clip((0.9 - self.T) * 5 + 0.55, 0, 1)
+ A = np.clip(acc * 1.15, 0, 1) * tooth * alpha
+ self.C += (hexc(colour) - self.C) * A[..., None]
+
+ # ================================================================== finish
+ def bloom(self, amount=1.0):
+ """a restrained bloom round the brightest lights (applied in render)"""
+ self.bloom_amt = float(amount)
+
+ def grain(self, amount=1.0):
+ """fine pastel grain over the picture and the paper (applied in render)"""
+ self.grain_amt = float(amount)
+
+ def render(self):
+ out = self.C
+ if self.bloom_amt:
+ lum = out.max(-1)
+ if self.pic is not None: lum = lum * self.pic # only the picture's own lights, not the margin
+ b = blur(np.clip(lum - 0.62, 0, 1), 9.0) * 0.8 + blur(np.clip(lum - 0.5, 0, 1), 26.0) * 0.5
+ add = b[..., None] * hexc('lava') * self.bloom_amt
+ if self.pic is not None: add *= self.pic[..., None]
+ out = out + add * (1 - out)
+ if self.grain_amt:
+ if not hasattr(self, '_grain'):
+ r = np.random.default_rng(self.seed + 7)
+ g = r.normal(0, 1, (self.H, self.W)).astype(np.float32)
+ g = 0.65 * g + 0.35 * blur(g, 0.8) * 2.0
+ self._grain = (0.016 * g).astype(np.float32)
+ out = out * (1 + self.grain_amt * self._grain[..., None])
+ return np.clip(out, 0, 1)
+
+ def composite(self):
+ return Image.fromarray((self.render() * 255 + 0.5).astype(np.uint8))
+
+ def stage(self, name):
+ if not self.keep_stages: return
+ 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