176 lines
4.3 KiB
Typst
176 lines
4.3 KiB
Typst
/* NOTE
|
||
一共有四种形态:夜鹭、绿头鸭、企鹅、啄木鸟
|
||
|
||
动画:
|
||
|
||
- 四种都有
|
||
- Idle
|
||
- walk
|
||
- jump
|
||
- jump_start
|
||
- jump_end
|
||
- falling
|
||
- 夜鹭
|
||
- gliding
|
||
- 绿头鸭
|
||
- swim-idle
|
||
- swim-walk
|
||
- swim-jump
|
||
- jump_start
|
||
- jump_end
|
||
- 企鹅
|
||
- slide
|
||
- slide_start
|
||
- sliding
|
||
- slide_end
|
||
*/
|
||
|
||
|
||
// Debug Sprite Animation Sheet Generator for UE PaperZD
|
||
// Usage: #form("form_name", ((state, frames, color), ...))
|
||
|
||
// ========== Configuration ==========
|
||
#let frame-width = 128pt
|
||
#let frame-height = 128pt
|
||
|
||
// Fixed grid size per page
|
||
#let grid-cols = 8
|
||
#let grid-rows = 4
|
||
|
||
// ========== Helper Functions ==========
|
||
|
||
#let frame-cell(form, state, index, total, bg-color) = {
|
||
let text-color = if bg-color.components().at(2) < 50% { white } else { black }
|
||
|
||
box(
|
||
width: frame-width,
|
||
height: frame-height,
|
||
fill: bg-color,
|
||
stroke: 1pt + black,
|
||
)[
|
||
#set align(center + horizon)
|
||
#set text(fill: text-color, weight: "bold")
|
||
|
||
#stack(
|
||
dir: ttb,
|
||
spacing: 4pt,
|
||
text(size: 10pt, fill: text-color.transparentize(30%))[#form],
|
||
text(size: 14pt)[#state],
|
||
v(4pt),
|
||
text(size: 20pt)[#(index + 1)],
|
||
text(size: 10pt, fill: text-color.transparentize(30%))[\/ #total],
|
||
)
|
||
]
|
||
}
|
||
|
||
#let empty-cell() = {
|
||
box(
|
||
width: frame-width,
|
||
height: frame-height,
|
||
fill: rgb("#222222"),
|
||
stroke: 1pt + rgb("#444444"),
|
||
)[]
|
||
}
|
||
|
||
// Form function - creates a page with all animations for one form
|
||
// anims: array of (state, frames, color)
|
||
#let form(form-name, anims) = {
|
||
let total-cells = grid-cols * grid-rows
|
||
|
||
// Build all cells for this form
|
||
let cells = ()
|
||
for anim in anims {
|
||
let (state, frames, color) = anim
|
||
for i in range(frames) {
|
||
cells.push(frame-cell(form-name, state, i, frames, color))
|
||
}
|
||
}
|
||
|
||
// Pad with empty cells to fill the grid
|
||
let filled = cells.len()
|
||
for i in range(total-cells - filled) {
|
||
cells.push(empty-cell())
|
||
}
|
||
|
||
page(
|
||
width: frame-width * grid-cols,
|
||
height: frame-height * grid-rows,
|
||
margin: 0pt,
|
||
)[
|
||
#grid(
|
||
columns: (frame-width,) * grid-cols,
|
||
rows: (frame-height,) * grid-rows,
|
||
..cells
|
||
)
|
||
]
|
||
}
|
||
|
||
// ========== Color Palette ==========
|
||
#let c-heron = rgb("#1565C0") // 深蓝
|
||
#let c-mallard = rgb("#2E7D32") // 深绿
|
||
#let c-penguin = rgb("#6A1B9A") // 紫
|
||
#let c-woodpecker = rgb("#D84315") // 橙红
|
||
|
||
#let L1 = 15% // walk
|
||
#let L2 = 30% // jump
|
||
#let L3 = 40% // falling
|
||
|
||
// ========== 夜鹭 Night Heron (蓝色系) ==========
|
||
#form("heron", (
|
||
("idle", 4, c-heron),
|
||
("walk", 6, c-heron.lighten(L1)),
|
||
("jump_start", 2, c-heron.lighten(L2)),
|
||
("jump_end", 2, c-heron.lighten(L2)),
|
||
("falling", 3, c-heron.lighten(L3)),
|
||
("gliding", 4, rgb("#00B0FF")),
|
||
))
|
||
|
||
// ========== 绿头鸭 Mallard (绿色系) ==========
|
||
#form("mallard", (
|
||
("idle", 4, c-mallard),
|
||
("walk", 6, c-mallard.lighten(L1)),
|
||
("jump_start", 2, c-mallard.lighten(L2)),
|
||
("jump_end", 2, c-mallard.lighten(L2)),
|
||
("falling", 3, c-mallard.lighten(L3)),
|
||
("swim_idle", 4, rgb("#00C853")),
|
||
("swim_walk", 6, rgb("#69F0AE")),
|
||
("swim_jump_start", 2, rgb("#B9F6CA")),
|
||
("swim_jump_end", 2, rgb("#B9F6CA")),
|
||
))
|
||
|
||
// ========== 企鹅 Penguin (紫色系) ==========
|
||
#form("penguin", (
|
||
("idle", 4, c-penguin),
|
||
("walk", 6, c-penguin.lighten(L1)),
|
||
("jump_start", 2, c-penguin.lighten(L2)),
|
||
("jump_end", 2, c-penguin.lighten(L2)),
|
||
("falling", 3, c-penguin.lighten(L3)),
|
||
("slide_start", 2, rgb("#E040FB")),
|
||
("sliding", 4, rgb("#EA80FC")),
|
||
("slide_end", 2, rgb("#E040FB")),
|
||
))
|
||
|
||
// ========== 啄木鸟 Woodpecker (橙红色系) ==========
|
||
#form("woodpecker", (
|
||
("idle", 4, c-woodpecker),
|
||
("walk", 6, c-woodpecker.lighten(L1)),
|
||
("jump_start", 2, c-woodpecker.lighten(L2)),
|
||
("jump_end", 2, c-woodpecker.lighten(L2)),
|
||
("falling", 3, c-woodpecker.lighten(L3)),
|
||
))
|
||
|
||
/*
|
||
========== 编译命令 ==========
|
||
|
||
mkdir -p debug_sprites && typst compile debug_sprites.typ debug_sprites/{p}.png && \
|
||
cd debug_sprites && \
|
||
mv 1.png heron.png && \
|
||
mv 2.png mallard.png && \
|
||
mv 3.png penguin.png && \
|
||
mv 4.png woodpecker.png && \
|
||
cd ..
|
||
|
||
每页一个形态,8x4 网格 (1024x512),格子大小 128x128。
|
||
导入 UE 时设置切割网格为 128x128。
|
||
*/
|