mirror of
https://github.com/tiennm99/tiennm99bot.git
synced 2026-10-11 03:13:46 +00:00
The beta wish renders an 8-second astrology-themed night sky in toon shading through a perspective action camera: it dollies toward a hero cloud, a comet lights the cloud's rim from behind and bursts through it, the camera chases the comet as its flare builds to a starburst, and the label appears with an S, SS, or SSS rank. It shares the /api/gacha request contract and render slots.
84 lines
2.7 KiB
JavaScript
84 lines
2.7 KiB
JavaScript
import {mkdir, writeFile} from 'node:fs/promises';
|
|
import path from 'node:path';
|
|
import {renderGachaBetaVideo, renderGachaVideo} from '../src/render/render-gacha.js';
|
|
import {renderWheelGif} from '../src/render/render-gif.js';
|
|
|
|
const smoke = process.argv.includes('--smoke');
|
|
const fixturesDir = path.join(process.cwd(), 'fixtures');
|
|
|
|
/** @type {{name: string, request: import('../src/schemas/wheel-request.js').WheelRenderRequest}[]} */
|
|
const fixtures = [
|
|
{
|
|
name: 'smoke',
|
|
request: {
|
|
options: ['alpha', 'beta', 'gamma', 'delta'],
|
|
winnerIndex: 1,
|
|
durationMs: smoke ? 3000 : 6500,
|
|
holdMs: smoke ? 500 : 1200,
|
|
fps: 12,
|
|
size: smoke ? 384 : 512,
|
|
theme: 'classic',
|
|
},
|
|
},
|
|
{
|
|
name: 'vietnamese',
|
|
request: {
|
|
options: ['khong dau', 'co dau', 'banh mi', 'ca phe sua da', 'pho bo', 'goi cuon', 'ha noi', 'sai gon'],
|
|
winnerIndex: 3,
|
|
durationMs: 6500,
|
|
holdMs: 1200,
|
|
fps: 15,
|
|
size: 512,
|
|
theme: 'festival',
|
|
},
|
|
},
|
|
{
|
|
name: 'sixteen-options',
|
|
request: {
|
|
options: Array.from({length: 16}, (_, index) => `option ${index + 1}`),
|
|
winnerIndex: 9,
|
|
durationMs: 6500,
|
|
holdMs: 1200,
|
|
fps: 15,
|
|
size: 512,
|
|
theme: 'classic',
|
|
},
|
|
},
|
|
];
|
|
|
|
await mkdir(fixturesDir, {recursive: true});
|
|
|
|
/** @type {{name: string, request: import('../src/schemas/gacha-request.js').GachaRenderRequest}[]} */
|
|
const gachaFixtures = [
|
|
{name: 'gacha-5-star', request: {label: 'Pizza', rarity: 5, fps: 24, width: 640, seed: 7}},
|
|
{name: 'gacha-4-star', request: {label: 'Phở bò tái nạm gầu', rarity: 4, fps: 24, width: 640, seed: 11}},
|
|
{name: 'gacha-3-star', request: {label: 'Cơm tấm', rarity: 3, fps: 24, width: 854, seed: 23}},
|
|
];
|
|
|
|
/**
|
|
* @param {string} name
|
|
* @param {{buffer: Buffer, byteLength: number, durationMs: number}} result
|
|
*/
|
|
const save = async (name, result) => {
|
|
const output = path.join(fixturesDir, name);
|
|
await writeFile(output, result.buffer);
|
|
console.log(`${name}: ${output} ${result.byteLength} bytes ${result.durationMs}ms`);
|
|
};
|
|
|
|
for (const fixture of smoke ? fixtures.slice(0, 1) : fixtures) {
|
|
await save(`${fixture.name}.gif`, await renderWheelGif(fixture.request, {timeoutInMilliseconds: 30000}));
|
|
}
|
|
|
|
for (const fixture of smoke ? gachaFixtures.slice(0, 1) : gachaFixtures) {
|
|
await save(`${fixture.name}.mp4`, await renderGachaVideo(fixture.request, {timeoutInMilliseconds: 30000}));
|
|
}
|
|
|
|
const betaFixture = {
|
|
label: 'Bún bò',
|
|
rarity: /** @type {const} */ (5),
|
|
fps: /** @type {const} */ (24),
|
|
width: /** @type {const} */ (640),
|
|
seed: 7,
|
|
};
|
|
await save('gachabeta-5-star.mp4', await renderGachaBetaVideo(betaFixture, {timeoutInMilliseconds: 30000}));
|