Community影像github.com

程式畫室

用程式畫靜幀:路徑追蹤、水彩、漫畫、版畫和字體海報,不呼叫生圖模型。

程式畫室 是什麼?

這是一間以程式作畫的工作室。選定畫風,寫一段短場景腳本,自己渲出 PNG:人物、風景、標題字、像素畫或生成式抽象。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Wexop/atelier/tree/HEAD

Installed? Explore more 影像 skills: steipete/songsee, affaan-m/frontend-design, mattpocock/improve-codebase-architecture · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

atelier — 由簡短 Python 腳本驅動的影像工作室

安裝(Python ≥ 3.11):pip install git+https://github.com/Wexop/atelier(更新:pip install -U git+...) 檢查:atelier palette · atelier brushes · atelier fx(簽名)。

循環(始終)

  1. 選擇風格指南(見下方的風格),並閱讀它;沒有合適的 → styles/new-style.md。
  2. 撰寫 scene.py(30–80 行,from atelier import *,建構 Canvas c,以 c.save(__file__[:-3] + ".png") 結尾)。
  3. atelier render scene.py --preview → scene_prev.jpg(512 像素,真實低解析度渲染,略過儲存)。檢視影像。
  4. atelier inspect scene.py → scene_sheet.jpg:檢視、5 階調研究 + 三分/焦點、剪裁映射圖、直方圖、調色盤、4 個自動放大 (鋸齒、條紋、雜訊、高光)標記為 --crop x,y,w,h、度量 + 紅旗。檢視它。 放大:atelier render scene.py --crop x,y,w,h。
  5. ≥3 次檢視與修正回合(atelier compare old.png new.png 進行 A/B 比較),然後 atelier render scene.py(最終版;--scale 2、--seed N → SEED)。 錯誤只會輸出一行 scene.py:LINE: Type: message(--debug 會印出追溯)。

慣例

  • 繪圖座標 = 畫布像素(y 向下)。欄位使用標準化的 x, y ∈ [0,1]。顏色:"#hex"、CSS 名稱、(r,g,b) 0–1 或 0–255。
  • 繪圖來源(fill=、color=、stroke=)= 顏色 | 欄位 | f(x,y) | 陣列 H×W×3/4。遮罩 = 欄位 | 形狀 | 陣列 | f(x,y)。
  • 所有隨機內容都需要 seed=。預覽以低解析度渲染:圖片完全相同,僅在最終版時更銳利。

畫布與圖層(核心)

c = Canvas(w, h, bg=None, pixel=False)      # pixel=True:無反鋸齒、固定比例、最近鄰居匯出
L = c.layer(blend="normal", opacity=1, mask=None)   # 新圖層,變成當前圖層;c.use(L) 切換回來
blends: normal multiply screen overlay soft_light hard_light add subtract color_dodge color_burn darken lighten difference hue saturation color luminosity
c.fill(src, mask=None) · c.erase(mask) · c.place(img|path, x=None, y=None, scale=None(cover), rot=0, fit="cover"|"contain", blend, opacity) -> layer
c.apply(*fx, mask=None)   # 合併所有圖層,然後套用效果(最終調色);L.apply(*fx, mask=None) = 單一圖層
c.save(path, quality=92, scale=1, smooth=None) · c.preview(path, width=512) · c.crop_preview(path, x, y, w, h)
c.flatten() -> H×W×4 float · L.rgba (get/set) · c.w c.h (邏輯) c.W c.H c.s (光柵比例)

欄位(field)— 惰性、可組合:+ - * / ** > <、np.sin(f)、f.ramp() f.warp() f.scale() f.rotate() f.move() f.remap(lo,hi) f.clip() f.within(shape|(x0,y0,x1,y1))

X Y radial(cx,cy) angle(cx,cy) · Field(lambda x, y: ...)
perlin/simplex/value(scale=4, seed) · fbm(scale=4, octaves=5, lacunarity=2, gain=.5, seed, base="perlin")
ridged(scale=3, ...) · turbulence(scale=4, ...) · worley(scale=6, mode="F1"|"F2"|"F2-F1"|"id", seed)
domain_warp(f, strength=.1, scale=2, seed) · aastep(f, edge=.5) · smoothstep(e0, e1, v) · mix(a, b, t)
patterns [0,1]: wood(rings=14, angle) marble() clouds(scale, cover=.5, sharp) terrain_height() water_ripples() fabric(scale=60) paper() stars(density=60, size)
gradient(stops, angle=90 (上→下;0 = 左→右), kind="linear"|"radial"|"conic", center, radius)
ramp(f, stops) / f.ramp("sunset") · stops = palette name | ["#..", ...] | [(pos, col), ...]   (OKLab 插值)
palette("name") names: sunset night ocean forest desert earth fire ice pastel neon vapor viridis wood marble mono retro16 green4
cosine_palette(a, b, c, d, n=8) · rgb2hsv hsv2rgb rgb2oklab oklab2rgb
shade(height, light=(azimuth, elevation), strength=1, color=None, ambient=.25, spec=0)   # 無顏色 → 灰色,flat=0.5(在疊加圖層上使用)
masks: top(f) bottom(f) left(f) right(f) band(y0, y1) zone(x0, y0, x1, y1) disc(cx, cy, r)  (全部 soft=)
curves: f.ridge_line(y=.6, amp=.15) / curve(lambda x: y) → c.fill_below(curve, src) / fill_above · curve.below()

向量與文字(vector)— Shape = skia 路徑,也是一個 Field 遮罩;布林運算 | & - ^

rect(x, y, w, h, r=0) ellipse(cx, cy, rx, ry) circle(cx, cy, r) polygon(pts) line(x1,y1,x2,y2 | pts) regular(cx,cy,r,n)
star(cx, cy, r, r2, n=5) arc(cx, cy, r, start, sweep) spline(pts, closed) svg("M .. C .. A .. Z") union(*shapes)
shape.move/rotate(deg)/scale/outline(width, dash)/soft(feather)/points(n)/bounds/length
c.draw(shape, fill="black", stroke=None, width=2, cap="round", join="round", dash=(on, off), feather=0, opacity=1)
c.rect/ellipse/circle/polygon/line/spline/path(d)(..., **same style)
c.text(txt, x, y, size=32, fill, font="sans"|"mono"|"serif"|family|path.ttf, weight="regular"|"semibold"|"bold"|int,
       align="left"|"center"|"right", valign="baseline"|"top"|"middle"|"bottom", spacing=em, line_height=1.2, italic, fit=width_px, kern=True)
text_shape(...) → Shape · text_size(txt, size) → (width, cap_height) · c.text_on_path(txt, shape|points, size, align, lift, fit, fill)
c.text_box(txt, x, y, w, h=None, size=18, align="left"|"justify"|"center", line_height=1.4, fit=True)   # **b** *i* [#c33]colour[/]
c.title(txt, x, y, size=96, style="shadow"|"extrude"|"outline"|"inline"|"neon", fill, color2)

筆刷(brush)

c.stroke(points|Shape, brush="round", size=12, color, pressure=[...]|f(t)|float, opacity, jitter, spacing, taper=(a, b), seed, **params)
brushes: round round_soft airbrush ink(speed) chalk(tooth) bristle(n, var, gaps) oil(impasto, pickup) watercolor(edge, granulation, bleed)
c.paint_like(ref, brush="oil", sizes=(48,24,12), tol=.08, angle=0, seed)   # 使用筆觸重新繪製參考(Canvas/Field/image)
c.scatter(what, n, region=mask, size=(a, b), color=col|list|palette|Field, color_jitter, rot=(a, b), seed)
   what: dot soft star grass leaf petal square person | Shape (單位大小在 0,0)
c.hatch(region, angle=45, spacing=8, width=1.2, color, tone=Field (0=暗 → 粗), cross=False, wobble)
km_mix(a, b, t) 類似顏料混合(藍+黃 = 綠) · L.relief = 1.0(油畫肌理打光強度)

效果(fx)— c.apply(...) / L.apply(...);大小以畫布像素為單位

blur(r) motion_blur(len, angle) sharpen(amt) bloom(threshold=.75, radius=12, strength=.8, tint) glow(r, strength, color)
drop_shadow(dx, dy, r, color, opacity) inner_shadow(...) vignette(amount=.35, softness=.6) grain(amount=.04, size=1, seed)
chromatic_aberration(px) lens_distortion(k) exposure(stops) contrast(amt) levels(black, white, gamma) curves([(in, out), ...], channel)
hue_sat(hue_deg, sat_mult, light) saturation(x) color_balance(shadows=(r,g,b), mids, highlights) gradient_map(stops) invert()
tone_map("agx"|"filmic"|"reinhard", exposure, look="punchy") displace(field, strength) posterize(levels)
pixelate(size, palette=name|list, colors=N, dither=None|"bayer"|"fs", strength=.6) halftone(size, angle, ink, paper, cmyk=False)
god_rays(x, y, rays=14, length=.9, strength=.45, color, threshold=.7, occlude=True) lens_flare(x, y, strength=.6, color, ghosts=6, streak=.5)
depth_of_field(depth, focus, aperture=8)   # depth 來自 c.render(scene)
match_palette("ref.jpg", amount) transfer_tone(ref, amount)   # 從參考影像進行色彩/色調轉換

風格化(stylize)— 3D → 插畫 + 繪畫式濾鏡(用於 c.apply / L.apply 的效果)

r = c.render(s, alpha=True); c.cur.apply(toon(r, bands=3, shadow=.45, colors={id: col}), shadow_dots(r, size=5, lo=.3), outlines(r, width=2.5, inner=1))
engraving: L.fill(PAPER, mask=r.alpha); L.apply(render_hatch(r, s, spacing=4.5, layers=3), outlines(r, width=2))  # 剖面線跟隨 3D 表面
kuwahara(radius=6) oil · xdog(sigma=1, eps=.9, ink, paper) ink lines · pencil() · linocut(lines=7, angle) · edge_smooth(4)
watercolorize(bleed=2, edge=1, granulation=.4, ink=0..1) · stained_glass(cell=26, lead=3) · mosaic(tile=10) · shading(r) → (H,W) light

3D(sdf)— y 向上,單位≈公尺,基本形狀以原點為中心

sphere(r) box(w, h, d) round_box(w, h, d, r) cylinder(r, h) capsule(a, b, r) torus(R, r) cone(r1, h, r2) plane(y, normal)
ellipsoid(rx, ry, rz) lathe([(radius, y), ...] 底部→頂部, thickness=None|shell) extrude([(x, y), ...], depth)
ops: a | b, a & b, a - b, a.union(b, k=smooth) .inter .sub · .move(x,y,z) .rotate(x,y,z deg) .scale(k|(kx,ky,kz))
     .onion(t) .round(r) .twist(k) .bend(k) .repeat(period, count) .mirror("x") .elongate() .displace(noise3(scale, octaves, seed), amount)
Mat(color | 2D Field (proj="tri"|"xz"|"xy"|"zy", tex_scale) | f(p, n)->(N,3), rough=.5|Field|f(p,n), metal=0, glass=0, ior=1.45,
    sss=0, sss_color, emit=None, power=1, bump=.3, bump_scale=60, local=True (紋理跟隨物件), sheen=.6,
    wear=[smudges(.5), scratches(.5, density=40), dust(.3), edge_wear(.5, width=.01, color)])
s = Scene(); id = s.add(sdf, Mat(...)); s.camera(pos, target, fov=40)
s.sun(dir_toward_sun, color, power=3, soft=.04) · s.point(pos, color, power, radius) · s.area(pos, size=(w,h), normal, color, power, pattern="window"|"softbox", visible)
s.studio(key, target, size, power=45, window=True, fill=.2, bg) · s.sky(zenith, horizon, ground, power) · s.fog(color, density)
r = c.render(s, aa=1|2, exposure=0, look=None|"punchy", alpha=False)          # 快速光線追蹤(直接光 + AO + 1 次反射)
r = c.pathtrace(s, spp=16, bounces=4, denoise=True, aperture=0, focus=None|dist|(x,y), seed=SEED)  # 照片級真實:全域照明、多次折射玻璃、自適應反鋸齒
r.depth r.normal r.id r.mask(id) r.focus_at(x, y, c.s) r.linear r.spp r.time · denoise(img, albedo, normal, depth)

自然(nature, terrain)

h = terrain(384, kind="alpine"|"hills"|"mesa"|"island"|"dunes", seed, erosion=1, flow=False)   # 侵蝕高度圖 [0,1];erode() thermal()
c.terrain_map(h, style="relief"|"topo"|"shaded", water=.2)
v = c.landscape(h, cam=(x, alt, z), yaw, fov, horizon=.58, sun_elev=10, sun_az=30, haze=1, clouds=.35, water=.1, waves=.02, snow=.7, seed)
    v.depth v.water v.project(x, y, z) -> (px, py, px_per_m) v.ground(x, z)   # 在 3D 地形上放置 2D 樹木
c.sky(sun_elev=8, sun_az=0, horizon=.6, clouds=.3, haze=1) · c.sea(sun_elev=6, waves=.12, wave_len=60, foam=.5, clouds=.25)
c.tree(x, y, height_px, kind="oak"|"pine"|"birch"|"palm"|"bush"|"dead", season="summer"|"spring"|"autumn"|"winter", haze=0..1, seed)
c.grass(x, y, w, h, n) c.flower(x, y, size, kind="daisy"|"poppy"|"tulip"|"bell") c.fern(x, y, size) · tree3d("oak", 4, seed) → (trunk, leaves) SDFs
scene_sky(s, sun_elev, sun_az)   # 在 3D 場景上的物理天空
c.anime_cloud(x, y, w, h=.55w, palette="day"|"sunset"|"dusk"|"storm"|(shadow,mid,light,rim), light=(az, elev), bands=3, rim=.7, wisps, edge, bottom, seed)  # 賽璐珞風格積雲,底部平坦於 (x, y)
c.anime_tree(x, y, height, kind="round"|"tall"|"umbrella", palette="summer"|"spring"|"autumn"|"sakura"|"dusk"|(sh,mid,lt,rim,trunk), light, width, leafy=.6, seed)  # 賽璐珞風格樹木
c.anime_mountains(y_foot, height, peaks=4, x0, x1, palette="day"|"dusk"|"autumn"|(sh,mid,lt,snow,snow_sh,haze), light, snow=.35, haze=.6, sharp=1, depth=.35, bands=3, seed)  # 侵蝕地形,正面視圖,賽璐珞色調
c.sparkles(n, region=mask, size=(6, 16), color, rays=4, glow=.6, seed)   # 星形閃光(水、雪)

人物(figure)— 腳在 (x, y),高度 = 站立像素(動物:肩高)

c.figure(x, y, h, pose="stand", style="flat"|"line"|"silhouette"|"stick"|"ink"|"chalk", kind="human"|"cat"|"dog"|"horse"|"bird", seed)
   poses: stand idle walk run sit wave point cheer jump dance think hips phone reach · phase=0-1(行走週期)view="front"|"3q"|"side"|"back"
   body=adult|teen|child|elder build=slim|heavy outfit="tee pants|coat skirt|dress" hair=short|bob|long|bun|curly skin=SKIN name colors={...}
figure_shape(...) → Shape · figure_joints(...) → {"hand_r": (x, y), ...}(附加道具)· figure_sdf(pose, height=1.75, style="mannequin")
c.crowd(n, box=(x0, y0, x1, y1), horizon=y, height=near_px, tint=(haze, .5), dogs=.1, seed)   # 透視縮放的人群

檢查(inspect)— 用數字判斷,而不僅是縮小的視圖

m = metrics(c|path|arr)   # 雜訊(<1 乾淨,>4 顆粒狀)鋸齒(% 硬階梯,>35 鋸齒狀)條紋 剪裁陰影/高光 flags[...]
contact_sheet(c, "sheet.jpg") · compare(a, b, "ab.jpg") · guides(c) / composition(c) → 焦點、平衡、傾斜 · analyze_reference("ref.jpg")

風格 — 在撰寫場景前先閱讀匹配的指南

指南位於此檔案旁的 styles/ 中(如果遺失:https://raw.githubusercontent.com/Wexop/atelier/main/styles/<name>.md)。 每個指南提供配方、規則、陷阱和一個範例腳本。可以混合多種(例如動畫 + 扁平)。

  • anime.md — 手繪動畫風景:賽璐珞雲、樹木、山脈、邊緣光、神光、閃光
  • oil.md — 油畫(paint_like)和水彩渲染
  • photoreal.md — 路徑追蹤靜物/產品、地形景觀、海洋和天空
  • comic.md — 清晰線條 / 來自 3D 的卡通風格、雕刻、墨水濾鏡
  • flat.md — 扁平向量、海報、字型設計、人物、剪影場景
  • pixel.md — 使用調色盤和抖色的像素藝術
  • abstract.md — 來自扭曲場域的生成式抽象
  • new-style.md — 沒有合適的指南:研究外觀,將其映射到基本元素,繪製,然後儲存新的 styles/<name>.md

陷阱

  • c.layer() 會改變當前目標:後續的 c.text/... 會進入該圖層(如果它是 multiply 則不好)。呼叫 c.layer() 或 c.use(L)。
  • c.apply() 會合併所有圖層。使用 L.apply() 來保留圖層。
  • shade(strength) 依賴於欄位頻率:大型形狀約為 1,精細紋理(如布料)約為 .05。
  • tone_map 在 2D 藝術上會使純白色變灰——它專用於 HDR/3D;在插圖上使用 curves/levels。
  • 硬閾值會產生鋸齒:對於可見邊緣,使用 aastep/smoothstep,而不是 f > .5。
  • 雜訊 scale = 每個畫布高度的特徵數。形狀座標 = 畫布像素;欄位座標 = 0–1。
  • 成本:pathtrace ≈ 30–60 µs/路徑(1200×800 @ 8 spp ≈ 在 2 核心上 5 分鐘,預覽減少 4 倍 spp)——使用 c.render 草稿; 低 spp 時,金屬/玻璃上會有閃爍(提高 spp)。aa=2 ≈ 4 倍。大量 SDF 部件(人物、tree3d、置換)追蹤速度較慢。
  • 玻璃:使用 rough=0 達到清晰效果(預設 rough .5 為磨砂)。在 c.render 中,玻璃折射一次;使用 pathtrace 進行真實折射。

…

[為翻譯而截斷]

相關技能