Claude paints with code: a Claude Code skill for procedural illustration in 83 styles, from ink wash (水墨), watercolour and ukiyo-e to stained glass, Roman mosaic, Art Deco, shadow puppets, pastel UI, sketchbook doodles, spot illustrations, grainy picture books, dreamy hills, sunlit greenery. No image model: numpy + Pillow on a CPU, draw-on GIFs.
Python agent-skillsanimechinese-paintingclaudeclaude-codeclaude-skillscolored-pencilcreative-codingcross-stitcheditorial-illustrationgenerative-artink-wash-paintingoil-paintingpaper-collagepixel-artprocedural-generationrisographshanshuiukiyo-ewatercolor
Add pastel UI style (61 total): product-film interface frames on flat pastel fields
clovericc10c96c1923a
diff --git a/README.md b/README.mdindex 6abacc1..31018de 100644--- a/README.md+++ b/README.md@@ -1,54 +1,54 @@# Claude Drawing · Claude 绘图-**Claude paints with code — no image model.** Sixty 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 and a synthwave sunset.-**不用生图模型,Claude 用代码一笔一笔作画。** 六十种画风,从水墨、油画到黏土、蓝晒、彩色玻璃花窗、罗马马赛克、代尔夫特蓝瓷砖、赛博朋克、光线追踪的小球海、低多边形 3D、热成像、X 光片、VHS 录像带和 Synthwave 落日。+**Claude paints with code — no image model.** Sixty-one 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 and a pastel product-film UI.+**不用生图模型,Claude 用代码一笔一笔作画。** 六十一种画风,从水墨、油画到黏土、蓝晒、彩色玻璃花窗、罗马马赛克、代尔夫特蓝瓷砖、赛博朋克、光线追踪的小球海、低多边形 3D、热成像、X 光片、VHS 录像带、Synthwave 落日和产品发布片式的粉彩界面。[English](#english) · [中文](#中文)<p align="center"><img src="examples/drawing_bawansiqian.gif" width="100%"><br><sub><b>Ink wash · 水墨</b> — every style below is drawn stage by stage like this (the storybook one is a real character animation) · 下面每种画风都是这样一步步画出来的(绘本角色动画是一段真正的角色动画)</sub></p>-| Ink wash · 水墨(月印万川) | Watercolour · 水彩 | Paper collage · 剪纸拼贴 |+| Watercolour · 水彩 | Paper collage · 剪纸拼贴 | Coloured pencil · 韩国彩铅 ||---|---|---|-|  |  |  |-| **Coloured pencil · 韩国彩铅** | **Anime · 日本动漫** | **Editorial · 编辑风手绘** |-|  |  |  |-| **Impasto oil · 油画厚涂** | **Ukiyo-e · 浮世绘木版画** | **Pixel art · 像素风** |-|  |  |  |-| **Stop-motion clay · 黏土定格** | **Cyanotype · 蓝晒** | **Cross-stitch · 十字绣** |-|  |  |  |-| **Retro panel · 复古仪器面板** | **Sticker collage × receipt · 贴纸拼贴 · 小票** | **Lab notebook × stickers · 实验笔记本 · 贴纸** |-|  |  |  |-| **Chalkboard · 黑板板书** | **Cyberpunk · 赛博朋克** | **Hand-drawn cartoon · 卡通手绘** |-|  |  |  |-| **Continuous line art · 单线画** | **Soft 3D · 柔光 3D** | **Shape morph · 形变动画** |-|  |  |  |-| **Newspaper collage · 报刊拼贴** | **Aurora glass · 弥散玻璃** | **Bauhaus geometric · 包豪斯几何** |-|  |  |  |-| **Retro synthwave · 复古 Synthwave** | **Isometric 2.5D · 等轴 2.5D** | **Perler beads · 拼豆** |-|  |  |  |-| **Petroglyph · 岩画** | **Egyptian tomb painting · 古埃及墓室壁画** | **Roman mosaic · 罗马马赛克** |-|  |  |  |-| **Stained glass · 彩色玻璃花窗** | **Illuminated manuscript · 泥金手抄本** | **Leonardo codex · 达·芬奇手稿** |-|  |  |  |-| **Silhouette · 剪影** | **Letterpress poster · 凸版印刷海报** | **Soviet constructivism · 苏联构成主义** |-|  |  |  |-| **Art Deco · 装饰艺术** | **Golden-age comic · 黄金时代漫画** | **Pop silkscreen · 波普丝网** |-|  |  |  |-| **ASCII art (line printer) · ASCII 字符画** | **Low poly · 低多边形** | **Stencil graffiti · 喷漆模板涂鸦** |-|  |  |  |-| **Embroidered patches · 刺绣徽章** | **Blueprint · 蓝图工程图** | **Children's crayon · 儿童蜡笔画** |-|  |  |  |-| **Green-screen CRT · 绿屏终端** | **Thermal camera · 热成像** | **Delft tiles · 代尔夫特蓝瓷砖** |-|  |  |  |-| **Cave painting · 洞穴壁画** | **1-bit paint program · 1-bit 早期画图软件** | **Greek black-figure vase · 古希腊黑绘陶瓶** |-|  |  |  |-| **Graphite pencil · 铅笔素描** | **X-ray · X 光片** | **1930s rubber hose · 1930 年代黑白橡皮管动画** |-|  |  |  |-| **Linocut · 黑白麻胶版画** | **VHS home video · VHS 家庭录像** | **Flat vector · 扁平矢量** |-|  |  |  |-| **Storybook animation · 绘本角色动画** | **Ballpoint doodle · 圆珠笔涂鸦** | **Overlay sheets · 描图纸叠层** |-|  |  |  |+|  |  |  |+| **Anime · 日本动漫** | **Editorial · 编辑风手绘** | **Impasto oil · 油画厚涂** |+|  |  |  |+| **Ukiyo-e · 浮世绘木版画** | **Pixel art · 像素风** | **Stop-motion clay · 黏土定格** |+|  |  |  |+| **Cyanotype · 蓝晒** | **Cross-stitch · 十字绣** | **Retro panel · 复古仪器面板** |+|  |  |  |+| **Sticker collage × receipt · 贴纸拼贴 · 小票** | **Lab notebook × stickers · 实验笔记本 · 贴纸** | **Chalkboard · 黑板板书** |+|  |  |  |+| **Cyberpunk · 赛博朋克** | **Hand-drawn cartoon · 卡通手绘** | **Continuous line art · 单线画** |+|  |  |  |+| **Soft 3D · 柔光 3D** | **Shape morph · 形变动画** | **Newspaper collage · 报刊拼贴** |+|  |  |  |+| **Aurora glass · 弥散玻璃** | **Bauhaus geometric · 包豪斯几何** | **Retro synthwave · 复古 Synthwave** |+|  |  |  |+| **Isometric 2.5D · 等轴 2.5D** | **Perler beads · 拼豆** | **Petroglyph · 岩画** |+|  |  |  |+| **Egyptian tomb painting · 古埃及墓室壁画** | **Roman mosaic · 罗马马赛克** | **Stained glass · 彩色玻璃花窗** |+|  |  |  |+| **Illuminated manuscript · 泥金手抄本** | **Leonardo codex · 达·芬奇手稿** | **Silhouette · 剪影** |+|  |  |  |+| **Letterpress poster · 凸版印刷海报** | **Soviet constructivism · 苏联构成主义** | **Art Deco · 装饰艺术** |+|  |  |  |+| **Golden-age comic · 黄金时代漫画** | **Pop silkscreen · 波普丝网** | **ASCII art (line printer) · ASCII 字符画** |+|  |  |  |+| **Low poly · 低多边形** | **Stencil graffiti · 喷漆模板涂鸦** | **Embroidered patches · 刺绣徽章** |+|  |  |  |+| **Blueprint · 蓝图工程图** | **Children's crayon · 儿童蜡笔画** | **Green-screen CRT · 绿屏终端** |+|  |  |  |+| **Thermal camera · 热成像** | **Delft tiles · 代尔夫特蓝瓷砖** | **Cave painting · 洞穴壁画** |+|  |  |  |+| **1-bit paint program · 1-bit 早期画图软件** | **Greek black-figure vase · 古希腊黑绘陶瓶** | **Graphite pencil · 铅笔素描** |+|  |  |  |+| **X-ray · X 光片** | **1930s rubber hose · 1930 年代黑白橡皮管动画** | **Linocut · 黑白麻胶版画** |+|  |  |  |+| **VHS home video · VHS 家庭录像** | **Flat vector · 扁平矢量** | **Storybook animation · 绘本角色动画** |+|  |  |  |+| **Ballpoint doodle · 圆珠笔涂鸦** | **Overlay sheets · 描图纸叠层** | **Pastel UI · 粉彩界面** |+|  |  |  |### Gallery · 画廊@@ -56,68 +56,68 @@|---|---|| **八万四千法门** · *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> | **水彩底纹** · *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%"> |--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. 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> | **热气球小镇** · *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%"> |++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. 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.---@@ -125,7 +125,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 styles:+A [Claude Code](https://claude.com/claude-code) skill and a small painting library with sixty-one styles:| Style | Module | What makes it read as the real medium ||---|---|---|@@ -189,6 +189,7 @@ A [Claude Code](https://claude.com/claude-code) skill and a small painting libra| **Storybook animation** | `lib/storybook.py` · `Storybook` | a real animation, not a draw-on: every piece of scenery is pre-painted once with a reveal map (the moment the pen or brush reaches each pixel), so ink lines draw along their length, washes spread with a darker wet front and props pop in with an overshoot — and the hills, flowers and banks are drawn exactly as the character passes (`follow`). The character is rendered every frame from implicit shapes in its own frame, squashed and stretched with a volume-preserving affine along its motion, rested exactly on the ground, lit by one fixed light so the highlight stays put while it rolls; poses come from eased, sprung and ballistic choreography plus impact lines, dust puffs, speed lines and ripples. The closing line writes itself in stroke order (skeleton walk), and the same scene renders a journey poster with the key poses multiply-exposed on a pencil motion arc || **Ballpoint doodle** | `lib/ballpoint.py` · `Ballpoint` | ballpoint ink is an oil paste a rolling ball lays down, kept as optical density, so a line drawn twice, a crossing or a blob goes darker and more saturated (blue deepens to blue-violet, never flat black); every stroke starts dry and thin, drifts in pressure and width, skips a few pixels now and then, drops gloops where the pen stops and at sharp turns, and flicks off in a little hook; outlines are gone over twice, slightly off; every stroke presses a groove into the copy paper that catches the raking light, and the sheet carries the blind indentations of a shopping list written on the page above; coloured pencil is wax on the paper tooth, hatched in quick slanted patches that run past the lines, light on big areas and pressed hard on small ones; the handwriting is the skeleton of a thin hand font re-drawn as pen strokes, each letter resized, tilted and lifted off a wandering baseline, with a word scribbled out and written again || **Overlay sheets (tracing paper on a light box)** | `lib/overlay.py` · `Overlay` | the picture is a product of transmittances: a warm light box glows through a base sheet printed in black line and grey tints, then through translucent sheets that each carry ONE ink, laid down on registration crosses; an ink's coverage is a screen tint (or a double hit above 100 %), and inks on different sheets multiply, so blue over yellow turns green, magenta over yellow red and magenta over blue violet; every sheet has its own paper tint, the cloudy fibre formation you only see against the light, stray fibres, a cut edge that reads as a thin dark line, punched holes that drop onto a steel peg bar; a lifted sheet is a little larger, throws a wide soft shadow you can see through it and blurs everything under it like the diffuser it is, then lands crisp with a thin contact shadow; curled corners, crepe drafting tape with torn ends, a clear film with a gloss sheen; the town under it is cut by recursive street splits into blocks with a ring of buildings and party walls, water-lined round the coast |+| **Pastel UI (product-film interface)** | `lib/pastelui.py` · `PastelUI` | one frame of a modern product film: a flat pastel field (blue, pink, yellow, lilac, mint, peach) with one big pool of soft light and a few white bokeh discs; macOS window cards with a frosted rim, a white body, the red / yellow / green lights and split panes, side panels, a dot pill and a step strip, a heavy headline with a translucent marker under the key words, status chips, round check / cross badges, text highlights, an inline reference chip and a callout tag; every shape is a signed-distance field with analytic 1 px anti-aliasing, and shadows follow CSS box-shadow (offset, blur, spread; a wide one tinted with the field colour plus a tight neutral one), so cards float without a grey halo; everything is drawn into named layers with a pose (offset, scale, opacity, left-to-right reveal) and a depth, so the same drawing pops a window up, writes a line, pops a badge or lets a companion rise from behind a card; a magnifier that enlarges the real pixels under it; a circular colour wipe between sections; three flat companions peek over the card edges — a starburst in a cream circle, a violet cloud with a >_ prompt, an orange pixel critter |Ask Claude to *"draw it yourself"*, *"paint this with code"*, or *"claude绘图"*, and name a style if you like. Claude then:@@ -302,6 +303,7 @@ Every style has a complete example: `python3 examples/<name>.py out.png --stages- **Storybook animation**: the story is the acting, so choreograph first — anticipation before every big move (squash and lean away), stretch along the velocity, squash on every landing with impact lines and dust, a spring settle afterwards — and let the world be drawn by the character (`follow=` with a lead of 150–350 px, `pre=` for what is left of the start). Give `soft` in pixels, not as a fraction of a 2000-px layer, or the paint front turns into fog. Keep the camera still: only what moves is re-encoded, so 151 frames stay near 0.6 MB. On the poster, pick poses that sit apart along the path, draw the end state itself instead of a ghost on top of it, and hide the props' final positions.- **Ballpoint doodle**: draw what sits in front first (the pieces), then let every later line stop at it with `clip` — the snakes, the ladders, the grid and the pencil all go round the pieces, the way a pen lifts at something already drawn. Keep big pencil areas light (pressure ~0.4) and small ones saturated (0.7–0.9), and let the hatching run a few px past the lines. Use red only for "this move" (hops, ring, arrow, the conclusion) and blue/black for everything else. Put every label inside an empty square or the margin — text split by a grid line or crowded by a sweat drop reads as a mistake. Keep the fold and the blind indentations faint; they should be found, not seen.- **Overlay sheets**: think in light, not paint — every sheet only takes light away, so tints are coverage and overlaps come out of the multiply on their own. Draw every separation in the same laid-down canvas coordinates and print the same registration crosses on each, so they register by construction. Keep tracing paper clear (transmittance ~0.98, formation ~2 %), or three sheets turn the town grey. Reversed-out numbers show whatever is underneath, so keep stop markers off dark landmarks, and give a tram and a walking route their own side of the same road. Put tape and curled corners where there is nothing printed. Lift a sheet only a little (σ ~3 px of blur, a 20–35 px offset): it should read as hovering, not as a second picture.+- **Pastel UI**: one screen, one idea — a headline, one main window, one side panel and a status, with few words set large. Keep the field flat and the cards solid white; colour lives in the accents (the step strip, chips, badges, markers), and green is reserved for a pass, so use a blue field when there are checks and crosses. Put companions on a lower layer than the card they peek over, so the card itself hides the rest of them. Give a magnifier room: centre it on one thing with its labels outside the rim (a lens over a narrow column cuts its label and temperature in half). Draw each state of a thing as its own layer and switch them; for the draw-on GIF, give anything that moves a few in-between poses instead of a cross-fade.### Roadmap@@ -313,7 +315,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,加上一个小巧的绘图库,内置六十一种画风:| 画风 | 模块 | 为什么看起来像真的 ||---|---|---|@@ -377,6 +379,7 @@ Every style has a complete example: `python3 examples/<name>.py out.png --stages| **绘本角色动画** | `lib/storybook.py` · `Storybook` | 是真动画,不是阶段叠化:每样风景都预画一次,并记一张「揭示图」(笔或刷子在第几时刻碰到每个像素),所以墨线沿着笔路画出来、水彩带着一道略深的湿边晕开、小物件回弹着冒出来;山坡、小花、河岸正好在角色经过时画上(`follow`)。角色每帧用隐式曲面现画,沿运动方向做保体积的挤压拉伸,最低点正好贴地,光照固定在世界里(滚动时高光不跟着转);动作由缓动、弹簧和抛物线编排,配冲击线、白色尘团、速度线和水波。结尾一行字按笔顺一笔笔写出来(走骨架),同一个场景还能出一张旅程总图:关键姿态多次曝光在铅笔运动弧上 || **圆珠笔涂鸦** | `lib/ballpoint.py` · `Ballpoint` | 圆珠笔墨是滚珠压上去的油性墨膏,按光密度叠加:描两遍、交叉、墨团都会更深更饱和(蓝色叠成深蓝紫,不会是死黑);每一笔起笔干而细,压力和线宽一路漂移,偶尔断墨几像素,停笔和急转弯处掉墨团,抬笔甩出小钩;轮廓描两遍、略微错开;每一笔都在复印纸上压出凹槽,侧光下看得见,纸上还留着上一页购物单的无墨压痕;彩铅是挂在纸纹上的蜡,一块块斜向快速排线、出界,大面积轻、小面积重;手写字是细手写字体的骨架重新用笔描出来,每个字母各自缩放、倾斜、上下浮动,还有一个词划掉重写 || **描图纸叠层** | `lib/overlay.py` · `Overlay` | 画面就是一路透过率相乘:暖白灯箱从下面照上来,先透过一张黑线灰调的底图,再透过一张张只印一种油墨的半透明叠片,叠片对着套准十字放下;油墨按网点覆盖率算(超过 100% 是叠印加深),不同叠片的油墨正片叠底,蓝叠黄成绿、品红叠黄成红、品红叠蓝成紫;每张纸有自己的纸色、只有背光才看得见的云状纤维和零星纤维丝、一道细暗的裁切边、落在钢定位钉上的打孔;抬起的纸略放大、投一片透过纸也看得见的宽软阴影,并像漫射片一样把下面的东西都模糊掉,放下后才清晰,只剩一道贴边细影;卷角、撕口的皱纹绘图胶带、带光泽的透明胶片;底图里的小城用递归切分的街道切出街区,沿街一圈房屋和分户墙,海岸外一圈圈水线 |+| **粉彩界面** | `lib/pastelui.py` · `PastelUI` | 产品发布片里的一帧界面:整片纯色粉彩底(蓝 / 粉 / 黄 / 淡紫 / 薄荷 / 桃)加一大片柔光和几颗白色光斑;macOS 窗口卡片(磨砂外框、白色窗体、红黄绿三点、分栏)、侧面板、带圆点的小胶囊和步骤条、粗黑大标题压一条半透明色条、状态标签、圆形 ✓ / ✗ 徽章、文字高亮、嵌在正文里的引用标签和带尖角的小标签;所有形状都是有符号距离场、1 px 解析抗锯齿,阴影按 CSS box-shadow 算(偏移、模糊、扩展;一层染着底色的宽阴影加一层中性的近阴影),卡片浮起来却没有灰边;一切画进带姿态(位移、缩放、不透明度、从左往右揭开)和前后层次的图层,同一套画面既能弹出窗口、逐行写字、弹出徽章,也能让小图标从卡片后面探头;放大镜放大的是它下面真实的像素;节与节之间圆形擦除换底色;三个扁平小图标从卡片边探头——奶油色圆里的橙色星芒、紫色云朵里的 >_、橙色像素小怪 |对 Claude 说「claude绘图」「你自己画」「用代码画」,也可以指定画风。它会:1. **先定构图**:层次、焦点、留白,而且画面要图解内容本身;@@ -466,6 +469,7 @@ python3 examples/flatvector_night_camp.py out.png # 扁平矢python3 examples/storybook_acorn.py out.jpg --gif out.gif # 绘本角色动画:小橡果的秋天python3 examples/ballpoint_board_game.py out.png # 圆珠笔涂鸦:蛇梯棋大冒险python3 examples/overlay_city_map.py out.jpg --stages stages/ # 描图纸叠层:海港步行图+python3 examples/pastelui_packing.py out.jpg --stages stages/ # 粉彩界面:出发前,再查一遍行李```### 作画要点(Claude 交图前逐条自查)@@ -528,6 +532,7 @@ python3 examples/overlay_city_map.py out.jpg --stages stages/ # 描图纸- **绘本角色动画**:故事靠表演,先编排动作——每个大动作前都要有预备(压扁、往反方向后仰),沿速度方向拉伸,每次落地压扁并配冲击线和尘团,之后用弹簧回稳——再让世界跟着角色画出来(`follow=` 提前量 150–350 px,起点左边那段用 `pre=`)。柔边按像素给,别写成 2000 px 宽层的比例,否则湿边变成一团雾。镜头别动:只有动的地方重新编码,151 帧才能压在 0.6 MB 左右。总图里选沿路分得开的姿态,终点画最后一帧本身,别再叠残影,道具终点位置也藏掉。- **圆珠笔涂鸦**:先画在前面的东西(棋子),后画的线都用 `clip` 在它前面停住——蛇、梯子、格线、彩铅都绕开棋子,就像笔走到已经画好的东西前会抬起来。大面积彩铅轻压(约 0.4),小面积压重(0.7–0.9),排线出界几像素。红笔只留给「这一步」(跳格、圈、箭头、结论),其余用蓝、黑。每个标注都放进空格子或页边:被格线劈开、被汗滴挤住的字看起来像画错了。折痕和无墨压痕要淡,是「找得到」而不是「一眼看见」。- **描图纸叠层**:按「光」想,不按「颜料」想——每张纸只会挡光,所以浅色是网点覆盖率,叠色交给正片叠底自己算。所有分色片都用纸放下时的同一套画布坐标画,每张都印同一组套准十字,天然对得上。描图纸要透(透过率约 0.98、云纹约 2%),否则三张叠下来整座城发灰。反白数字露出的是下面那一层,所以站点别压在深色地标上;电车和步行路线在同一条路上要各走一边。胶带和卷角放在没印东西的地方。纸只抬一点(模糊 σ 约 3 px、偏 20–35 px),看上去是「悬着」,不是又一张画。+- **粉彩界面**:一屏只讲一件事——一个大标题、一个主窗口、一个侧面板、一个状态,字少而大。底色平、卡片实心白,颜色只放在强调处(步骤条、标签、徽章、色条);绿色只留给「通过」,所以有 ✓ / ✗ 的画面用蓝底。小图标放在它探头的那张卡片下一层,让卡片自己挡住其余部分。放大镜要有地方放:对准一样东西,标签放在镜框外(镜片压在窄窄一列上会把日期和温度切成两半)。同一样东西的不同状态各画一层再切换;做动图时,会动的东西给几个中间姿态,不要叠化。### 计划diff --git a/SKILL.md b/SKILL.mdindex 931f399..0b258fe 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)、扁平矢量(分层几何色块、七色、层间投影)、绘本角色动画(小角色挤压拉伸的真动画)、圆珠笔涂鸦(蓝红圆珠笔线稿、墨团、彩铅、页边涂鸦)、描图纸叠层(灯箱上的黑线底图 + 一张张单色描图纸叠片:正片叠底、套准十字、定位钉、绘图胶带)。用户说「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、家庭录像、录像带、扁平插画、扁平风、矢量插画、绘本动画、角色动画、挤压拉伸、圆珠笔、圆珠笔涂鸦、原子笔、页边涂鸦、课本涂鸦、手画棋盘、描图纸、硫酸纸、叠片、叠层、分色片、灯箱、拷贝台、透光台、套准、定位钉),或 "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 without an image model" 时使用;也用于需要逐步画出(draw-on)动画的插画。单独说「剪纸」指剪纸拼贴、「刺绣」指十字绣、「丝网印刷 / screen print」指包豪斯几何;「打马赛克」是打码,不是马赛克画风;单说「蓝图」指蓝图工程图,「蓝晒 / 晒图」仍指蓝晒;「铅笔 / 素描」指铅笔素描,「彩铅」指韩国彩铅;「像素」仍指像素风,「1-bit / 黑白画图软件」指 1-bit 早期画图软件;「霓虹」仍指赛博朋克;「喷漆 / 街头涂鸦」仍指喷漆模板涂鸦,「圆珠笔 / 随手涂鸦 / 页边涂鸦」指圆珠笔涂鸦;「描图纸 / 硫酸纸 / 叠片 / 灯箱」指描图纸叠层(蓝图工程图那张描图布是晒成蓝图的,不是叠片)。+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 窗口卡片、胶囊与粗黑标题色条、状态标签与 ✓ / ✗ 徽章、放大镜、从卡片边探头的扁平小图标)。用户说「claude绘图」「用代码画」「你自己画」「不用生图模型画」「程序化绘画」,或点名以上任一画风(含黏土、彩泥、定格动画、蓝晒、晒图、十字绣、刺绣、复古面板、老式收音机、贴纸、小票、收据、手帐拼贴、实验笔记本、方格本、荧光笔、便利贴、黑板、板书、粉笔、赛博朋克、霓虹、雨夜街道、卡通、手绘卡通、逐帧手绘、抖线、等轴、2.5D、微缩模型、单线画、一笔画、线条动画、柔光 3D、3D 渲染、C4D 风、软糖字、小球海、形变、变形动画、报刊拼贴、剪报、达达、勒索信字、网点印刷、弥散渐变、玻璃拟态、毛玻璃、包豪斯、几何构成、丝网印刷、Synthwave、蒸汽波、合成器浪潮、80 年代复古、拼豆、拼拼豆、熔珠、熨豆、豆豆画、钉板、烫豆、岩画、岩刻、凿刻、石刻、沙漠漆、史前壁刻、大角羊、古埃及、埃及壁画、墓室壁画、法老时代、象形文字、尼罗河、底比斯、罗马马赛克、马赛克镶嵌、镶嵌画、石子拼画、地砖画、古罗马地板、彩色玻璃、彩绘玻璃、花窗、玻璃花窗、教堂花窗、哥特花窗、铅条玻璃、泥金手抄本、手抄本、彩饰手抄本、中世纪手稿、羊皮纸、哥特体、花体首字母、泥金、贴金、星盘、达芬奇、达·芬奇、达芬奇手稿、手稿风、文艺复兴手稿、发明手稿、镜像字、镜像书写、扑翼机、红粉笔、钢笔排线、机械草图、分解图、剪影、剪影肖像、侧影、侧面像、黑纸剪影、剪影小像、椭圆金框、乔治时代肖像、摄政时期肖像、凸版印刷、活版印刷、木活字、铅字海报、马戏团海报、复古海报、老海报、19 世纪海报、双色套印、错版、套色错位、木刻插图、构成主义、苏联海报、苏联构成主义、俄国先锋派、罗德琴科风、红黑海报、照片蒙太奇、照片拼贴海报、西里尔字、装饰艺术、装饰风、流线型、流线型海报、1930 年代海报、旅行海报、铁路海报、火车海报、喷枪画、喷笔画、阶梯高楼、射线背景、盖茨比风、黄金时代漫画、老漫画、复古漫画、美漫封面、漫画封面、Ben-Day 网点、本戴点、网点上色、四色印刷、四色错版、新闻纸、对白框、拟声字、1940 年代漫画、波普、波普艺术、波普丝网、沃霍尔风、丝网版画头像、撞色头像、多格重复头像、六宫格撞色头像、ASCII、字符画、字符艺术、文字画、行式打印机、绿条纸、连续打印纸、针孔打印纸、老电脑打印、叠打、低多边形、低面数、低模、多边形风、千禧年 3D、90 年代 3D、复古 3D 游戏、老游戏截图、PS1 风、N64 风、平面着色、线框、游戏 HUD、飞行游戏、穿环、喷漆、模板涂鸦、镂空模板、喷漆模板、模板喷绘、街头涂鸦、街头艺术、墙绘、滴漆、班克西风格、刺绣徽章、徽章、布章、臂章、刺绣贴、绣标、锁边、牛仔外套徽章、户外徽章、营地徽章、弧形条章、蓝图、工程图、施工图、蜡笔画、儿童画、绿屏终端、CRT、显像管、热成像、热像仪、温度图、代尔夫特、荷兰蓝瓷砖、洞穴壁画、史前壁画、赭石、1-bit、黑白画图软件、MacPaint 风、黑绘、古希腊陶瓶、希腊瓶画、铅笔素描、素描、铅笔画、X 光、X 光片、安检图像、橡皮管动画、黑白卡通、老动画、麻胶版画、黑白版画、藏书票、VHS、家庭录像、录像带、扁平插画、扁平风、矢量插画、绘本动画、角色动画、挤压拉伸、圆珠笔、圆珠笔涂鸦、原子笔、页边涂鸦、课本涂鸦、手画棋盘、描图纸、硫酸纸、叠片、叠层、分色片、灯箱、拷贝台、透光台、套准、定位钉、粉彩界面、粉彩 UI、Dot 风、Dot 那种风格、产品发布会界面、发布会质感、窗口卡片、macOS 窗口、界面卡片、讲解片界面页、小图标探头),或 "draw it yourself", "paint with code", "procedural painting", "watercolor / collage / colored pencil / anime / editorial / impasto oil / ukiyo-e / pixel art / clay / claymation / cyanotype / sun print / cross-stitch / embroidery / retro instrument panel / vintage radio / sticker collage / receipt / lab notebook / graph paper / chalkboard / blackboard / cyberpunk / neon city / cartoon / hand-drawn animation / isometric / 2.5D / continuous line / one-line drawing / soft 3D / 3D render / puffy letters / ball pit / shape morph / morphing / newspaper collage / Dada / ransom note / halftone / glassmorphism / aurora gradient / Bauhaus / geometric poster / screen print / synthwave / retrowave / outrun / perler beads / hama beads / artkal / fuse beads / melty beads / pegboard beads / petroglyph / rock art / rock carving / desert varnish / Egyptian tomb painting / ancient Egypt / hieroglyphs / Theban tomb / Roman mosaic / floor mosaic / tesserae / opus vermiculatum / Pompeii mosaic / stained glass / leaded glass / church window / Gothic window / grisaille / illuminated manuscript / medieval manuscript / book of hours / gold leaf / illuminated initial / blackletter / vellum / astrolabe / da Vinci notebook / Leonardo codex / Renaissance sketchbook / mirror writing / iron-gall ink / red chalk / sanguine / ornithopter / exploded view / inventor's sketch / silhouette / silhouette portrait / cut-paper profile / shade portrait / Georgian portrait / Regency portrait / oval gilt frame / letterpress / wood type / playbill / circus poster / Victorian poster / two-colour misregistration / woodcut poster / constructivism / constructivist poster / Soviet avant-garde / Russian avant-garde / Rodchenko style / photomontage poster / art deco / streamline moderne / 1930s travel poster / railway poster / airbrush poster / sunburst rays / Gatsby style / golden age comic / vintage comic book / comic cover / Ben-Day dots / four-color printing / newsprint / speech balloon / pulp cover / pop art / Warhol-style / pop silkscreen / silkscreen portrait / repeated pop portrait grid / ASCII art / text art / typewriter art / line printer / greenbar / fanfold paper / tractor feed / overstrike / printer plot / low poly / low-poly / retro 3D / 90s 3D game / PS1 style / N64 style / software rasterizer / flat shading / affine texture mapping / vertex fog / game HUD / stencil / stencil graffiti / spray paint stencil / street art / drips and overspray / Banksy-style stencil / embroidered patch / embroidery patch / iron-on patch / sew-on patch / merit badge / camp badge / merrow border / rocker patch / denim jacket patches / blueprint / technical drawing / crayon / kid's drawing / CRT terminal / green screen / thermal camera / thermal imaging / Delft tiles / Delft blue / cave painting / ochre / Lascaux-style / 1-bit / MacPaint-style / black-figure / Greek vase / pencil drawing / graphite / X-ray / baggage scanner / rubber hose / 1930s cartoon / linocut / lino print / VHS / home video / flat vector / flat illustration / storybook animation / squash and stretch / ballpoint / biro / ballpoint doodle / margin doodles / hand-drawn board game / overlay sheets / tracing-paper overlays / light box / colour separations / registration marks / acetate overlay / pastel UI / Dot-style product film / launch-film interface / macOS window cards without an image model" 时使用;也用于需要逐步画出(draw-on)动画的插画。单独说「剪纸」指剪纸拼贴、「刺绣」指十字绣、「丝网印刷 / screen print」指包豪斯几何;「打马赛克」是打码,不是马赛克画风;单说「蓝图」指蓝图工程图,「蓝晒 / 晒图」仍指蓝晒;「铅笔 / 素描」指铅笔素描,「彩铅」指韩国彩铅;「像素」仍指像素风,「1-bit / 黑白画图软件」指 1-bit 早期画图软件;「霓虹」仍指赛博朋克;「喷漆 / 街头涂鸦」仍指喷漆模板涂鸦,「圆珠笔 / 随手涂鸦 / 页边涂鸦」指圆珠笔涂鸦;「描图纸 / 硫酸纸 / 叠片 / 灯箱」指描图纸叠层(蓝图工程图那张描图布是晒成蓝图的,不是叠片);「Dot 风 / 粉彩界面 / 窗口卡片 / 发布会界面」指粉彩界面(纯色底 + 白色实心窗口卡片),要磨砂玻璃和弥散渐变仍用弥散玻璃。---# Claude 绘图@@ -74,6 +74,7 @@ description: Claude 绘图 / Claude Drawing —— 不借助任何生图模型| 绘本角色动画 | `lib/storybook.py` · `Storybook` | `examples/storybook_acorn.py` 小橡果的秋天(真动画 + 旅程总图:米色纸上,枝头打盹的小橡果被晃醒、拉长掉下、落地压扁再弹起,追着一片红橡叶滚下山坡,山坡、小花、远山随它经过一笔笔画出来;跳上漂在小河上的橡叶,撞岸后空翻上岸,钻进土里发芽长成一棵还戴着橡果帽的小橡树;最后「hello, little oak」按笔顺写出来,彩纸屑飞起。总图把六个关键姿态多次曝光在铅笔运动弧上;加 `--gif out.gif` 出 15 fps 的真动画) | 约 1 秒(总图)/ 约 3 秒(151 帧动图) || 圆珠笔涂鸦 | `lib/ballpoint.py` · `Ballpoint` | `examples/ballpoint_board_game.py` 蛇梯棋大冒险 · Snakes & Ladders, Round 7(午休时在复印纸上用蓝、红、黑三支圆珠笔画的 8×8 蛇梯棋,彩铅一行行涂成彩虹色格子;一局正在进行:骰子刚从页边弹过来、掷出 4,蜗牛从 10 跳四格到 14(红笔虚线弧标出 1-2-3-4),正顺着长梯子爬到 38(红圈、虚线箭头、+24!),小云从 47 被绿蛇滑下去,晕乎乎地喊 nooo~,骰子怪在 51 捂着脸;页边是彩旗、太阳、井字棋、纸飞机、星星串、山坡小房子、花盆,吐槽小纸条「who drew this snake so LONG?!」、记分卡、把 three 划掉改成 four、红笔结论 slow snail, fast ladder!;右下角还有上一页购物单压过来的无墨压痕) | 约 4 秒 || 描图纸叠层 | `lib/overlay.py` · `Overlay` | `examples/overlay_city_map.py` 海港步行图 · Larkhaven on Foot(暖白灯箱上,定位钉挂着一张黑线灰调的海边小城底图:递归切出的街区、沿街一圈房屋和分户墙、深色地标、海岸与防波堤、铁路、城堡山和岬角的等高线;三张单色叠片对着套准十字落下——蓝片(沿岸一圈圈水线、河、港湾、渡轮航线、2 路电车)、黄片(公园、集市广场、海滩)、品红片(六站步行路线,坐渡轮去灯塔);不同叠片的油墨正片叠底:植物园的池塘叠成绿、路线压过公园成红、压过海面成紫;描图纸背光下的纤维云纹、卷角、打孔、绘图胶带,旁边一张透明胶片上的图例卡) | 约 7 秒 |+| 粉彩界面 · Pastel UI | `lib/pastelui.py` · `PastelUI` | `examples/pastelui_packing.py` 出发前,再查一遍行李 · Pack Check(产品发布片里的一帧:蓝色粉彩底、一大片柔光和几颗白色光斑;左上胶囊「旅行清单」和步骤条 证件 → 充电 → 雨具 → 出发,粗黑大标题「出发前,再查一遍行李」压一条浅蓝色条;macOS 窗口「打包清单 · 京都 4 天」:左栏目的地、三天天气预报(周一下雨)、已装好 11 / 12 进度条,右栏打包助手的话逐行写出——行首的引用标签「证件夹 ✓」、绿色色条压在已装好的东西下、粉色高亮「周一京都有小雨」配「伞还没装」小标签;右边「出门检查」面板三行:证件 ✓、充电 ✓、雨具 ✗,结论「还差一把伞」;放大镜停在周一的雨云上,镜里是真像素放大;紫色云朵 >_ 从窗口后面探头、奶油色圆里的橙色星芒从面板后面探头、橙色像素小怪站在面板上) | 约 0.5 秒(加 `--stages` 约 5 秒) |各画风共用 `lib/core.py` 里的底层工具:噪声、模糊、样条曲线、多边形遮罩、有机轮廓 `blob_pts`、毛笔 `bristle_stroke`、中文字体查找;新四种还用到补零平移 `shift`、文字遮罩 `text_mask`、西文字体查找 `latin_font`/`load_font`,以及高度图打光 `height_normals`、`height_shadow`(沿光线步进的投影)、`ambient_occlusion`。@@ -137,7 +138,8 @@ description: Claude 绘图 / Claude Drawing —— 不借助任何生图模型- 风景、户外、旅行与露营、MG 动画式的场景背景和转场、讲解片的「场景 / 旅程 / 夜晚」页、要干净现代又有层次的插画 → 扁平矢量(要撕纸边和蜡笔的手作感用剪纸拼贴;要正等轴的微缩模型用等轴 2.5D;要 80 年代霓虹用复古 Synthwave);- 要「真的动起来」的小故事、一个可爱小角色的旅程或成长(从 A 到 B、出发—遇到—到达)、讲解片的片头片尾和转场、品牌吉祥物小动画、「一路走一路画出来」的过程感 → 绘本角色动画(`Storybook.gif()` 出真动画,`journey()` 出一张旅程总图;只要一条轮廓的变形用形变动画;要逐帧抖线的静态卡通插画用卡通手绘);- 上课 / 午休走神的随手涂鸦、纸上正在进行的游戏或计划(手画棋盘、寻宝图、清单、路线、比分)、学生和办公室日常的轻松小故事、讲解片里「在草稿纸上推演一步」的页 → 圆珠笔涂鸦(要铅笔图表、荧光笔和贴纸的实验记录用实验笔记本;要没有线稿、柔和的彩铅小物用韩国彩铅;要小孩的蜡笔画用儿童蜡笔画;要黑白石墨写生用铅笔素描);-- 地图、路线与导览、城市 / 园区 / 校园平面图,「一层一层把信息加上去」的图解(底图 → 水系 → 绿地 → 路线),设计稿或方案的分层、叠加与对照,讲解片里「把几层信息叠起来看」的页 → 描图纸叠层(要正等轴的微缩模型用等轴 2.5D;要剖面、尺寸和施工说明用蓝图工程图;要三原色丝网海报用包豪斯几何)。+- 地图、路线与导览、城市 / 园区 / 校园平面图,「一层一层把信息加上去」的图解(底图 → 水系 → 绿地 → 路线),设计稿或方案的分层、叠加与对照,讲解片里「把几层信息叠起来看」的页 → 描图纸叠层(要正等轴的微缩模型用等轴 2.5D;要剖面、尺寸和施工说明用蓝图工程图;要三原色丝网海报用包豪斯几何);+- 产品发布片 / 科技讲解片的「界面 / 流程 / 检查结果」页,要明亮干净、像真产品截图的窗口卡片,一屏讲一件事(大标题 + 一个主窗口 + 一个侧面板 + 状态),一整部讲解片统一的主画面(每节换一种粉彩底、圆形擦除转场)→ 粉彩界面(要磨砂玻璃和弥散渐变用弥散玻璃;要等轴微缩模型用等轴 2.5D;要黑白早期界面用 1-bit 早期画图软件)。每种画风一幅范例作为质量基准(范例都不用禅意主题);水墨另加一幅「月印万川」(留白托月、水面倒影)。@@ -964,6 +966,17 @@ from core import spline, curve, blob_pts, fbm1d, blur, polygon_mask- 字体 `font(kind, size)`:map / map_bold / map_heavy / map_italic / map_light(Gill Sans 一族)、title(Avenir Next Heavy)、label、cjk / cjk_light(黑体),也认 core 的样式名;可用 `INKPAINT_FONT_OVERLAY_<KIND>` 指定- 常量 `INKS`(black blue yellow magenta cyan orange green red)、`PAPERS`;`stage(name)`、`save(path, stages_dir)`;`save('x.jpg')` 默认 quality 88、4:4:4 色度+**粉彩界面 `PastelUI`**:+- 思路:产品发布片里的一帧界面。整片纯色粉彩底(蓝 / 粉 / 黄 / 淡紫 / 薄荷 / 桃,`FIELDS`)加一大片柔光和几颗白色光斑;上面是 macOS 窗口卡片和侧面板、胶囊、粗黑大标题压半透明色条、状态标签、✓ / ✗ 徽章、文字高亮、放大镜,三个扁平小图标从卡片边探头。所有圆角矩形、圆、环、胶囊和线性图标都是有符号距离场,1 px 解析抗锯齿(像素中心取 i + 0.5,整数坐标的边是锐利的);只有自由多边形(小标签的尖角)是 4 倍超采样再 BOX 缩小。阴影按 CSS box-shadow 的语义算(偏移、模糊半径 σ = blur / 2、扩展、颜色、不透明度,只画在元素外面):卡片叠两三层——一圈发丝描边、一层染着底色的宽阴影、一层中性的近阴影,所以卡片浮起来却没有灰边+- 图层:一切都画进有名字的图层(预乘 RGBA,收尾时裁到画过的范围)。`layer(name, z)` 开始往某层画(再次调用会重新打开),z 小的在后面:小图标的 z 比卡片小,就只露出探出卡片边的那一截;`end()` 之后画在底色上。每层有姿态 `pose(name, dx, dy, scale, alpha, reveal, origin, feather)`:位移、绕 origin 缩放、不透明度、从左往右揭开(reveal 0–1,软边 feather px);`show / hide` 只改不透明度;`bounds(name)`。同一样东西的两种状态(检查行之前 / 之后)画成两层,用 show / hide 切换。`stage(name)` 按当前姿态合成快照(PNG 压缩存在内存里)+- 构造:`PastelUI(W, H, seed, keep_stages=True)`;`field(colour='blue', glow=(x, y), glow_size, glow_alpha, bokeh)` 底色(用 FIELDS 名字时同时设定强调色 `accent`、阴影色 `tint`、标题色条色 `mark_colour`);`wipe(cx, cy, r, prev='lilac', rim, rim_width)` 圆形擦除:圆里显示一切,圆外是上一节的底色,圆边一道强调色的环,`wipe()` 清掉+- 形状:`rrect(x0, y0, x1, y1, r, fill, alpha, grad=(c0, c1), angle, ring, inset)`(ring=w 只画边,inset 决定在里还是在外)、`circle(cx, cy, r, fill, alpha, ring, grad)`、`line(pts, width, fill)`、`poly(pts, fill)`、`shadow(x0, y0, x1, y1, r, dx, dy, blur_px, spread, colour, alpha, shape=(cx, cy, r))`、`soft_shadow(cov_fn, box, …)`(任意形状的 drop-shadow)、`with clip(x0, y0, x1, y1, r):` 把里面画的东西裁进圆角矩形(窗格底色裁进窗体圆角)+- 文字:`text(s, x, y, size, fill, weight='regular'|'medium'|'bold'|'heavy', anchor, alpha, spacing, family='sans'|'mono')`,返回宽度;中英文自动分段(macOS:中文苹方、粗黑标题兰亭黑 Heavy、西文 SF Pro 可变字重、等宽 SF Mono;其他系统 Noto Sans CJK / 微软雅黑;可用 `INKPAINT_FONT_PASTELUI_<CJK|HEAVY|LATIN|MONO>` 指定);anchor 的第二个字母 s 基线 / m 中文字身中线 / t 字身顶;`measure(…)` 量宽度;`marker(x0, x1, base, h, colour, alpha, drop)` 压在字下面的色条(文字高亮就是 h 盖满字高的 marker)+- 部件:`window(x, y, w, h, title, icon, sub, split, bar=50, radius=22, rim=9, tint)` 返回 Box(`.bar`、`.left`、`.right` 两个窗格):55 % 白的磨砂外框、两层阴影、白色窗体、标题栏红黄绿三点、居中的应用小图标 + 粗体标题 + 等宽副标题、浅色左栏和发丝分隔线;`card(x, y, w, h, r=26)` 侧面板;`pill(x, cy, text, dot)` 带圆点的小胶囊,返回右边缘;`steps(x, cy, labels, lit, current)` 箭头连起来的步骤条;`headline(x, base, text, size, mark='关键词', draw_text, draw_mark)` 粗黑标题和色条(两者可分两层画,色条那层 z 放后面);`chip(x, cy, text, colour, size, solid, glyph, anchor)` 状态标签;`mono_tag`;`callout(x, cy, text, colour, glyph)` 左边带尖角的实心小标签;`ref_chip(x, base, text, glyph, ok)` 嵌在正文行里的引用标签(右上角绿色 ✓ 小圆);`badge(cx, cy, 'pass'|'fail', size)`;`spinner`;`bar(x0, x1, cy, frac)`;`tile(x, y, size, fill, glyph, grad)` 应用图标方块;`avatar`;`glyph(name, cx, cy, size, fill, sw)` 24 格线性图标(`GLYPHS`:more user code lens spark book inbox tag check x suitcase umbrella plug passport calendar pin sun bolt leaf);`weather('sun'|'partly'|'cloud'|'rain', cx, cy, size)`;`check_row(x, y, w, h, label, tag, sub, glyph, tone, state='idle'|'active'|'pass'|'fail', result, status)` 检查行(status=False 时右端留空,用 `row_status(x1, cy, state, text)` 画到另一层,好单独弹出徽章)+- 放大镜:`magnifier(cx, cy, r, mag, colour, name='lens', z, handle=45)` 自成一层;合成时先把它下面**真实的像素**按 mag 倍双线性放大进镜片,再画白色镜框、淡紫内圈、高光和紫色渐变镜柄;用 `pose('lens', dx, dy, scale)` 移动,放大的内容跟着走+- 小图标(扁平矢量、无脸):`spark(cx, cy, size, spin)` 奶油色圆里的橙色星芒(白圈、暖色投影);`cloud(cx, cy, size, rot)` 紫色渐变云朵里的白色 >_(十一个圆平滑并集、径向渐变、光泽、投影);`critter(x, y, px=9, blink)` 橙色像素小怪(10 × 6 格,整数像素对齐)+- 色板常量 `INK BLUE LILAC GREEN PINK YELLOW MINT PEACH CLAY LINE GREY FIELDS BOKEH`;`render()`、`composite()`、`save(path, stages_dir)`;`save('x.jpg')` 默认 quality 88、4:4:4 色度+**顺序**:都是先远后近、先大后小,文字最后叠加。水墨的雾要画在它该吞没的东西之后;水彩的叶梗要先画,并且只画在叶子外面。## 三、毛病清单(都真实出现过)@@ -1903,6 +1916,19 @@ from core import spline, curve, blob_pts, fbm1d, blur, polygon_mask| 动图 5.1 MB:每落下一张纸,整片带纹理的区域都重新编码 | 见第四节:只重发明显变化的像素,开灯的叠化帧不加抖动;1.9 MB || 跳过小变化以后,灯箱渐变和海面上出现一圈圈等高线似的色斑 | 差值拆成平滑分量(模糊 2 px)和细节残差分开判断;停 900 毫秒的关键帧把平滑分量追到 3 级以内;开灯那几帧逐像素精确发送 |+**粉彩界面**++| 问题 | 改法 |+|---|---|+| 放大镜压在四天天气预报上:一列只有 86 px,镜片盖住了「周一」、切掉半个「18°」,粉色选中框在镜里变成两道竖条 | 预报改成三天(每列 113 px),日期和温度离图标中心 66 / 76 px,正好在镜框外;镜片半径 47、放大 1.42 倍,镜里只看得到那朵雨云 |+| 绿色色条压在字的下半截,看着像删除线 | 色条下沿落到基线下约 0.22 em(32 px 字:drop 7、高 13),只垫在字脚下 |+| 两个窗格下面各空出约 100 px | 正文行距 70 → 72、首行下移 10 px,进度条贴着预报卡往下放 |+| 「根据 [证件夹]:护照、机票都在」读着别扭 | 引用标签放到行首:「[证件夹 ✓] 里,护照、机票都在;」 |+| 换成薄荷底,步骤条和胶囊跟着变绿,和「通过」的绿色撞在一起 | 有 ✓ / ✗ 的画面用蓝底(强调色是蓝),绿色只留给通过 |+| 回弹缓动前两步就走完 99 %,五步的弹出看着像直接冒出来 | 窗口和面板的弹出改成六步 |+| 动图里橙色像素小怪和星芒变成粉色、绿色徽章变成青色、奶油色圆盘抖成粉点 | 这些颜色面积小、最后几秒才出现,中值切分分不到色位:把整套界面色(47 个精确色值)强制放进调色板,最后一帧取样 ×8 |+| 84 张阶段快照留在内存里,峰值 1.27 GB | `stage()` 存成 PNG 压缩字节(compress_level=1),峰值约 0.54 GB |+## 四、做成动画- 各画风都有 `stage(name)` 和 `save(path, stages_dir)`,按阶段依次淡入叠化,就是「一幅画被逐步画出来」。README 里的动图就是这样做的。@@ -1923,6 +1949,7 @@ from core import spline, curve, blob_pts, fbm1d, blur, polygon_mask- 满屏几乎一种色调(X 光片的蓝胶片)时,补几个色位不够:按「主色调像素 / 其余彩色像素」两段分别中值切分(186 + 69 色);OSD 里必须精确的纯白、纯黑、REC 红这类颜色直接强制占色位(热成像、VHS 家庭录像),否则白字被量化成淡黄。- 大块色层整片交接的叠化(扁平矢量的夜蓝 → 橙 → 沙):调色板样本里加上 1/3、2/3 两张叠化帧,Bayer 只叠在两张关键帧不同的地方(整帧都叠更大;Floyd–Steinberg 更大,还会抖出透明占位色)。只有黑白两值的画风(1-bit 早期画图软件)缩小用 BOX、配固定灰阶调色板,不做中值切分。- 描图纸叠层的动图(脚本在 `claude_drawing/overlay_work/make_gif_overlay.py`):阶段是 关灯 → 灯变暖 → 开灯 → 底图 → 每张叠片「抬起、偏着」→「放下」→ 胶片图例卡 → 贴胶带。一张纸落下,会让一大片带纹理的区域整体变几级、线条由糊变清,逐帧精确差分要 3–5 MB。做法:目标和屏上已显示颜色的差值拆成平滑分量(模糊 2 px)和细节残差,平滑分量超过阈值(叠化帧 12 级、关键帧 3 级)或单点超过阈值(30 / 16 级)才重发,只有单点超阈值的孤立像素(纸纹在阈值上下翻动)不发;开灯那几帧逐像素精确发送,其中的叠化帧不加抖动(加了每帧每个像素都变);最后一帧收紧阈值追平。73 帧约 1.9 MB,按解码结果逐帧自检。+- 粉彩界面的动图(脚本在 `claude_drawing/pastelui_work/make_gif_pastelui.py`):阶段是 圆形擦除铺开底色 → 窗口弹出 → 胶囊、标题、色条、左栏、正文逐行写出 → 面板弹出 → 徽章依次打勾 / 打叉(中间放大镜从第三行飞到天气预报上)→ 三个小图标探头。会动的东西不用叠化:范例里 `move()` 给每样东西几个缓动 / 回弹的中间姿态,存成 `mv_*` 阶段,动图里每个 50 毫秒硬切,就是真运动(写字是 reveal 从 0 到 1,徽章是绕自己中心从 0.3 倍回弹到 1);其余阶段用 70 毫秒的帧叠化。调色板先强制放进整套界面色,再按加权样本中值切分;固定 4×4 Bayer,没变的像素记成品红透明。107 帧、15.6 秒、约 0.35 MB,按解码结果逐帧自检。- 绘本角色动画的动图是真动画,不是阶段叠化:`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 遮罩按顺序显现。这个还没做成现成接口。@@ -1991,6 +2018,7 @@ lib/flatvector.py 扁平矢量(分层几何色块、七色限定色板、lib/storybook.py 绘本角色动画(按时间取帧:带揭示图的场景层、follow 边走边画、隐式曲面角色挤压拉伸、动作编排、特效、按骨架笔顺手写、旅程总图)lib/ballpoint.py 圆珠笔涂鸦(复印纸纹、纤维与折痕;圆珠笔:干起笔、压力线宽、断墨、墨团、收笔小钩、描两遍、压痕;彩铅斜向排线出界;圆珠笔之字排线;字体骨架重描的手写、划掉重写、无墨压痕字)lib/overlay.py 描图纸叠层(灯箱发光、黑线灰调底图与单色叠片、透过率相乘的油墨、背光纤维云纹、抬起时的漫射模糊与投影、卷角、打孔与定位钉、套准十字、绘图胶带、透明胶片)+lib/pastelui.py 粉彩界面(纯色粉彩底与光斑、距离场抗锯齿的窗口卡片与部件、CSS 式多层阴影、带姿态的图层、真像素放大镜、圆形擦除、三个扁平小图标)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_pastelui_packing.gif b/examples/drawing_pastelui_packing.gifnew file mode 100644index 0000000..87ce601Binary files /dev/null and b/examples/drawing_pastelui_packing.gif differdiff --git a/examples/pastelui_packing.jpg b/examples/pastelui_packing.jpgnew file mode 100644index 0000000..f3ce2ebBinary files /dev/null and b/examples/pastelui_packing.jpg differdiff --git a/examples/pastelui_packing.py b/examples/pastelui_packing.pynew file mode 100644index 0000000..103bc8a--- /dev/null+++ b/examples/pastelui_packing.py@@ -0,0 +1,230 @@+"""Example (pastel UI): 出发前,再查一遍行李 / Pack Check — one frame of a product film in the pastel-UI look.++A flat pastel field with a soft pool of light and bokeh; a section pill and a step strip (证件 → 充电 → 雨具 → 出发);+a heavy headline with a marker stroke under the key words. A macOS window card, 「打包清单 · 京都 4 天」: on the left+the trip (destination, dates, a four-day forecast, a packing progress bar), on the right the packing assistant's+note, written line by line, with an inline reference chip, green markers under what is packed and a pink highlight+on the one thing that is not -- 周一京都有小雨, with a 「伞还没装」 callout. Beside it a checklist panel, 「出门检查」:+three rows, two pass with a green check, the third (雨具) fails with a pink cross, and the verdict 「还差一把伞」.+A magnifier rests on Monday's rain cloud in the forecast, magnifying the real pixels. Three flat companions peek+over the card edges: a violet cloud with a >_ prompt behind the window, a starburst in a cream circle behind the+panel, and the orange pixel critter standing on the panel. No image model.+python3 pastelui_packing.py [out.jpg] [--stages DIR] [--field blue|mint|peach|...]+"""+import os, sys, time+import numpy as np+sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'lib'))+from pastelui import PastelUI, Box, INK, BLUE, LILAC, GREEN, PINK, YELLOW, LINE, GREY, WHITE++out = sys.argv[1] if len(sys.argv) > 1 and not sys.argv[1].startswith('--') else 'pastelui_packing.jpg'+stages = sys.argv[sys.argv.index('--stages') + 1] if '--stages' in sys.argv else None+FIELD = sys.argv[sys.argv.index('--field') + 1] if '--field' in sys.argv else 'blue'+T0 = time.time()+tick = lambda name: print(f'{name:14s} {time.time() - T0:5.1f}s') if os.environ.get('PASTELUI_TIMING') else None++ui = PastelUI(1920, 1080, seed=4, keep_stages=bool(stages))+ui.field(FIELD, glow=(520, 150))++# ===================================================================== layout+WX, WY, WW, WH, SPLIT, BAR = 120, 300, 1090, 600, 400, 54 # window body+PX, PY, PW, PH = 1290, 352, 510, 548 # checklist panel+LX0, LX1 = WX + 30, WX + SPLIT - 30 # left pane content+RX0, RX1 = WX + SPLIT + 44, WX + WW - 36 # right pane content+TX, TY0, TLH, TS = RX0, 522, 72, 32 # reply text: x, first baseline, line height, size+LINE_Y = [TY0 + i * TLH for i in range(5)]+WEEK = [('周日', 'partly', '22°'), ('周一', 'rain', '18°'), ('周二', 'sun', '23°')]+WXC = Box(LX0 - 2, 546, LX1 + 2, 794, 18) # forecast card+COLW = WXC.w / 3+ICON_Y = WXC.y0 + 152+RAIN = (WXC.x0 + COLW * 1.5, ICON_Y) # Monday's icon centre++# ===================================================================== companions behind the cards (drawn first, low z)+ui.layer('cloud', z=5)+ui.cloud(1096, WY - 120 * 0.84 + 60, 120, rot=-4)+ui.layer('spark', z=5)+ui.spark(1470, PY - 124 * 0.8 + 62, 124, spin=8)++# ===================================================================== title: pill, step strip, headline + marker+ui.layer('pill', z=20)+PILL_X1 = ui.pill(120, 112, '旅行清单')+STEPS = ['证件', '充电', '雨具', '出发']+for k, cur in [(0, None), (1, 0), (2, 1), (3, 2)]:+ ui.layer(f'steps{k}', z=20)+ ui.steps(PILL_X1 + 26, 112, STEPS, lit=k, current=cur)+HEAD = '出发前,再查一遍行李'+ui.layer('mark', z=19)+_, span = ui.headline(116, 236, HEAD, 76, mark='再查一遍行李', draw_text=False)+ui.layer('headline', z=20)+ui.headline(116, 236, HEAD, 76, mark='再查一遍行李', draw_mark=False)+tick('title')++# ===================================================================== the window+ui.layer('window', z=10)+win = ui.window(WX, WY, WW, WH, title='打包清单', icon='suitcase', sub='· 京都 4 天', split=SPLIT, bar=BAR)++# left pane: trip, forecast, progress+ui.layer('trip', z=12)+y = WY + BAR + 36+ui.glyph('pin', LX0 + 9, y, 19, '#7d8796', 1.9)+ui.text('目的地', LX0 + 26, y, 17, '#6a7482', 'bold', 'lm', spacing=1)+ui.text('10/12 – 10/15', LX1, y, 15, '#9aa3af', 'regular', 'rm', family='mono')+ui.text('京都', LX0, y + 84, 50, '#18202b', 'heavy')+ui.chip(LX1, y + 84 - 50 * 0.37, '明早出发', BLUE, size=16, solid=True, anchor='r')+ui.text('4 天 3 晚 · 1 只登机箱', LX0, y + 122, 18, '#8a94a3')+ui.shadow(*WXC, WXC.r, 0, 10, 22, -16, '#143c78', 0.45)+ui.rrect(*WXC, WXC.r, WHITE)+ui.rrect(*WXC, WXC.r, '#e2e8f0', ring=1.0)+ui.tile(WXC.x0 + 18, WXC.y0 + 16, 30, YELLOW, 'sun', radius=9, glyph_size=19, sw=2.2, shadow=False)+ui.text('天气预报', WXC.x0 + 58, WXC.y0 + 31, 18, '#1f2733', 'bold', 'lm')+for i, (d, kind, t) in enumerate(WEEK):+ cx = WXC.x0 + COLW * (i + 0.5)+ ui.text(d, cx, ICON_Y - 66, 17, '#8a94a3', 'regular', 'mm')+ ui.weather(kind, cx, ICON_Y, 50)+ ui.text(t, cx, ICON_Y + 76, 22, '#2b3442', 'bold', 'ms')+py = WXC.y1 + 50+ui.text('已装好', LX0, py, 17, '#8a94a3', 'regular', 'ls')+ui.text('11 / 12', LX1, py, 19, '#2b3442', 'bold', 'rs', family='mono')+ui.bar(LX0, LX1, py + 24, 11 / 12, BLUE, 8)+ui.layer('wx_hl', z=13) # Monday, after the check+hx0, hx1 = WXC.x0 + COLW + 6, WXC.x0 + COLW * 2 - 6+ui.rrect(hx0, WXC.y0 + 58, hx1, WXC.y1 - 10, 16, PINK, 0.08)+ui.rrect(hx0, WXC.y0 + 58, hx1, WXC.y1 - 10, 16, PINK, 0.85, ring=2.0)+tick('left pane')++# right pane: the assistant's note+ui.layer('reply_head', z=12)+hy = WY + BAR + 44+ui.tile(RX0, hy - 23, 46, grad=('#63b6ff', '#1f8ff0'), glyph='suitcase', radius=14, glyph_size=25)+ui.text('打包助手', RX0 + 60, hy - 5, 20, '#1f2733', 'bold')+ui.circle(RX0 + 64, hy + 16, 3.5, '#28c840')+ui.text('清单已生成 · 12 件', RX0 + 74, hy + 16, 15, '#8a94a3', 'regular', 'lm')+ui.rrect(RX0, hy + 44, RX1, hy + 45, 0, LINE)+for name, txt, col in [('chip_draft', '清单草稿', '#8a94a3'), ('chip_check', '检查中', LILAC), ('chip_fail', '还差 1 件', PINK)]:+ ui.layer(name, z=12)+ ui.chip(RX1, hy - 4, txt, col, size=16, anchor='r')++ui.layer('line0', z=14)+ui.text('明早出发,帮你对一遍:', TX, LINE_Y[0], TS, '#232a35')+ui.layer('line1', z=14)+x = ui.ref_chip(TX, LINE_Y[1], '证件夹', glyph='passport', size=26)+ui.text('里,护照、机票都在;', x + 12, LINE_Y[1], TS, '#232a35')+ui.layer('line2_mk', z=13)+w = ui.measure('充电器、转换插头', TS)+ui.marker(TX, TX + w, LINE_Y[2], 13, '#a6e6bd', 0.85, drop=7)+ui.layer('line2', z=14)+ui.text('充电器、转换插头已装好,', TX, LINE_Y[2], TS, '#232a35')+ui.layer('line3_hl', z=13)+w3 = ui.measure('周一京都有小雨', TS)+ui.marker(TX, TX + w3, LINE_Y[3], 40, '#ffbdd5', 0.95, drop=7)+ui.layer('line3', z=14)+W3 = ui.text('周一京都有小雨,', TX, LINE_Y[3], TS, '#232a35')+ui.layer('line3_tag', z=15)+ui.callout(TX + W3 + 14, LINE_Y[3] - TS * 0.37, '伞还没装', PINK, glyph='umbrella', size=19)+ui.layer('line4', z=14)+ui.text('一路顺风!', TX, LINE_Y[4], TS, '#6b7482')+tick('right pane')++# ===================================================================== the checklist panel+ui.layer('panel', z=30)+card = ui.card(PX, PY, PW, PH)+ui.text('出门检查', PX + 30, PY + 66, 36, '#141a24', 'heavy')+ui.mono_tag(PX + PW - 30, PY + 50, 'CHECK')+ui.text('三样东西,各看一眼', PX + 30, PY + 104, 18, '#6b7686')+ui.rrect(PX + 30, PY + PH - 104, PX + PW - 30, PY + PH - 103, 0, LINE)+ui.text('这只箱子', PX + 30, PY + PH - 66, 16, '#8a94a3')+ROWS = [('证件', '必带', '护照、机票', 'passport', BLUE, 'pass', '齐了'),+ ('充电', '必带', '充电器、转换插头', 'plug', BLUE, 'pass', '齐了'),+ ('雨具', '看天气', '周一有雨', 'umbrella', LILAC, 'fail', '没带')]+RH, RG, RY0 = 100, 14, PY + 128+for i, (lab, tag, sub, gl, tone, res, txt) in enumerate(ROWS):+ ry = RY0 + i * (RH + RG)+ states = ['idle', res] + (['active'] if res == 'fail' else [])+ for st in states:+ ui.layer(f'row{i}_{st}', z=31)+ ui.check_row(PX + 30, ry, PW - 60, RH, lab, tag=tag, sub=sub, glyph=gl, tone=tone, state=st,+ status=(st != res), progress=0.62)+ ui.layer(f'row{i}_st', z=32)+ ui.row_status(PX + PW - 48, ry + RH / 2, res, txt, tone, RH)+ui.layer('verdict', z=32)+ui.text('还差一把伞', PX + 30, PY + PH - 32, 24, '#1b2230', 'bold')+ui.chip(PX + PW - 30, PY + PH - 50, '未装好', PINK, size=21, solid=True, glyph='x', anchor='r', pad=16)+ui.layer('verdict_wait', z=32)+ui.text('等待检查', PX + PW - 30, PY + PH - 50, 16, '#a3acb8', 'regular', 'rm')+tick('panel')++# ===================================================================== the critter on the panel, the magnifier+ui.layer('critter', z=35)+ui.critter(1650, PY - 54 + 1, 9)+ui.magnifier(RAIN[0], RAIN[1], 47, 1.42, z=40, handle=58)+ui.end()+tick('drawn')++# ===================================================================== stage by stage (the draw-on GIF), then the final frame+# Things that move get a few in-between poses (stage names 'mv_*': the GIF shows them as quick hard cuts, i.e. real+# motion); everything else cross-fades from stage to stage.+ALL = list(ui.layers)+ease_out = lambda u: 1 - (1 - u) ** 3+ease_back = lambda u: 1 + 2.4 * (u - 1) ** 3 + 1.4 * (u - 1) ** 2 # overshoots ~6 % and settles+ease_io = lambda u: 3 * u * u - 2 * u ** 3+REST = dict(dx=0.0, dy=0.0, scale=1.0, alpha=1.0, reveal=1.0)+++def move(names, frm, to=REST, n=5, tag='', ease=ease_out, last=True, origin=None, between=None):+ """pose one or more layers from `frm` to `to` over n stages; the last stage is named `tag`"""+ names = [names] if isinstance(names, str) else names+ for k in range(1, n + 1):+ u = ease(k / n)+ p = {key: frm.get(key, REST[key]) + (to.get(key, REST[key]) - frm.get(key, REST[key])) * u for key in REST}+ p['alpha'] = min(1.0, max(0.0, p['alpha']))+ if between: between(p, k / n)+ for nm in names: ui.pose(nm, origin=origin, **p)+ if k < n: ui.stage(f'mv_{tag}{k}')+ elif last: ui.stage(tag)+++def pop(name, tag, cx, cy):+ move(name, dict(scale=0.3, alpha=0.0), n=4, tag=tag, ease=ease_back, origin=(cx, cy))+++if stages:+ for n in ALL: ui.hide(n)+ for r in (0, 170, 400, 690, 1030):+ ui.wipe(1010, 560, r, prev='lilac', rim_width=26 * (1 - 0.5 * r / 1030)); ui.stage(f'wipe{r:04d}')+ ui.wipe(); ui.stage('field')+ move('window', dict(dy=80, scale=0.96, alpha=0.0), n=6, tag='window', ease=ease_back)+ ui.show('pill', 'steps0'); ui.stage('pill')+ ui.show('headline'); ui.stage('headline')+ move('mark', dict(reveal=0.0), n=4, tag='mark')+ ui.show('trip'); ui.stage('trip')+ ui.show('reply_head', 'chip_draft'); ui.stage('reply_head')+ for nm in ['line0', 'line1', 'line2', 'line3', 'line4']:+ group = [nm, 'line2_mk'] if nm == 'line2' else [nm]+ move(group, dict(reveal=0.0), n=4, tag=nm, ease=ease_io)+ move('panel', dict(dy=70, scale=0.96, alpha=0.0), n=6, tag='panel', ease=ease_back)+ ui.show('row0_idle', 'row1_idle', 'row2_idle', 'verdict_wait'); ui.stage('rows')+ for i in range(2):+ cy = RY0 + i * (RH + RG) + RH / 2+ ui.hide(f'row{i}_idle', f'steps{i}'); ui.show(f'row{i}_pass', f'steps{i + 1}')+ pop(f'row{i}_st', f'check{i}', PX + PW - 110, cy)+ # the third row starts checking: the lens leaves its row, flies over to the forecast and settles on Monday+ ui.hide('row2_idle', 'chip_draft'); ui.show('row2_active', 'chip_check'); ui.stage('row2_active')+ lx, ly = PX + 90 - RAIN[0], RY0 + 2 * (RH + RG) + RH / 2 - RAIN[1]+ move('lens', dict(dx=lx, dy=ly, scale=0.3, alpha=0.0), n=7, tag='lens', ease=ease_io,+ between=lambda p, u: p.update(dy=p['dy'] - 220 * np.sin(np.pi * u), alpha=min(1, 4 * u)))+ ui.hide('row2_active', 'chip_check', 'steps2'); ui.show('row2_fail', 'chip_fail', 'wx_hl', 'line3_hl', 'steps3')+ pop('row2_st', 'check2', PX + PW - 110, RY0 + 2 * (RH + RG) + RH / 2)+ pop('line3_tag', 'tag', TX + W3 + 14, LINE_Y[3] - TS * 0.37)+ ui.hide('verdict_wait'); ui.show('verdict'); ui.stage('verdict')+ move('cloud', dict(dy=150, alpha=1.0), n=5, tag='cloud', ease=ease_back)+ move('spark', dict(dy=150, alpha=1.0), n=5, tag='spark', ease=ease_back)+ move('critter', dict(dy=-110, alpha=0.0), n=4, tag='critter', ease=ease_back, last=False)++# final poses: everything finished+for n in ALL:+ ui.pose(n)+for n in ['steps0', 'steps1', 'steps2', 'chip_draft', 'chip_check', 'verdict_wait',+ 'row0_idle', 'row1_idle', 'row2_idle', 'row2_active']:+ ui.hide(n)+ui.save(out, stages_dir=stages)+tick('saved')+print('saved', out)diff --git a/lib/pastelui.py b/lib/pastelui.pynew file mode 100644index 0000000..2470a26--- /dev/null+++ b/lib/pastelui.py@@ -0,0 +1,1069 @@+"""pastelui — 粉彩界面 / Pastel UI: product-film interface frames on flat pastel fields (numpy + Pillow only).++The look of a modern product launch film: a flat pastel field (blue, pink, yellow, lilac, mint, peach) with one big+soft pool of light and a few white bokeh discs; on it, crisp macOS-style window cards and side panels; a headline in+heavy black type with a translucent marker stroke under the key words; pills, status chips, round check / cross+badges, text highlights and a magnifier; and three small flat companions peeking over the card edges (a starburst+in a cream circle, a violet cloud with a `>_` prompt, a pixel critter). Clean, bright, no texture, no plush.++ shapes every rounded rectangle, disc, ring, capsule and icon stroke is a signed-distance field with 1 px+ analytic anti-aliasing (pixel centres at i + 0.5, so integer coordinates give crisp edges); the few+ free polygons (pointer triangles) are rasterised 4x and box-filtered.+ shadows CSS box-shadow semantics: offset, blur radius (sigma = blur / 2), spread, colour, opacity; painted+ only outside the element. Cards stack two or three: a hairline ring, a wide shadow tinted with the+ field's colour (so cards float without a grey halo) and a tight neutral key shadow.+ windows a frosted rim (white at 55 % with a white hairline inside), a white body with a 1 px border at 8 %,+ a title bar with the red / yellow / green lights, an app icon and a centred title, split panes with a+ pale left pane and hairline dividers. `clip()` keeps pane fills inside the body's rounded corners.+ type PingFang SC (CJK) + SF Pro (Latin, variable weight) on macOS, Lantinghei SC Heavy for the heavy+ headline weight, SF Mono for ids and tags; script runs are split automatically. Elsewhere Noto Sans+ CJK / Microsoft YaHei and the core fonts. Override with $INKPAINT_FONT_PASTELUI_<CJK|HEAVY|LATIN|MONO>.+ layers everything is drawn into named layers (premultiplied RGBA, cropped to what was drawn). A layer has a+ depth and a pose -- offset, scale about an origin, opacity, left-to-right reveal -- so one drawing+ can be shown in many states: a window popping up, a line being written, a companion rising from+ behind a card, a badge popping in. Two drawings of the same thing in two states (a check row before+ and after) are two layers; switch them with show / hide. `stage()` composites the current poses.+ magnifier a lens layer: when composited it magnifies the real pixels under it (bilinear), adds a faint tint+ ring, then draws its white rim, glint and violet handle on top.+ wipe `wipe(cx, cy, r, prev)`: everything shows inside a growing circle, the previous field colour+ outside, a coloured rim leads the edge (the section change of the film).++ import sys; sys.path.insert(0, 'lib')+ from pastelui import PastelUI, BLUE, GREEN, PINK+ ui = PastelUI(1920, 1080, seed=1)+ ui.field('blue', glow=(520, 150))+ ui.layer('title')+ x = ui.pill(140, 110, '一个例子', BLUE)+ ui.headline(137, 230, '一张工单,走完整个流程', 66, mark='走完整个流程')+ ui.layer('window')+ win = ui.window(140, 300, 1060, 560, title='客服工作台', icon='inbox', sub='· 工单 #0412', split=400)+ ui.layer('panel')+ card = ui.card(1290, 330, 490, 520)+ ui.check_row(card.x0 + 28, card.y0 + 120, card.w - 56, 96, '引用条款', tag='代码规则', sub='引用了手册条款?',+ glyph='code', state='pass', result='通过')+ ui.layer('buddy', z=-1) # behind the window: only the top peeks out+ ui.spark(1468, 290, 124)+ ui.pose('window', dy=60, scale=0.97, alpha=0.6); ui.stage('window_in')+ ui.pose('window'); ui.save('out.jpg')+"""+import glob+import io+import os+from contextlib import contextmanager+import numpy as np+from PIL import Image, ImageDraw, ImageFont+from core import blur, load_font++# ---------------------------------------------------------------- palette (the Dot-film kit)+INK = '#1b1b1f'+BLUE, LILAC, GREEN, PINK = '#1f8ff0', '#8a4fe0', '#1fa866', '#f25c92'+YELLOW, MINT, PEACH = '#f5b400', '#2fb35f', '#f2643a'+CLAY, PIXINK = '#d97757', '#1b1a18'+LINE, GREY = '#e9eef4', '#6f7a88'+PANE = '#f7f9fc'+WHITE = '#ffffff'+FIELDS = { # name: (field, accent, shadow tint, marker under a headline)+ 'blue': ('#d6effd', BLUE, '#2878c8', '#a6d4fb'),+ 'pink': ('#fae3ed', PINK, '#c8507e', '#ffbdd5'),+ 'yellow': ('#fff3c4', YELLOW, '#c08a10', '#ffdf7e'),+ 'lilac': ('#ece3fb', LILAC, '#6e3cc8', '#d6c4fb'),+ 'mint': ('#ddf6e4', MINT, '#2a9a5a', '#a6e6bd'),+ 'peach': ('#ffe6da', PEACH, '#d06a40', '#ffc4ad'),+}+BOKEH = [(0.05, 0.9, 56, 0.45), (0.955, 0.13, 38, 0.7), (0.975, 0.86, 70, 0.45), (0.47, 0.965, 30, 0.7), (0.6, 0.05, 22, 0.45)]+LIGHTS = ('#ff5f57', '#febc2e', '#28c840')+RAYS = [(0, 1), (31, 0.86), (64, 0.97), (97, 0.83), (128, 1), (160, 0.88), (193, 0.96), (226, 0.84), (258, 1),+ (291, 0.9), (326, 0.95)] # starburst rays: (angle clockwise from up, length)+CRITTER = ['.########.', '.#o####o#.', '##########', '.########.', '.#.#..#.#.', '.#.#..#.#.']++# line icons on a 24-unit grid (stroked): ('p', points, closed) polyline, ('c', cx, cy, r) circle, ('a', cx, cy, r, a0, a1)+# arc (degrees, 0 = +x, 90 = down), ('d', cx, cy, r) filled dot, ('r', x0, y0, x1, y1, radius) rounded rectangle+GLYPHS = {+ 'more': [('d', 5, 12, 1.3), ('d', 12, 12, 1.3), ('d', 19, 12, 1.3)],+ 'user': [('c', 12, 8, 4), ('a', 12, 21, 8, 180, 360)],+ 'code': [('p', [(8, 7), (3, 12), (8, 17)]), ('p', [(16, 7), (21, 12), (16, 17)]), ('p', [(14, 4), (10, 20)])],+ 'lens': [('c', 10.5, 10.5, 6.5), ('p', [(15.5, 15.5), (20, 20)])],+ 'spark': [('p', [(12, 3), (13.9, 8.1), (19, 10), (13.9, 11.9), (12, 17), (10.1, 11.9), (5, 10), (10.1, 8.1)], True),+ ('p', [(18.5, 15.5), (19.3, 17.7), (21.5, 18.5), (19.3, 19.3), (18.5, 21.5), (17.7, 19.3), (15.5, 18.5), (17.7, 17.7)], True)],+ 'book': [('p', [(5, 19.5), (5, 5.5)]), ('a', 6.5, 5.5, 1.5, 180, 270), ('p', [(6.5, 4), (18, 4), (18, 18), (6.5, 18)]),+ ('a', 6.5, 19.5, 1.5, 90, 270), ('p', [(6.5, 21), (18, 21), (18, 18)])],+ 'inbox': [('p', [(4, 13), (6.5, 5), (17.5, 5), (20, 13), (20, 19), (4, 19)], True),+ ('p', [(4, 13), (8.5, 13), (10, 15.5), (14, 15.5), (15.5, 13), (20, 13)])],+ 'tag': [('p', [(4, 4), (11, 4), (20, 13), (13, 20), (4, 11)], True), ('d', 8.5, 8.5, 1.2)],+ 'check': [('p', [(5, 12.5), (9.5, 17), (19, 7)])],+ 'x': [('p', [(7, 7), (17, 17)]), ('p', [(17, 7), (7, 17)])],+ 'suitcase': [('r', 4.5, 7.5, 19.5, 20.5, 2.5), ('p', [(9, 7.5), (9, 4.5), (15, 4.5), (15, 7.5)]),+ ('p', [(9, 11), (9, 17)]), ('p', [(15, 11), (15, 17)])],+ 'umbrella': [('a', 12, 12.5, 8.5, 180, 360), ('p', [(3.5, 12.5), (20.5, 12.5)]), ('p', [(12, 12.5), (12, 18.5)]),+ ('a', 10, 18.5, 2, 0, 180)],+ 'plug': [('p', [(9, 3), (9, 7)]), ('p', [(15, 3), (15, 7)]), ('r', 6, 7, 18, 12.5, 1.5),+ ('p', [(8.5, 12.5), (10, 16), (14, 16), (15.5, 12.5)]), ('p', [(12, 16), (12, 21)])],+ 'passport': [('r', 5.5, 3, 18.5, 21, 2), ('c', 12, 10.5, 3.2), ('p', [(9, 16.5), (15, 16.5)])],+ 'calendar': [('r', 4, 5, 20, 20, 2), ('p', [(4, 9.5), (20, 9.5)]), ('p', [(8, 3), (8, 6.5)]), ('p', [(16, 3), (16, 6.5)])],+ 'pin': [('a', 12, 10, 6, 150, 390), ('p', [(6.8, 13), (12, 21), (17.2, 13)]), ('c', 12, 10, 2.2)],+ 'sun': [('c', 12, 12, 4)] + [('p', [(12 + 6.5 * np.cos(a), 12 + 6.5 * np.sin(a)), (12 + 9 * np.cos(a), 12 + 9 * np.sin(a))])+ for a in np.arange(8) * np.pi / 4],+ 'bolt': [('p', [(13, 3), (6, 13.5), (12, 13.5), (11, 21), (18, 10.5), (12, 10.5)], True)],+ 'leaf': [('a', 12, 12, 8, 135, 315), ('a', 12, 12, 8, 315, 495), ('p', [(6.5, 17.5), (17.5, 6.5)])],+}+++def hexc(h):+ h = h.lstrip('#')+ return np.array([int(h[i:i + 2], 16) for i in (0, 2, 4)], np.float32) / 255+++def _c(c):+ if isinstance(c, str):+ return hexc(FIELDS[c][1]) if c in FIELDS else hexc(c)+ return np.asarray(c, np.float32)+++def ramp(t, stops):+ """colours along stops (hex or rgb; evenly spaced, or (pos, colour) pairs) -> t.shape + (3,)"""+ if isinstance(stops[0], tuple) and len(stops[0]) == 2 and not isinstance(stops[0][1], (int, float)):+ pos = np.array([p for p, _ in stops], np.float32); cols = np.stack([_c(c) for _, c in stops])+ else:+ cols = np.stack([_c(c) for c in stops]); pos = np.linspace(0, 1, len(cols)).astype(np.float32)+ t = np.clip(np.asarray(t, np.float32), 0, 1)+ return np.stack([np.interp(t, pos, cols[:, k]) for k in range(3)], -1).astype(np.float32)+++# ---------------------------------------------------------------- signed distances (negative inside)+def sdf_rrect(u, v, hw, hh, r):+ r = min(r, hw, hh)+ qx, qy = np.abs(u) - (hw - r), np.abs(v) - (hh - r)+ return np.hypot(np.maximum(qx, 0), np.maximum(qy, 0)) + np.minimum(np.maximum(qx, qy), 0) - r+++def sdf_segment(X, Y, a, b):+ ax, ay = float(a[0]), float(a[1]); bx, by = float(b[0]), float(b[1])+ dx, dy = bx - ax, by - ay+ l2 = dx * dx + dy * dy + 1e-9+ t = np.clip(((X - ax) * dx + (Y - ay) * dy) / l2, 0, 1)+ return np.hypot(X - (ax + t * dx), Y - (ay + t * dy))+++def sdf_polyline(X, Y, pts, closed=False):+ P = [tuple(p) for p in pts]+ if closed: P = P + [P[0]]+ d = np.full(np.broadcast(X, Y).shape, 1e9, np.float32)+ for a, b in zip(P[:-1], P[1:]):+ d = np.minimum(d, sdf_segment(X, Y, a, b))+ return d+++def smin(a, b, k):+ """smooth union of two distance fields (k px of fillet)"""+ h = np.clip(0.5 + 0.5 * (b - a) / k, 0, 1)+ return b * (1 - h) + a * h - k * h * (1 - h)+++def _cov(d):+ return np.clip(0.5 - d, 0, 1).astype(np.float32)+++def _arc_pts(cx, cy, r, a0, a1):+ n = max(6, int(abs(a1 - a0) / 9))+ t = np.deg2rad(np.linspace(a0, a1, n))+ return np.stack([cx + r * np.cos(t), cy + r * np.sin(t)], 1)+++# ---------------------------------------------------------------- fonts+_HERE_AD = '/System/Library/AssetsV2/com_apple_MobileAsset_Font*/*/AssetData/'+_CJK_FACES = [ # (glob, {weight: face index or file-name token}); first hit wins -- macOS, Linux, Windows+ (_HERE_AD + 'PingFang.ttc', {'regular': 3, 'medium': 7, 'bold': 11, 'heavy': 11}),+ ('/System/Library/Fonts/PingFang.ttc', {'regular': 3, 'medium': 7, 'bold': 11, 'heavy': 11}),+ ('/System/Library/Fonts/Hiragino Sans GB.ttc', {'regular': 0, 'medium': 0, 'bold': 2, 'heavy': 2}),+ ('/usr/share/fonts/**/NotoSansCJK*-{W}.tt[cf]', {'regular': 'Regular', 'medium': 'Medium', 'bold': 'Bold', 'heavy': 'Black'}),+ ('/usr/share/fonts/**/NotoSansSC-{W}.[ot]tf', {'regular': 'Regular', 'medium': 'Medium', 'bold': 'Bold', 'heavy': 'Black'}),+ ('C:/Windows/Fonts/msyh{W}.ttc', {'regular': '', 'medium': '', 'bold': 'bd', 'heavy': 'bd'}),+]+_HEAVY_FACES = [(_HERE_AD + 'Lantinghei.ttc', 2), ('/System/Library/Fonts/Lantinghei.ttc', 2)]+_LATIN_W = {'regular': 400, 'medium': 510, 'bold': 680, 'heavy': 860}+_MONO_W = {'regular': 420, 'medium': 520, 'bold': 680, 'heavy': 800}+_FONTS = {}+++def _find(pat):+ fs = sorted(glob.glob(pat, recursive=True))+ return fs[0] if fs else None+++def _truetype(path, size, idx):+ for i in ([idx, 0] if idx else [0]):+ try:+ return ImageFont.truetype(path, size, index=i)+ except OSError:+ continue+ return None+++def _cjk(weight, size):+ """-> (font, faux-bold stroke px)"""+ env = os.environ.get('INKPAINT_FONT_PASTELUI_HEAVY' if weight == 'heavy' else 'INKPAINT_FONT_PASTELUI_CJK')+ if env and os.path.exists(env):+ return ImageFont.truetype(env, size), 0+ if weight == 'heavy':+ for pat, idx in _HEAVY_FACES:+ p = _find(pat)+ f = p and _truetype(p, size, idx)+ if f: return f, 0+ for pat, faces in _CJK_FACES:+ tok = faces[weight]+ p = _find(pat.replace('{W}', tok)) if isinstance(tok, str) else _find(pat)+ if not p: continue+ f = _truetype(p, size, 2 if (isinstance(tok, str) and p.endswith('.ttc') and 'Noto' in p) else (tok if isinstance(tok, int) else 0))+ if f:+ fake = max(1, round(size / 46)) if weight == 'heavy' and not ('Black' in p) else 0+ return f, fake+ return load_font('cjk_sans', size), (max(1, round(size / 40)) if weight in ('bold', 'heavy') else 0)+++def _latin(weight, size, mono=False):+ env = os.environ.get('INKPAINT_FONT_PASTELUI_' + ('MONO' if mono else 'LATIN'))+ if env and os.path.exists(env):+ return ImageFont.truetype(env, size)+ p = '/System/Library/Fonts/SFNSMono.ttf' if mono else '/System/Library/Fonts/SFNS.ttf'+ if os.path.exists(p):+ try:+ f = ImageFont.truetype(p, size)+ if mono:+ w = _MONO_W[weight]; f.set_variation_by_axes([w, w])+ else:+ f.set_variation_by_axes([100, float(np.clip(size * 0.75, 17, 96)), 400, _LATIN_W[weight]])+ return f+ except (OSError, ValueError):+ pass+ if mono:+ for q, i in [('/System/Library/Fonts/Menlo.ttc', 1 if weight in ('bold', 'heavy') else 0),+ ('/usr/share/fonts/**/DejaVuSansMono*.ttf', 0), ('C:/Windows/Fonts/consola.ttf', 0)]:+ pp = _find(q)+ if pp:+ f = _truetype(pp, size, i)+ if f: return f+ return load_font('typewriter', size)+ if os.path.exists('/System/Library/Fonts/HelveticaNeue.ttc'):+ return ImageFont.truetype('/System/Library/Fonts/HelveticaNeue.ttc', size,+ index={'regular': 0, 'medium': 10, 'bold': 1, 'heavy': 1}[weight])+ return load_font('sans_bold' if weight in ('bold', 'heavy') else 'sans', size)+++def _font(kind, weight, size):+ key = (kind, weight, int(size))+ if key not in _FONTS:+ _FONTS[key] = _cjk(weight, int(size)) if kind == 'cjk' else (_latin(weight, int(size), kind == 'mono'), 0)+ return _FONTS[key]+++def _is_cjk(ch):+ return ord(ch) >= 0x2e80+++# ---------------------------------------------------------------- data holders+class Box:+ """a rectangle in canvas pixels (cards, windows, panes, chips)"""++ def __init__(self, x0, y0, x1, y1, r=0.0):+ self.x0, self.y0, self.x1, self.y1, self.r = x0, y0, x1, y1, r+ self.w, self.h = x1 - x0, y1 - y0+ self.cx, self.cy = (x0 + x1) / 2, (y0 + y1) / 2++ def __iter__(self):+ return iter((self.x0, self.y0, self.x1, self.y1))+++class Layer:+ def __init__(self, name, z, order, W, H):+ self.name, self.z, self.order = name, z, order+ self.rgb = np.zeros((H, W, 3), np.float32) # premultiplied+ self.a = np.zeros((H, W), np.float32)+ self.x0 = self.y0 = 0+ self.open = True+ self.lens = None+ self.pose = dict(dx=0.0, dy=0.0, scale=1.0, alpha=1.0, reveal=1.0, origin=None, feather=14.0)+++# ---------------------------------------------------------------- the canvas+class PastelUI:+ FIELDS = FIELDS+ GLYPHS = GLYPHS++ def __init__(self, W=1920, H=1080, seed=0, keep_stages=True):+ self.W, self.H = W, H+ self.seed = seed+ self.rng = np.random.default_rng(seed)+ self.keep_stages = keep_stages+ self.stages = []+ self.base = np.ones((H, W, 3), np.float32) * hexc(FIELDS['blue'][0])+ self.layers = {}+ self.cur = None+ self._clip = None+ self._wipe = None+ self.field_name = 'blue'+ self.accent, self.tint, self.mark_colour = BLUE, FIELDS['blue'][2], FIELDS['blue'][3]+ g = np.random.default_rng(seed + 7).random((H, W)).astype(np.float32)+ self._grain = (g - 0.5) * (1.2 / 255) # fixed sub-level dither: no banding in big soft glows++ # ------------------------------------------------------------ layers+ def layer(self, name, z=None):+ """start drawing into layer `name` (re-opens it if it exists). z: depth (default: creation order);+ lower z is further back -- a companion with a lower z than a card hides behind it"""+ self._close()+ if name in self.layers:+ L = self.layers[name]+ full_rgb = np.zeros((self.H, self.W, 3), np.float32); full_a = np.zeros((self.H, self.W), np.float32)+ h, w = L.a.shape+ full_rgb[L.y0:L.y0 + h, L.x0:L.x0 + w] = L.rgb; full_a[L.y0:L.y0 + h, L.x0:L.x0 + w] = L.a+ L.rgb, L.a, L.x0, L.y0, L.open = full_rgb, full_a, 0, 0, True+ if z is not None: L.z = z+ else:+ n = len(self.layers)+ L = Layer(name, n if z is None else z, n, self.W, self.H)+ self.layers[name] = L+ self.cur = L+ return name++ def end(self):+ """stop drawing into the current layer (later drawing goes onto the field)"""+ self._close()++ @staticmethod+ def _view(L):+ """(rgb, a, x0, y0) of what was drawn into L, cropped (a view while the layer is still open)"""+ if not L.open: return L.rgb, L.a, L.x0, L.y0+ rows = np.nonzero(L.a.max(1) > 0.5 / 255)[0]+ cols = np.nonzero(L.a.max(0) > 0.5 / 255)[0]+ if not len(cols): return L.rgb[:1, :1], L.a[:1, :1] * 0, 0, 0+ y0, y1, x0, x1 = rows[0], rows[-1] + 1, cols[0], cols[-1] + 1+ return L.rgb[y0:y1, x0:x1], L.a[y0:y1, x0:x1], int(x0), int(y0)++ def _close(self):+ L = self.cur+ self.cur = None+ if L is None or not L.open: return+ rgb, a, x0, y0 = self._view(L)+ L.rgb, L.a, L.x0, L.y0, L.open = rgb.copy(), a.copy(), x0, y0, False++ def pose(self, name, dx=0.0, dy=0.0, scale=1.0, alpha=1.0, reveal=1.0, origin=None, feather=14.0):+ """how layer `name` is shown: offset, scale about `origin` (default: its centre; a magnifier: the lens+ centre), opacity and a left-to-right reveal (0..1, soft edge `feather` px). pose(name) = drawn as is"""+ L = self.layers[name]+ if origin is None and L.lens: origin = L.lens[:2]+ L.pose = dict(dx=dx, dy=dy, scale=scale, alpha=alpha, reveal=reveal, origin=origin, feather=feather)++ def show(self, *names, alpha=1.0):+ for n in names: self.layers[n].pose['alpha'] = alpha++ def hide(self, *names):+ for n in names: self.layers[n].pose['alpha'] = 0.0++ def bounds(self, name):+ """(x0, y0, x1, y1) of what was drawn into layer `name`"""+ rgb, a, x0, y0 = self._view(self.layers[name])+ return x0, y0, x0 + a.shape[1], y0 + a.shape[0]++ @contextmanager+ def clip(self, x0, y0, x1, y1, r=0.0):+ """everything drawn inside is clipped to this rounded rectangle (pane fills inside a window body)"""+ old = self._clip+ self._clip = (x0, y0, x1, y1, r)+ try:+ yield+ finally:+ self._clip = old++ # ------------------------------------------------------------ low level+ def _grid(self, x0, y0, x1, y1):+ """clipped pixel box -> (slices, X (1, w), Y (h, 1)) with pixel centres at i + 0.5, or None"""+ x0, y0 = max(0, int(np.floor(x0))), max(0, int(np.floor(y0)))+ x1, y1 = min(self.W, int(np.ceil(x1)) + 1), min(self.H, int(np.ceil(y1)) + 1)+ if x1 <= x0 or y1 <= y0: return None+ X = np.arange(x0, x1, dtype=np.float32)[None, :] + 0.5+ Y = np.arange(y0, y1, dtype=np.float32)[:, None] + 0.5+ return (slice(y0, y1), slice(x0, x1)), X, Y++ def _over(self, sl, cov, col):+ """paint colour `col` (rgb, or an (h, w, 3) array) with coverage `cov` over the current target"""+ cov = np.clip(cov, 0, 1).astype(np.float32)+ if self._clip is not None:+ cx0, cy0, cx1, cy1, cr = self._clip+ X = np.arange(sl[1].start, sl[1].stop, dtype=np.float32)[None, :] + 0.5+ Y = np.arange(sl[0].start, sl[0].stop, dtype=np.float32)[:, None] + 0.5+ cov = cov * _cov(sdf_rrect(X - (cx0 + cx1) / 2, Y - (cy0 + cy1) / 2, (cx1 - cx0) / 2, (cy1 - cy0) / 2, cr))+ col = col if (isinstance(col, np.ndarray) and col.ndim == 3) else _c(col)+ c3 = cov[..., None]+ if self.cur is None:+ self.base[sl] = self.base[sl] * (1 - c3) + col * c3+ else:+ L = self.cur+ L.rgb[sl] = L.rgb[sl] * (1 - c3) + col * c3+ L.a[sl] = L.a[sl] * (1 - cov) + cov++ def _fill(self, sl, d, fill, alpha=1.0, grad=None, angle=180.0, box=None, X=None, Y=None):+ cov = _cov(d) * alpha+ if grad is not None:+ bx0, by0, bx1, by1 = box+ a = np.deg2rad(angle); ux, uy = np.sin(a), -np.cos(a) # CSS: 0deg = up, 90deg = right+ L = abs((bx1 - bx0) * ux) + abs((by1 - by0) * uy)+ t = ((X - (bx0 + bx1) / 2) * ux + (Y - (by0 + by1) / 2) * uy) / max(L, 1e-3) + 0.5+ self._over(sl, cov, ramp(np.broadcast_to(t, cov.shape), grad))+ else:+ self._over(sl, cov, fill)+ return cov++ # ------------------------------------------------------------ the field+ def field(self, colour='blue', glow=(520, 150), glow_size=(1200, 900), glow_alpha=0.62, bokeh=BOKEH, drift=(0, 0)):+ """the flat pastel field: a FIELDS name (sets the accent, shadow tint and marker colour) or a hex colour;+ one big soft pool of white light (top-left corner of its 1200 x 900 ellipse at `glow`) and bokeh discs"""+ if colour in FIELDS:+ bg, self.accent, self.tint, self.mark_colour = FIELDS[colour]+ self.field_name = colour+ else:+ bg = colour+ self.base[:] = hexc(bg)+ gx, gy = glow[0] + glow_size[0] / 2, glow[1] + glow_size[1] / 2+ rx, ry = glow_size[0] / 2, glow_size[1] / 2+ g = self._grid(gx - rx, gy - ry, gx + rx, gy + ry)+ if g:+ sl, X, Y = g+ t = np.hypot((X - gx) / rx, (Y - gy) / ry)+ a = glow_alpha * np.clip(1 - t, 0, 1) ** 1.15+ old, self.cur = self.cur, None+ self._over(sl, a, WHITE)+ self.cur = old+ old, self.cur = self.cur, None+ for (fx, fy, r, al) in (bokeh or ()):+ self.circle(fx * self.W + drift[0], fy * self.H + drift[1], r, WHITE, al)+ self.cur = old++ def wipe(self, cx=None, cy=None, r=0.0, prev='lilac', rim=None, rim_width=26.0):+ """circular colour wipe for the next stage(s): inside radius r everything shows, outside the previous+ field colour `prev`; a rim in `rim` (default: the accent) leads the edge. wipe() with no args clears it"""+ if cx is None:+ self._wipe = None+ else:+ pc = hexc(FIELDS[prev][0]) if prev in FIELDS else _c(prev)+ self._wipe = (cx, cy, r, pc, _c(rim or self.accent), rim_width)++ # ------------------------------------------------------------ shapes+ def rrect(self, x0, y0, x1, y1, r=0.0, fill=WHITE, alpha=1.0, grad=None, angle=180.0, ring=0.0, inset=True):+ """rounded rectangle; ring=w draws only a w px line along the edge (inside if inset, else outside)"""+ g = self._grid(x0 - ring - 2, y0 - ring - 2, x1 + ring + 2, y1 + ring + 2)+ if not g: return None+ sl, X, Y = g+ d = sdf_rrect(X - (x0 + x1) / 2, Y - (y0 + y1) / 2, (x1 - x0) / 2, (y1 - y0) / 2, r)+ if ring:+ d = np.abs(d + ring / 2) - ring / 2 if inset else np.abs(d - ring / 2) - ring / 2+ return self._fill(sl, d, fill, alpha, grad, angle, (x0, y0, x1, y1), X, Y)++ def circle(self, cx, cy, r, fill=WHITE, alpha=1.0, ring=0.0, grad=None, angle=180.0):+ """disc (or with ring=w a circular line w px wide, centred on radius r - w / 2)"""+ g = self._grid(cx - r - 2, cy - r - 2, cx + r + 2, cy + r + 2)+ if not g: return None+ sl, X, Y = g+ d = np.hypot(X - cx, Y - cy) - r+ if ring: d = np.abs(d + ring / 2) - ring / 2+ return self._fill(sl, d, fill, alpha, grad, angle, (cx - r, cy - r, cx + r, cy + r), X, Y)++ def line(self, pts, width=2.0, fill=INK, alpha=1.0, closed=False):+ """polyline with round caps and joins"""+ P = np.asarray(pts, np.float32)+ pad = width / 2 + 2+ g = self._grid(P[:, 0].min() - pad, P[:, 1].min() - pad, P[:, 0].max() + pad, P[:, 1].max() + pad)+ if not g: return None+ sl, X, Y = g+ return self._fill(sl, sdf_polyline(X, Y, P, closed) - width / 2, fill, alpha)++ def poly(self, pts, fill=INK, alpha=1.0, ss=4):+ """filled polygon, rasterised ss x and box-filtered"""+ P = np.asarray(pts, np.float32)+ x0, y0 = int(np.floor(P[:, 0].min())) - 1, int(np.floor(P[:, 1].min())) - 1+ x1, y1 = int(np.ceil(P[:, 0].max())) + 2, int(np.ceil(P[:, 1].max())) + 2+ im = Image.new('L', ((x1 - x0) * ss, (y1 - y0) * ss), 0)+ ImageDraw.Draw(im).polygon([((x - x0) * ss, (y - y0) * ss) for x, y in P.tolist()], fill=255)+ m = np.asarray(im.resize((x1 - x0, y1 - y0), Image.BOX), np.float32) / 255+ g = self._grid(x0, y0, x1 - 1, y1 - 1)+ if not g: return None+ sl = g[0]+ m = m[sl[0].start - y0:sl[0].stop - y0, sl[1].start - x0:sl[1].stop - x0]+ self._over(sl, m * alpha, fill)++ def shadow(self, x0, y0, x1, y1, r=0.0, dx=0.0, dy=0.0, blur_px=0.0, spread=0.0, colour='#000000', alpha=0.25,+ shape=None):+ """CSS box-shadow of a rounded rectangle (offset dx dy, blur radius blur_px, spread), painted only outside the+ element. shape=(cx, cy, r) casts the shadow of a disc instead"""+ sig = blur_px / 2+ pad = 3 * sig + abs(spread) + 3+ if shape is not None:+ cx, cy, rr = shape+ x0, y0, x1, y1 = cx - rr, cy - rr, cx + rr, cy + rr+ g = self._grid(min(x0, x0 + dx) - pad, min(y0, y0 + dy) - pad, max(x1, x1 + dx) + pad, max(y1, y1 + dy) + pad)+ if not g: return+ sl, X, Y = g+ if shape is not None:+ m = _cov(np.hypot(X - cx - dx, Y - cy - dy) - (rr + spread))+ own = _cov(np.hypot(X - cx, Y - cy) - rr)+ else:+ sx0, sy0, sx1, sy1 = x0 - spread + dx, y0 - spread + dy, x1 + spread + dx, y1 + spread + dy+ if sx1 <= sx0 or sy1 <= sy0: return+ m = _cov(sdf_rrect(X - (sx0 + sx1) / 2, Y - (sy0 + sy1) / 2, (sx1 - sx0) / 2, (sy1 - sy0) / 2, max(0.0, r + spread)))+ own = _cov(sdf_rrect(X - (x0 + x1) / 2, Y - (y0 + y1) / 2, (x1 - x0) / 2, (y1 - y0) / 2, r))+ if sig > 0.3: m = blur(m, sig)+ self._over(sl, m * (1 - own) * alpha, colour)++ def soft_shadow(self, cov_fn, box, dx=0.0, dy=3.0, blur_px=6.0, colour='#2a2080', alpha=0.35):+ """drop shadow that follows any shape (CSS filter: drop-shadow): cov_fn(X, Y) -> coverage"""+ sig = blur_px / 2+ pad = 3 * sig + 3+ g = self._grid(box[0] - pad + min(dx, 0), box[1] - pad + min(dy, 0), box[2] + pad + max(dx, 0), box[3] + pad + max(dy, 0))+ if not g: return+ sl, X, Y = g+ m = cov_fn(X - dx, Y - dy)+ if sig > 0.3: m = blur(m, sig)+ self._over(sl, m * alpha, colour)++ # ------------------------------------------------------------ text+ def _glyphs(self, s, size, weight, spacing, family):+ out, x = [], 0.0+ runs = []+ for ch in s:+ k = _is_cjk(ch)+ if runs and runs[-1][1] == k: runs[-1][0] += ch+ else: runs.append([ch, k])+ for piece, k in runs:+ f, fake = _font('cjk' if k else ('mono' if family == 'mono' else 'latin'), weight, size)+ if spacing:+ for ch in piece:+ out.append((f, ch, x, fake)); x += f.getlength(ch) + spacing+ else:+ out.append((f, piece, x, fake)); x += f.getlength(piece)+ return out, (x - spacing if (spacing and s) else x)++ def measure(self, s, size, weight='regular', spacing=0.0, family='sans'):+ """advance width of a string in px"""+ return self._glyphs(s, int(round(size)), weight, spacing, family)[1]++ def text(self, s, x, y, size, fill=INK, weight='regular', anchor='ls', alpha=1.0, spacing=0.0, family='sans'):+ """text (CJK / Latin runs split automatically). weight: regular / medium / bold / heavy; family: sans / mono.+ anchor: [l m r] + [s baseline, m middle of the CJK body, t top of the CJK body]. Returns the width"""+ size = int(round(size))+ gl, tw = self._glyphs(s, size, weight, spacing, family)+ x0 = x - tw * {'l': 0.0, 'm': 0.5, 'r': 1.0}[anchor[0]]+ base = y + {'s': 0.0, 'm': 0.37 * size, 't': 0.86 * size}[anchor[1]]+ bx0, by0 = int(np.floor(x0)) - 6, int(np.floor(base - size * 1.25))+ bw, bh = int(tw) + 14, int(size * 1.65) + 8+ im = Image.new('L', (bw, bh), 0)+ dr = ImageDraw.Draw(im)+ for f, piece, off, fake in gl:+ dr.text((x0 - bx0 + off, base - by0), piece, font=f, fill=255, anchor='ls', stroke_width=fake, stroke_fill=255)+ m = np.asarray(im, np.float32) / 255+ g = self._grid(bx0, by0, bx0 + bw - 1, by0 + bh - 1)+ if not g: return tw+ sl = g[0]+ m = m[sl[0].start - by0:sl[0].stop - by0, sl[1].start - bx0:sl[1].stop - bx0]+ self._over(sl, m * alpha, fill)+ return tw++ def marker(self, x0, x1, base, h=20.0, colour=None, alpha=0.85, drop=6.0, r=6.0):+ """a translucent marker stroke under words on baseline `base`: from base + drop - h to base + drop,+ 5 px wider than the words on each side"""+ self.rrect(x0 - 5, base + drop - h, x1 + 5, base + drop, r, colour or self.mark_colour, alpha)++ # ------------------------------------------------------------ icons+ def glyph(self, name, cx, cy, size=18, fill='#8a8a92', sw=1.7, rot=0.0):+ """a line icon from GLYPHS (24-unit grid, stroke sw in grid units), centred on (cx, cy)"""+ k = size / 24.0+ pad = size * 0.6 + 2+ g = self._grid(cx - pad, cy - pad, cx + pad, cy + pad)+ if not g: return+ sl, X, Y = g+ u, v = (X - cx) / k + 12, (Y - cy) / k + 12+ if rot:+ c, s = np.cos(np.deg2rad(rot)), np.sin(np.deg2rad(rot))+ u, v = (u - 12) * c + (v - 12) * s + 12, -(u - 12) * s + (v - 12) * c + 12+ d = np.full(np.broadcast(u, v).shape, 1e9, np.float32)+ for p in GLYPHS[name]:+ kind = p[0]+ if kind == 'p':+ e = sdf_polyline(u, v, p[1], len(p) > 2 and p[2]) - sw / 2+ elif kind == 'c':+ e = np.abs(np.hypot(u - p[1], v - p[2]) - p[3]) - sw / 2+ elif kind == 'a':+ e = sdf_polyline(u, v, _arc_pts(*p[1:])) - sw / 2+ elif kind == 'd':+ e = np.hypot(u - p[1], v - p[2]) - p[3]+ else: # 'r'+ x0, y0, x1, y1, rr = p[1:]+ e = np.abs(sdf_rrect(u - (x0 + x1) / 2, v - (y0 + y1) / 2, (x1 - x0) / 2, (y1 - y0) / 2, rr)) - sw / 2+ d = np.minimum(d, e)+ self._over(sl, _cov(d * k), fill)++ def tile(self, x, y, size=46, fill=None, glyph=None, radius=None, grad=None, glyph_size=None, sw=2.1, shadow=True):+ """an app-icon tile (rounded square) with a white line icon; grad=(c0, c1) for a 140deg gradient"""+ fill = fill or self.accent+ r = size * 0.3 if radius is None else radius+ if shadow:+ self.shadow(x, y, x + size, y + size, r, 0, size * 0.17, size * 0.35, -size * 0.17, grad[1] if grad else fill, 0.9)+ self.rrect(x, y, x + size, y + size, r, fill, grad=grad, angle=140)+ if glyph:+ self.glyph(glyph, x + size / 2, y + size / 2, glyph_size or size * 0.52, WHITE, sw)++ def avatar(self, cx, cy, r=21, glyph='user', fill='#dcebfb', colour='#4f86c0'):+ self.circle(cx, cy, r, fill)+ self.glyph(glyph, cx, cy, r * 1.05, colour, 2.0)++ def weather(self, kind, cx, cy, size=44):+ """flat weather icon: sun, cloud, partly (sun behind a cloud), rain"""+ k = size / 44.0+ if kind in ('sun', 'partly'):+ sx, sy = (cx, cy) if kind == 'sun' else (cx + 7 * k, cy - 6 * k)+ r = (11 if kind == 'sun' else 9) * k+ for a in np.arange(8) * np.pi / 4:+ self.line([(sx + (r + 4.5 * k) * np.cos(a), sy + (r + 4.5 * k) * np.sin(a)),+ (sx + (r + 9 * k) * np.cos(a), sy + (r + 9 * k) * np.sin(a))], 3.2 * k, '#ffbf2e')+ self.circle(sx, sy, r, '#ffc93d')+ if kind in ('cloud', 'partly', 'rain'):+ oy = 3 * k if kind == 'partly' else (-3 * k if kind == 'rain' else 0)+ ox = -3 * k if kind == 'partly' else 0+ col = {'cloud': '#c9d8ea', 'partly': '#d9e5f2', 'rain': '#aebfd6'}[kind]+ g = self._grid(cx - 24 * k, cy - 20 * k, cx + 24 * k, cy + 22 * k)+ sl, X, Y = g+ u, v = (X - cx - ox) / k, (Y - cy - oy) / k+ d = np.hypot(u + 7, v - 2) - 9+ d = smin(d, np.hypot(u - 2, v + 3) - 11, 3)+ d = smin(d, np.hypot(u - 11, v - 3) - 8, 3)+ d = smin(d, sdf_rrect(u - 2, v - 6, 18, 5, 5), 2)+ self._over(sl, _cov(d * k), col)+ if kind == 'rain':+ for i, dx_ in enumerate((-9, 0, 9)):+ x0_, y0_ = cx + (dx_ + 2) * k, cy + 13 * k + (i % 2) * 3 * k+ self.line([(x0_, y0_), (x0_ - 2.5 * k, y0_ + 7 * k)], 3.6 * k, '#3d9bf0')++ # ------------------------------------------------------------ UI parts+ def lights(self, x, cy, d=13, gap=9):+ """the red / yellow / green window buttons, first one's left edge at x"""+ for i, c in enumerate(LIGHTS):+ px = x + d / 2 + i * (d + gap)+ self.circle(px, cy, d / 2, c)+ self.circle(px, cy, d / 2, '#000000', 0.18, ring=0.6)++ def window(self, x, y, w, h, title='', icon='inbox', icon_fill=None, sub='', split=None, bar=50, radius=22, rim=9,+ tint=None):+ """a macOS window card: frosted rim, layered shadows, white body, title bar with lights and a centred+ title (app icon + bold title + mono sub), optional pale left pane `split` px wide.+ Returns a Box with .bar (y of the title bar's bottom), .left and .right (pane Boxes)"""+ tint = tint or self.tint+ X0, Y0, X1, Y1, R = x - rim, y - rim, x + w + rim, y + h + rim, radius + rim - 1+ self.shadow(X0, Y0, X1, Y1, R, 0, 50, 90, -30, tint, 0.30)+ self.shadow(X0, Y0, X1, Y1, R, 0, 16, 40, -18, '#1e3250', 0.22)+ self.rrect(X0, Y0, X1, Y1, R, WHITE, 0.55)+ self.rrect(X0, Y0, X1, Y1, R, WHITE, 0.7, ring=1.0)+ self.rrect(x, y, x + w, y + h, radius, '#141e32', 0.08, ring=1.0, inset=False)+ self.rrect(x, y, x + w, y + h, radius, WHITE)+ with self.clip(x, y, x + w, y + h, radius):+ self.rrect(x, y, x + w, y + bar, 0, '#f6f8fa')+ self.rrect(x, y + bar - 1, x + w, y + bar, 0, LINE)+ if split:+ self.rrect(x, y + bar, x + split, y + h, 0, PANE)+ self.rrect(x + split - 1, y + bar, x + split, y + h, 0, LINE)+ self.lights(x + 20, y + bar / 2)+ if title:+ tw = self.measure(title, 16, 'bold')+ sw_ = self.measure(sub, 14, 'regular', family='mono') if sub else 0+ total = (20 + 10 if icon else 0) + tw + (10 + sw_ if sub else 0)+ tx = x + w / 2 - total / 2+ if icon:+ self.tile(tx, y + bar / 2 - 10, 20, icon_fill or self.accent, icon, radius=6, glyph_size=13, sw=2.2, shadow=False)+ tx += 30+ self.text(title, tx, y + bar / 2, 16, '#5a6472', 'bold', 'lm')+ if sub:+ self.text(sub, tx + tw + 10, y + bar / 2, 14, '#9aa3af', 'regular', 'lm', family='mono')+ self.glyph('more', x + w - 29, y + bar / 2, 18, '#8a8a92', 1.7)+ b = Box(x, y, x + w, y + h, radius)+ b.bar = y + bar+ b.left = Box(x, y + bar, x + split, y + h) if split else None+ b.right = Box(x + (split or 0), y + bar, x + w, y + h)+ return b++ def card(self, x, y, w, h, r=26, tint=None, fill=WHITE):+ """a floating white panel: hairline ring, a wide shadow tinted with the field colour, a tight key shadow"""+ tint = tint or self.tint+ self.shadow(x, y, x + w, y + h, r, 0, 40, 80, -34, tint, 0.45)+ self.shadow(x, y, x + w, y + h, r, 0, 12, 30, -16, '#142850', 0.2)+ self.rrect(x, y, x + w, y + h, r, '#142850', 0.07, ring=1.0, inset=False)+ self.rrect(x, y, x + w, y + h, r, fill)+ return Box(x, y, x + w, y + h, r)++ def pill(self, x, cy, text, dot=None, size=21):+ """the section pill: white 72 % capsule with a coloured dot (and its halo). Returns the right edge"""+ dot = dot or self.accent+ tw = self.measure(text, size, 'bold', spacing=1)+ h = size * 1.5 + 18+ x1 = x + 15 + 10 + 12 + tw + 20+ y0, y1 = cy - h / 2, cy + h / 2+ self.shadow(x, y0, x1, y1, h / 2, 0, 6, 18, -10, '#143c78', 0.25)+ self.rrect(x, y0, x1, y1, h / 2, '#000000', 0.05, ring=1.0, inset=False)+ self.rrect(x, y0, x1, y1, h / 2, WHITE, 0.72)+ self.circle(x + 20, cy, 9, dot, 0.2)+ self.circle(x + 20, cy, 5, dot)+ self.text(text, x + 37, cy, size, '#2a2a30', 'bold', 'lm', spacing=1)+ return x1++ def steps(self, x, cy, labels, lit=0, current=None, size=19, accent=None):+ """a row of step chips joined by arrows; the first `lit` are filled with the accent, `current` gets a+ halo. Returns the right edge"""+ accent = accent or self.accent+ for i, s in enumerate(labels):+ on = i < lit+ if i:+ col = accent if on else '#9fbbd6'+ self.line([(x + 1, cy), (x + 18, cy)], 2.2, col)+ self.line([(x + 13, cy - 5), (x + 18, cy), (x + 13, cy + 5)], 2.2, col)+ x += 22 + 8+ tw = self.measure(s, size, 'bold')+ h = size * 1.5 + 14+ x1 = x + tw + 32+ y0, y1 = cy - h / 2, cy + h / 2+ if on:+ if i == current:+ self.rrect(x - 5, y0 - 5, x1 + 5, y1 + 5, h / 2 + 5, accent, 0.22)+ self.shadow(x, y0, x1, y1, h / 2, 0, 8, 16, -10, accent, 0.8)+ self.rrect(x, y0, x1, y1, h / 2, accent)+ self.text(s, x + 16, cy, size, WHITE, 'bold', 'lm')+ else:+ self.rrect(x, y0, x1, y1, h / 2, WHITE, 0.8, ring=1.0, inset=False)+ self.rrect(x, y0, x1, y1, h / 2, WHITE, 0.55)+ self.text(s, x + 16, cy, size, '#7a8ea4', 'bold', 'lm')+ x = x1 + 8+ return x - 8++ def headline(self, x, base, text, size=62, fill=INK, mark=None, mark_colour=None, mark_h=None, spacing=1.0,+ draw_text=True, draw_mark=True):+ """heavy headline on baseline `base`; `mark` = the substring that gets a marker stroke under it.+ Returns (width, (mark_x0, mark_x1) or None) -- with draw_text / draw_mark you can put the marker and the+ words in different layers (the marker goes in the layer behind)"""+ span = None+ if mark and mark in text:+ i = text.index(mark)+ mx0 = x + self.measure(text[:i], size, 'heavy', spacing) + (spacing if i else 0)+ mx1 = mx0 + self.measure(mark, size, 'heavy', spacing)+ span = (mx0, mx1)+ if draw_mark:+ self.marker(mx0, mx1, base, mark_h or size * 0.32, mark_colour, 0.9, drop=size * 0.1)+ w = self.measure(text, size, 'heavy', spacing)+ if draw_text:+ self.text(text, x, base, size, fill, 'heavy', 'ls', spacing=spacing)+ return w, span++ def chip(self, x, cy, text, colour=None, size=15, solid=False, glyph=None, anchor='l', pad=11, family='sans'):+ """status chip: a capsule tinted 10 % with a 25 % ring and bold coloured text, or solid with white text and a+ coloured glow. anchor 'l' / 'r' / 'm' on x. Returns its Box"""+ colour = colour or self.accent+ tw = self.measure(text, size, 'bold', family=family)+ gw = size * 1.15 + 6 if glyph else 0+ w = tw + gw + 2 * pad+ h = size * 1.45 + 8+ x0 = x - w * {'l': 0, 'm': 0.5, 'r': 1}[anchor]+ x1, y0, y1 = x0 + w, cy - h / 2, cy + h / 2+ if solid:+ self.shadow(x0, y0, x1, y1, h / 2, 0, 8, 16, -8, colour, 0.9)+ self.rrect(x0, y0, x1, y1, h / 2, colour)+ fg = WHITE+ else:+ self.rrect(x0, y0, x1, y1, h / 2, colour, 0.10)+ self.rrect(x0, y0, x1, y1, h / 2, colour, 0.25, ring=1.0)+ fg = colour+ tx = x0 + pad+ if glyph:+ self.glyph(glyph, tx + size * 0.55, cy, size * 1.1, fg, 3.0 if glyph in ('x', 'check') else 2.2)+ tx += gw+ self.text(text, tx, cy, size, fg, 'bold', 'lm', family=family)+ return Box(x0, y0, x1, y1, h / 2)++ def mono_tag(self, x1, cy, text, size=13):+ """a small grey mono tag (GRADERS, #0412...) right-aligned at x1"""+ tw = self.measure(text, size, 'bold', spacing=1.5, family='mono')+ self.rrect(x1 - tw - 20, cy - size, x1, cy + size, 8, '#f2f4f7')+ self.text(text, x1 - 10, cy, size, '#8a94a3', 'bold', 'rm', spacing=1.5, family='mono')++ def callout(self, x, cy, text, colour=None, glyph=None, size=17):+ """solid pill with a pointer on its left (points at x): a verdict tag next to a highlighted line"""+ colour = colour or PINK+ self.poly([(x, cy), (x + 9, cy - 7.5), (x + 9, cy + 7.5)], colour)+ b = self.chip(x + 8, cy, text, colour, size, solid=True, glyph=glyph, pad=12)+ return b++ def ref_chip(self, x, base, text, glyph='book', colour='#1774c9', ok=True, size=22):+ """an inline reference chip sitting on a text line (baseline `base`), with a green check bubble if ok.+ Returns the right edge"""+ tw = self.measure(text, size, 'bold')+ h = size * 1.55+ x0, x1 = x, x + 11 + size * 0.8 + 6 + tw + 11+ y1 = base + size * 0.22+ y0 = y1 - h+ if ok:+ self.rrect(x0, y0, x1, y1, 9, GREEN, 1.0, ring=2.5, inset=False)+ self.rrect(x0, y0, x1, y1, 9, '#e7f2fe')+ self.rrect(x0, y0, x1, y1, 9, BLUE, 0.25, ring=1.0)+ self.glyph(glyph, x0 + 11 + size * 0.4, (y0 + y1) / 2, size * 0.8, colour, 2.0)+ self.text(text, x0 + 11 + size * 0.8 + 6, (y0 + y1) / 2, size, colour, 'bold', 'lm')+ if ok:+ self.circle(x1, y0, 13.5, WHITE)+ self.circle(x1, y0, 11, GREEN)+ self.glyph('check', x1, y0, 14, WHITE, 3.2)+ return x1++ def badge(self, cx, cy, kind='pass', size=30):+ """round badge: green disc with a white check, or pink with a white cross"""+ c = GREEN if kind == 'pass' else PINK+ self.shadow(0, 0, 0, 0, 0, 0, 6, 14, -6, c, 0.9, shape=(cx, cy, size / 2))+ self.circle(cx, cy, size / 2, c)+ self.glyph('check' if kind == 'pass' else 'x', cx, cy, size * 0.62, WHITE, 3.2)++ def spinner(self, cx, cy, size=22, colour=None, angle=0.0):+ colour = colour or LILAC+ r = size * 7.5 / 20+ self.circle(cx, cy, r + 1.3, colour, 0.2, ring=2.6)+ pts = _arc_pts(cx, cy, r, angle - 90, angle)+ self.line(pts, 2.6 * size / 20, colour)++ def bar(self, x0, x1, cy, frac, colour=None, h=6):+ """progress bar: tinted track and a filled part"""+ colour = colour or self.accent+ self.rrect(x0, cy - h / 2, x1, cy + h / 2, h / 2, colour, 0.15)+ if frac > 0:+ self.rrect(x0, cy - h / 2, x0 + (x1 - x0) * frac, cy + h / 2, h / 2, colour)++ def check_row(self, x, y, w, h=94, label='', tag=None, sub=None, glyph='code', tone=None, state='idle',+ result=None, status=True, progress=0.6):+ """a checklist row (rounded 18): icon tile, bold label + tag chip, grey question underneath, status on the+ right. state: idle (white, dashed ring, 待检查) / active (tone ring + glow, spinner, progress bar) /+ pass (green tint, check badge) / fail (pink tint, cross badge). status=False leaves the right side empty+ (draw it in another layer with row_status). Returns the status anchor (x1, cy)"""+ tone = tone or self.accent+ x1, y1, cy = x + w, y + h, y + h / 2+ if state == 'pass':+ self.rrect(x, y, x1, y1, 18, '#effaf3'); self.rrect(x, y, x1, y1, 18, '#bfe8cc', ring=1.5)+ elif state == 'fail':+ self.rrect(x, y, x1, y1, 18, '#fff1f6'); self.rrect(x, y, x1, y1, 18, '#f9c0d5', ring=1.5)+ elif state == 'active':+ self.shadow(x, y, x1, y1, 18, 0, 14, 26, -16, tone, 1.0)+ self.rrect(x, y, x1, y1, 18, WHITE)+ self.rrect(x, y, x1, y1, 18, tone, 0.05)+ self.rrect(x, y, x1, y1, 18, tone, ring=2.0)+ else:+ self.rrect(x, y, x1, y1, 18, WHITE); self.rrect(x, y, x1, y1, 18, LINE, ring=1.0)+ ts = h * 0.49+ self.tile(x + 18, cy - ts / 2, ts, tone, glyph, glyph_size=ts * 0.52)+ tx = x + 18 + ts + 15+ ls = h * 0.27+ lw = self.text(label, tx, cy - h * 0.035, ls, '#18202b', 'heavy')+ if tag:+ self.chip(tx + lw + 10, cy - h * 0.035 - ls * 0.37, tag, tone, size=h * 0.14, pad=9)+ if sub:+ self.text(sub, tx, cy + h * 0.29, h * 0.175, '#7c8694')+ if state == 'active' and progress is not None:+ self.bar(x + 18, x1 - 18, y1 - 10, progress, tone, 4)+ if status:+ self.row_status(x1 - 18, cy, state, result, tone, h)+ return x1 - 18, cy++ def row_status(self, x1, cy, state='pass', text=None, tone=None, h=94):+ """the right end of a check row, right-aligned at x1: badge + 通过 / 不通过, spinner + 检查中, or 待检查"""+ tone = tone or self.accent+ fs = h * 0.18+ if state in ('pass', 'fail'):+ text = text or ('通过' if state == 'pass' else '不通过')+ col = GREEN if state == 'pass' else PINK+ tw = self.text(text, x1, cy, fs, col, 'bold', 'rm')+ self.badge(x1 - tw - 8 - 15 * h / 94, cy, state, 30 * h / 94)+ elif state == 'active':+ tw = self.text(text or '检查中', x1, cy, fs * 0.95, tone, 'bold', 'rm')+ self.spinner(x1 - tw - 8 - 11, cy, 22, tone, 120)+ else:+ tw = self.text(text or '待检查', x1, cy, fs * 0.95, '#a3acb8', 'regular', 'rm')+ for a in range(0, 360, 30):+ p = _arc_pts(x1 - tw - 8 - 12, cy, 11, a, a + 16)+ self.line(p, 2, '#c6cfda')++ # ------------------------------------------------------------ magnifier+ def magnifier(self, cx, cy, r=52, mag=1.32, colour=None, name='lens', z=None, handle=45.0):+ """a lens in its own layer: it magnifies the real pixels under it when composited (move it with pose:+ the view follows), with a white rim, a violet handle toward `handle` degrees and a glint"""+ colour = colour or LILAC+ prev = self.cur.name if self.cur is not None else None+ self.layer(name, z)+ a = np.deg2rad(handle); ux, uy = np.cos(a), np.sin(a)+ p0 = (cx + ux * (r + 6), cy + uy * (r + 6)); p1 = (cx + ux * (r + 62), cy + uy * (r + 62))+ g = self._grid(min(p0[0], p1[0]) - 30, min(p0[1], p1[1]) - 30, max(p0[0], p1[0]) + 30, max(p0[1], p1[1]) + 34)+ sl, X, Y = g+ d = sdf_segment(X, Y, p0, p1) - 9+ self.soft_shadow(lambda XX, YY: _cov(sdf_segment(XX, YY, p0, p1) - 9), (p0[0] - 12, p0[1] - 12, p1[0] + 12, p1[1] + 12),+ 0, 10, 18, '#3c1e78', 0.4)+ t = ((X - cx) * (-uy) + (Y - cy) * ux) / 18 + 0.5 # across the handle+ self._over(sl, _cov(d), ramp(np.broadcast_to(t, d.shape), ('#7442d0', '#9a6cf2')))+ self.shadow(0, 0, 0, 0, 0, 0, 18, 30, -12, '#3c1e78', 0.45, shape=(cx, cy, r + 7))+ self.circle(cx, cy, r + 8.5, colour, 0.6, ring=1.5)+ self.circle(cx, cy, r + 7, WHITE, ring=7)+ self.circle(cx, cy, r, colour, 0.35, ring=1.5)+ gg = self._grid(cx - r, cy - r, cx + r, cy + r)+ sl, X, Y = gg+ rad = np.hypot(X - cx, Y - cy) / r+ self._over(sl, np.clip((rad - 0.62) / 0.38, 0, 1) * 0.10 * _cov(np.hypot(X - cx, Y - cy) - r), colour)+ gx, gy = cx - 0.6 * r, cy - 0.6 * r+ b = np.deg2rad(42); vx, vy = np.sin(b), -np.cos(b)+ self.line([(gx - vx * r * 0.18, gy - vy * r * 0.18), (gx + vx * r * 0.18, gy + vy * r * 0.18)], r * 0.13, WHITE, 0.55)+ L = self.layers[name]+ L.lens = (cx, cy, r, mag)+ L.pose['origin'] = (cx, cy)+ self._close()+ if prev is not None: self.layer(prev)+ return name++ # ------------------------------------------------------------ companions+ def spark(self, cx, cy, size=124, spin=0.0, colour=CLAY):+ """starburst in a cream circle with a white ring and a warm shadow (spin: degrees)"""+ r = size / 2+ self.shadow(0, 0, 0, 0, 0, 0, 16, 30, -14, '#783c1e', 0.45, shape=(cx, cy, r))+ self.circle(cx, cy, r + 5, WHITE)+ self.circle(cx, cy, r, '#fbf4ec')+ k = size * 0.66 / 100+ g = self._grid(cx - 46 * k, cy - 46 * k, cx + 46 * k, cy + 46 * k)+ sl, X, Y = g+ d = np.hypot(X - cx, Y - cy) - 9 * k+ for a, l in RAYS:+ t = np.deg2rad(a + spin)+ tip = (cx + np.sin(t) * 40 * l * k, cy - np.cos(t) * 40 * l * k)+ d = np.minimum(d, sdf_segment(X, Y, (cx, cy), tip) - 5.5 * k)+ self._over(sl, _cov(d), colour)++ def cloud(self, cx, cy, size=118, rot=0.0):+ """violet puffy cloud with a white >_ prompt: radial gradient, soft drop shadow, a gloss highlight"""+ k = size / 100+ bumps = [(50, 50, 33)] + [(50 + 31 * np.cos(t), 52 + 31 * np.sin(t), 15 + 2.5 * np.sin(3 * t + 1))+ for t in np.linspace(-np.pi / 2, 1.5 * np.pi, 10, endpoint=False)]+ c, s = np.cos(np.deg2rad(rot)), np.sin(np.deg2rad(rot))++ def dist(X, Y):+ u, v = (X - cx) / k, (Y - cy) / k+ u, v = u * c + v * s + 50, -u * s + v * c + 50+ d = np.full(np.broadcast(u, v).shape, 1e9, np.float32)+ for bx, by, br in bumps:+ d = smin(d, np.hypot(u - bx, v - by) - br, 4.0)+ return d * k, u, v++ box = (cx - 52 * k, cy - 52 * k, cx + 52 * k, cy + 52 * k)+ self.soft_shadow(lambda X, Y: _cov(dist(X, Y)[0]), box, 0, 3 * k, 6 * k, '#2a2080', 0.35)+ g = self._grid(*box)+ sl, X, Y = g+ d, u, v = dist(X, Y)+ t = np.hypot(u - 35, v - 28) / 80+ self._over(sl, _cov(d), ramp(t, [(0.0, '#9a90ff'), (0.55, '#6b5cff'), (1.0, '#3f33c4')]))+ hl = _cov((np.hypot((u - 38) / 16, (v - 28) / 8) - 1) * 8 * k) * _cov(d)+ self._over(sl, hl * 0.22, WHITE)+ P = lambda q: (cx + ((q[0] - 50) * c - (q[1] - 50) * s) * k, cy + ((q[0] - 50) * s + (q[1] - 50) * c) * k)+ self.line([P((30, 40)), P((44, 52)), P((30, 64))], 8 * k, WHITE)+ self.line([P((52, 66)), P((70, 66))], 8 * k, WHITE)++ def critter(self, x, y, px=9, colour=CLAY, eye=PIXINK, blink=False):+ """the orange pixel critter (10 x 6 cells of px), top-left at (x, y); blink closes the eyes"""+ x, y = round(x), round(y)+ for j, row in enumerate(CRITTER):+ for i, ch in enumerate(row):+ if ch == '.': continue+ x0, y0 = x + i * px, y + j * px+ if ch == 'o':+ self.rrect(x0, y0, x0 + px, y0 + px, 0, colour if blink else eye)+ if blink: self.rrect(x0, y0 + px * 0.6, x0 + px, y0 + px, 0, eye)+ else:+ self.rrect(x0, y0, x0 + px, y0 + px, 0, colour)++ # ------------------------------------------------------------ compositing+ def _posed(self, L):+ """-> (rgb, a, x0, y0) of layer L under its pose (scale about origin, offset, reveal)"""+ p = L.pose+ rgb, a, lx0, ly0 = self._view(L)+ h, w = a.shape+ x0, y0 = float(lx0), float(ly0)+ s = p['scale']+ if abs(s - 1) > 1e-4:+ ox, oy = p['origin'] or (lx0 + w / 2, ly0 + h / 2)+ nw, nh = max(1, int(round(w * s))), max(1, int(round(h * s)))+ rs = lambda ch: np.asarray(Image.fromarray(np.ascontiguousarray(ch), 'F').resize((nw, nh), Image.BILINEAR), np.float32)+ rgb = np.stack([rs(rgb[..., k]) for k in range(3)], -1)+ a = rs(a)+ x0, y0 = ox + (x0 - ox) * s, oy + (y0 - oy) * s+ w, h = nw, nh+ if p['reveal'] < 1:+ cut = w * p['reveal']+ xs = np.arange(w, dtype=np.float32)+ m = np.clip((cut - xs) / max(p['feather'], 1) + 0.5, 0, 1) if p['reveal'] > 0 else np.zeros(w, np.float32)+ rgb = rgb * m[None, :, None]; a = a * m[None, :]+ return rgb, a, int(round(x0 + p['dx'])), int(round(y0 + p['dy']))++ def _magnify(self, out, cx, cy, r, mag, alpha):+ g = self._grid(cx - r - 1, cy - r - 1, cx + r + 1, cy + r + 1)+ if not g: return+ sl, X, Y = g+ sx = cx + (X - cx) / mag - 0.5+ sy = cy + (Y - cy) / mag - 0.5+ sx = np.clip(np.broadcast_to(sx, (Y.shape[0], X.shape[1])), 0, self.W - 1.001)+ sy = np.clip(np.broadcast_to(sy, (Y.shape[0], X.shape[1])), 0, self.H - 1.001)+ x0, y0 = sx.astype(np.int32), sy.astype(np.int32)+ fx, fy = (sx - x0)[..., None], (sy - y0)[..., None]+ v = (out[y0, x0] * (1 - fx) + out[y0, x0 + 1] * fx) * (1 - fy) + (out[y0 + 1, x0] * (1 - fx) + out[y0 + 1, x0 + 1] * fx) * fy+ m = (_cov(np.hypot(X - cx, Y - cy) - r) * alpha)[..., None]+ out[sl] = out[sl] * (1 - m) + v * m++ def render(self):+ """composite the field and every layer under its current pose -> float RGB"""+ out = self.base.copy()+ for L in sorted(self.layers.values(), key=lambda q: (q.z, q.order)):+ al = L.pose['alpha']+ if al <= 0: continue+ rgb, a, x0, y0 = self._posed(L)+ if L.lens:+ cx, cy, r, mag = L.lens+ s = L.pose['scale']+ self._magnify(out, cx + L.pose['dx'], cy + L.pose['dy'], r * s, mag, al)+ h, w = a.shape+ X0, Y0 = max(0, x0), max(0, y0)+ X1, Y1 = min(self.W, x0 + w), min(self.H, y0 + h)+ if X1 <= X0 or Y1 <= Y0: continue+ cr = rgb[Y0 - y0:Y1 - y0, X0 - x0:X1 - x0]; ca = a[Y0 - y0:Y1 - y0, X0 - x0:X1 - x0]+ out[Y0:Y1, X0:X1] = out[Y0:Y1, X0:X1] * (1 - ca[..., None] * al) + cr * al+ if self._wipe:+ cx, cy, r, pc, rc, rw = self._wipe+ Y = np.arange(self.H, dtype=np.float32)[:, None] + 0.5+ X = np.arange(self.W, dtype=np.float32)[None, :] + 0.5+ d = np.hypot(X - cx, Y - cy)+ inside = _cov(d - r)[..., None]+ out = out * inside + pc * (1 - inside)+ ring = _cov(np.abs(d - r + rw / 2) - rw / 2)[..., None] * 0.9+ out = out * (1 - ring) + rc * ring+ return out++ def composite(self):+ I = self.render() + self._grain[..., None]+ return Image.fromarray((np.clip(I, 0, 1) * 255 + 0.5).astype(np.uint8))++ def stage(self, name):+ """snapshot the current poses (kept PNG-compressed in memory: a draw-on sequence has 80+ of them)"""+ if self.keep_stages:+ buf = io.BytesIO()+ self.composite().save(buf, 'PNG', compress_level=1)+ self.stages.append((name, buf.getvalue()))++ def save(self, path, stages_dir=None, quality=88):+ self._close()+ img = self.composite()+ if str(path).lower().endswith(('.jpg', '.jpeg')): img.save(path, quality=quality, subsampling=0)+ else: img.save(path)+ if stages_dir:+ os.makedirs(stages_dir, exist_ok=True)+ for i, (name, png) in enumerate(self.stages):+ with open(f'{stages_dir}/{i:02d}_{name}.png', 'wb') as fh:+ fh.write(png)+ img.save(f'{stages_dir}/{len(self.stages):02d}_final.png')+ return img