diff --git a/assets.build.ts b/assets.build.ts index 4e930c9a..ecf35bfc 100644 --- a/assets.build.ts +++ b/assets.build.ts @@ -1,8 +1,7 @@ -import {gen6Padded, itemPadded} from './rules/minisprites.ts'; import {Manifest, itemspritecopy, spritecopy} from './rules/publish.ts'; -import {rule} from './tools/build/artifact.ts'; -import {spriteglob} from './tools/build/helpers.ts'; +import {forEachRule, rule} from './tools/build/artifact.ts'; +import {compresspng, pad, spriteglob} from './tools/build/helpers.ts'; import {deploy} from './tools/deploy/api.ts'; // The tar root maps onto the served tree: sprites/x is served at @@ -54,11 +53,18 @@ deploy(async ctx => { ctx.write('__meta/spritesheet-css-url.txt', `${SERVED}/${ASSETS}/spritesheet-${ch}.css\n`); }); -// Forumsprites: padded minisprites under stamped names, with the +// Forumsprites: uniform-size minisprites under stamped names, with the // unhashed -> url mapping in a manifest. -let forumItems = itemPadded(); -let forumG6 = gen6Padded(); +let forumItems = forEachRule('src/minisprites/items/*.png', { + display: 'pad item minisprite %f', + cmds: [pad({w: 24, h: 24}), compresspng({config: 'MINISPRITE'})], +}, '%b'); + +let forumG6 = forEachRule('src/minisprites/pokemon/gen6/*.png', { + display: 'pad g6 minisprite %f', + cmds: [pad({w: 40, h: 30}), compresspng({config: 'MINISPRITE'})], +}, '%b'); deploy(async ctx => { let manifest = new Manifest(ctx, SERVED); diff --git a/rules/minisprites.ts b/rules/minisprites.ts deleted file mode 100644 index df91186d..00000000 --- a/rules/minisprites.ts +++ /dev/null @@ -1,33 +0,0 @@ - -import {type Artifact, forEachRule} from '../tools/build/artifact.ts'; -import {compresspng, pad, trimimg} from '../tools/build/helpers.ts'; - -// Uniform size minisprites - -export function gen6Padded(): Artifact[] { - return forEachRule('src/minisprites/pokemon/gen6/*.png', { - display: 'pad g6 minisprite %f', - cmds: [pad({w: 40, h: 30}), compresspng({config: 'MINISPRITE'})], - }, '%b'); -} - -export function itemPadded(): Artifact[] { - return forEachRule('src/minisprites/items/*.png', { - display: 'pad item minisprite %f', - cmds: [pad({w: 24, h: 24}), compresspng({config: 'MINISPRITE'})], - }, '%b'); -} - -export function gen6Trimmed(): Artifact[] { - return forEachRule('src/minisprites/pokemon/gen6/*.png', { - display: 'trim g6 minisprite %f', - cmds: [trimimg(), compresspng({config: 'MINISPRITE'})], - }, '%b'); -} - -export function itemTrimmed(): Artifact[] { - return forEachRule('src/minisprites/items/*.png', { - display: 'trim item minisprite %f', - cmds: [trimimg(), compresspng({config: 'MINISPRITE'})], - }, '%b'); -} diff --git a/rules/modelslike.ts b/rules/modelslike.ts index a0dde6d5..4952a6d1 100644 --- a/rules/modelslike.ts +++ b/rules/modelslike.ts @@ -1,21 +1,7 @@ import {type Artifact, forEachRule} from '../tools/build/artifact.ts'; -// Gen 9 - -export function gen9Modelslike(): Artifact[] { - return forEachRule('src/gen9species/*.png', { - display: '96x96 %f', - // TODO, add customizable compression for gif - // ... or investigate using webp instead of both png/gif here - cmds: [ - 'magick convert %f -trim +repage -resize 90x90 %o', - 'gifsicle -O3 -b %o', - ], - }, '%B.gif'); -} - -// Gen 10 +// Shared by the smogon xy/ set and the PS ani/ set. export function gen10Modelslike(): Artifact[] { return forEachRule('src/champions/*.png', { @@ -28,14 +14,3 @@ export function gen10Modelslike(): Artifact[] { ], }, '%B.gif'); } - -// Gen 5 CAPs... - -export function gen5Gifs(): Artifact[] { - return forEachRule('src/sprites/gen5/*.png', [ - // TODO, add customizable compression for gif - // ... or investigate using webp instead of both png/gif here - 'magick convert %f %o', - 'gifsicle -O3 -b %o', - ], '%B.gif'); -} diff --git a/rules/social.ts b/rules/social.ts deleted file mode 100644 index d0212d29..00000000 --- a/rules/social.ts +++ /dev/null @@ -1,38 +0,0 @@ - -import {type Artifact, forEachRule} from '../tools/build/artifact.ts'; -import {PNG_DETERMINISTIC, base, compresspng, spriteglob} from '../tools/build/helpers.ts'; - -// Smogdex social images: models, backfilled with gen9 species not yet in -// models (first source wins). - -function socialInputs(): string[] { - let social = spriteglob(['src/models/*'], {b: false, s: false}); - let socialSeen = new Set(social.map(base)); - for (let file of spriteglob(['src/gen9species/*'], {b: false, s: false})) { - if (!socialSeen.has(base(file))) { - social.push(file); - socialSeen.add(base(file)); - } - } - return social; -} - -export function fbSprites(): Artifact[] { - return forEachRule(socialInputs(), { - display: 'fbsprite %f', - cmds: [ - `magick convert "%f[0]" ${PNG_DETERMINISTIC} -trim -resize 150x150 -background white -gravity center -extent 198x198 -bordercolor black -border 1 %o`, - compresspng({config: 'MODELS'}), - ], - }, '%B.png'); -} - -export function twitterSprites(): Artifact[] { - return forEachRule(socialInputs(), { - display: 'twittersprite %f', - cmds: [ - `magick convert "%f[0]" ${PNG_DETERMINISTIC} -trim -resize 115x115 -background white -gravity center -extent 120x120 %o`, - compresspng({config: 'MODELS'}), - ], - }, '%B.png'); -} diff --git a/smogon.build.ts b/smogon.build.ts index 52cba797..aeb06b35 100644 --- a/smogon.build.ts +++ b/smogon.build.ts @@ -1,14 +1,32 @@ -import {gen6Trimmed} from './rules/minisprites.ts'; -import {gen10Modelslike, gen5Gifs, gen9Modelslike} from './rules/modelslike.ts'; +import {gen10Modelslike} from './rules/modelslike.ts'; import {Manifest, type Sprite, spritecopy} from './rules/publish.ts'; +import {forEachRule} from './tools/build/artifact.ts'; +import {compresspng, trimimg} from './tools/build/helpers.ts'; import {deploy} from './tools/deploy/api.ts'; // xy/ animations: first source wins per sprite name. -let xyModels = gen9Modelslike(); +let xyModels = forEachRule('src/gen9species/*.png', { + display: '96x96 %f', + // TODO, add customizable compression for gif + // ... or investigate using webp instead of both png/gif here + cmds: [ + 'magick convert %f -trim +repage -resize 90x90 %o', + 'gifsicle -O3 -b %o', + ], +}, '%B.gif'); + let xyChampions = gen10Modelslike(); -let xyGen5 = gen5Gifs(); + +// Non-model gen 5 CAPs. + +let xyGen5 = forEachRule('src/sprites/gen5/*.png', [ + // TODO, add customizable compression for gif + // ... or investigate using webp instead of both png/gif here + 'magick convert %f %o', + 'gifsicle -O3 -b %o', +], '%B.gif'); deploy(async ctx => { let seenModels = new Set(); @@ -44,7 +62,10 @@ deploy(async ctx => { // xyicons/: trimmed gen6 minisprites. -let xyIcons = gen6Trimmed(); +let xyIcons = forEachRule('src/minisprites/pokemon/gen6/*.png', { + display: 'trim g6 minisprite %f', + cmds: [trimimg(), compresspng({config: 'MINISPRITE'})], +}, '%b'); deploy(async ctx => { let manifest = new Manifest(ctx); @@ -54,10 +75,45 @@ deploy(async ctx => { manifest.write('xyicons/manifest.json'); }); -// Deprecated, unstamped sets: -// let xyItems = itemTrimmed(); (rules/minisprites.ts) -// let fb = fbSprites(); (rules/social.ts) -// let twitter = twitterSprites(); (rules/social.ts) +// Deprecated, unstamped sets. Reviving one also means importing what it +// uses (PNG_DETERMINISTIC, base, spriteglob, itemspritecopy) and giving the +// copies a Manifest, as the stamped deploys above do. +// +// let xyItems = forEachRule('src/minisprites/items/*.png', { +// display: 'trim item minisprite %f', +// cmds: [trimimg(), compresspng({config: 'MINISPRITE'})], +// }, '%b'); +// +// Smogdex social images: models, backfilled with gen9 species not yet in +// models (first source wins). +// +// function socialInputs(): string[] { +// let social = spriteglob(['src/models/*'], {b: false, s: false}); +// let socialSeen = new Set(social.map(base)); +// for (let file of spriteglob(['src/gen9species/*'], {b: false, s: false})) { +// if (!socialSeen.has(base(file))) { +// social.push(file); +// socialSeen.add(base(file)); +// } +// } +// return social; +// } +// +// let fb = forEachRule(socialInputs(), { +// display: 'fbsprite %f', +// cmds: [ +// `magick convert "%f[0]" ${PNG_DETERMINISTIC} -trim -resize 150x150 -background white -gravity center -extent 198x198 -bordercolor black -border 1 %o`, +// compresspng({config: 'MODELS'}), +// ], +// }, '%B.png'); +// +// let twitter = forEachRule(socialInputs(), { +// display: 'twittersprite %f', +// cmds: [ +// `magick convert "%f[0]" ${PNG_DETERMINISTIC} -trim -resize 115x115 -background white -gravity center -extent 120x120 %o`, +// compresspng({config: 'MODELS'}), +// ], +// }, '%B.png'); // // deploy(ctx => { // for (let f of xyItems) {