Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 | 25x 25x 25x 25x 25x 25x 3x 3x 37x 3x 3x 3x 3x 9x 9x 1x 1x 1x 1x 8x 8x 3x 3x 3x 3x 3x 3x 3x 3x 7x 6x 20x 6x 15x 6x 6x 6x 6x 6x | import { Container, Graphics } from 'pixi.js';
import { drawFrame, drawReticle } from './draw.ts';
import {
burstParticlePosition,
burstParticles,
emberColor,
hsvToHex,
projectPoint,
rotateY,
starfieldPoint,
} from './space.ts';
import {
SYN_AMBER,
SYN_CYAN,
SYN_DEEP,
SYN_DIM,
SYN_DISPLAY_FONT,
SYN_EMBER,
SYN_FLARE,
SYN_MAGENTA,
SYN_MIST,
SYN_RED,
SYN_TEXT_FONT,
SYN_VOID,
SYN_WHITE,
sceneHue,
} from './style.ts';
import {
easeOutBack,
easeOutCubic,
resolveResultCourseCard,
resolveResultCourseScroll,
resolveResultLamp,
resolveResultPlayTag,
resolveResultTrackRows,
rollUpValue,
stageProgress,
resolveResultVerdict,
type BeMusicResultData,
type ResultCourseCard,
type ResultTrackRow,
} from '@be-music/player-skin-sdk';
import { resolveResultGrid } from './result-grid.ts';
import type { PixiResultFrame, PixiResultSkin, SkinTextOptions } from '../pixi-kit/index.ts';
import { addSynesthesiaText } from './figures.ts';
/** How fast the entrance timeline plays: the choreography below is authored at 1x and runs 1.3x, so the card settles
* sooner without changing its order or easing. */
const ENTRANCE_PACE = 1.3;
const ROLL_DELAY_MS = 700;
const ROLL_MS = 1100;
const RANK_DELAY_MS = 1600;
const RANK_BURST = burstParticles(29, 260);
export const synesthesiaResultSkin: PixiResultSkin = { render: (frame) => renderSynesthesiaResult(frame) };
/**
* Synesthesia result, in the light of a cosmic particle world: a black void with ember dust and a floor of light
* points; the verdict condenses out of wide-tracked light, hairline frames fade up in sequence while counters roll,
* graphs draw as glowing filaments, and the rank letter ignites in a burst of sparks the moment it lands — a lock-on
* reticle snapping shut on it.
*/
export function renderSynesthesiaResult(frame: PixiResultFrame): void {
const { result, designWidth, designHeight, nowMs, rankLabel, layer } = frame;
// Panels sit on the landscape grid, or stack on a portrait stage (see resolveResultGrid).
const grid = resolveResultGrid(designWidth, designHeight);
const portrait = designHeight > designWidth;
const margin = grid.margin;
// Effects off: skip the entrance and render the settled result.
const elapsed = frame.effects === 'off' ? Number.POSITIVE_INFINITY : frame.elapsedMs * ENTRANCE_PACE;
const seconds = nowMs / 1000;
const hue = sceneHue(seconds);
const accent = hsvToHex(hue, 0.6, 1);
const cleared = result.cleared;
const verdictColor = cleared ? SYN_AMBER : SYN_RED;
const exMax = Math.max(0, result.score.total * 2);
const roll = stageProgress(elapsed, ROLL_DELAY_MS, ROLL_MS);
const group = (label: string): { root: Container; g: Graphics } => {
const root = new Container();
root.label = `synesthesia-result/${label}`;
const g = new Graphics();
root.addChild(g);
layer.addChild(root);
return { root, g };
};
const text = (target: Container, value: string, x: number, y: number, options: SkinTextOptions) =>
addSynesthesiaText(target, value, x, y, options);
/** Fade + rise a group in. */
const rise = (root: Container, delayMs: number, distance = 18, durationMs = 520): void => {
const eased = easeOutCubic(stageProgress(elapsed, delayMs, durationMs));
root.y = distance * (1 - eased);
root.alpha = eased;
};
const display = (size: number, fill: number, extra: SkinTextOptions = {}): SkinTextOptions => ({
size,
fill,
fontFamily: SYN_DISPLAY_FONT,
...extra,
});
// Labels read at 9 px on the landscape stage; the portrait stage is shown smaller on a phone, so they go up to 10.
const labelSize = portrait ? 10 : 9;
const label = (value: string, x: number, y: number, target: Container, fill: number = SYN_DIM, maxWidth?: number) =>
text(target, value, x, y, display(labelSize, fill, { letterSpacing: 2, maxWidth }));
// Space: warm black, dust pouring out of the vanishing point, and a floor of points.
const space = group('space');
const bands: ReadonlyArray<readonly [number, number]> = [
[SYN_DEEP, 0.3],
[0x070201, 0.55],
[0x040100, 0.8],
[SYN_VOID, 1],
];
let top = 0;
for (const [color, until] of bands) {
const bottom = designHeight * until;
space.g.rect(0, top, designWidth, bottom - top).fill(color);
top = bottom;
}
const light = new Graphics();
light.blendMode = 'add';
space.root.addChild(light);
const horizon = designHeight * 0.74;
const vanishX = designWidth / 2;
const vanishY = designHeight * 0.45;
for (let index = 0; index < 260; index += 1) {
const point = starfieldPoint(index, seconds, { spread: 560, near: 20, far: 900, speed: 90 });
const projected = projectPoint(point, vanishX, vanishY, 180);
if (!projected.visible) continue;
const nearness = Math.min(1, projected.scale);
const color = index % 9 === 0 ? SYN_CYAN : index % 13 === 0 ? SYN_MAGENTA : emberColor(0.35 + 0.65 * nearness);
const size = 0.5 + 1.3 * nearness;
light
.rect(projected.x - size / 2, projected.y - size / 2, size, size)
.fill({ color, alpha: 0.25 + 0.6 * nearness });
}
const floor = (x: number, z: number) => projectPoint({ x, y: 130, z }, vanishX, horizon, 200);
const offset = (seconds * 110) % 100;
for (let z = 100 - offset; z < 2600; z += 100) {
const nearness = 1 - z / 2600;
const size = 0.6 + 1.4 * nearness * nearness;
const color = emberColor(0.3 + 0.65 * nearness);
const alpha = 0.12 + 0.7 * nearness * nearness;
for (let x = -1400; x <= 1400; x += 50) {
const point = floor(x, z);
if (point.x < -4 || point.x > designWidth + 4) continue;
light.rect(point.x - size / 2, point.y - size / 2, size, size);
}
// One fill per row: its points share a colour and alpha and never overlap.
light.fill({ color, alpha });
}
// Verdict: tracking condenses from wide to settled while it fades in.
const verdict = group('verdict');
const verdictT = easeOutCubic(stageProgress(elapsed, 100, 900));
verdict.g.rect(0, 44, designWidth, 1).fill({ color: verdictColor, alpha: 0.5 * verdictT });
text(verdict.root, resolveResultVerdict(result), margin, 14, {
...display(15, SYN_WHITE),
letterSpacing: 6 + 22 * (1 - verdictT),
alpha: verdictT,
dropShadow: { color: verdictColor, distance: 0, blur: 12, alpha: 1 },
});
// AUTO PLAY / ASSIST: a framed tag at the right end of the verdict's line, fading in with it.
const playTag = resolveResultPlayTag(result);
if (playTag !== undefined) {
const tag = group('play-tag');
const tagColor = playTag === 'AUTO PLAY' ? SYN_CYAN : SYN_MAGENTA;
const tagRight = designWidth - margin;
const tagText = text(tag.root, playTag, tagRight - 12, 23, {
...display(11, tagColor),
letterSpacing: 3,
anchorX: 1,
anchorY: 0.5,
dropShadow: { color: tagColor, distance: 0, blur: 8, alpha: 0.8 },
});
const tagW = Math.ceil(tagText.width) + 24;
drawFrame(tag.g, tagRight - tagW, 11, tagW, 24, tagColor, { fill: 0.6, arm: 6 });
tag.root.alpha = verdictT;
}
// Rank: sparks burst outward as the letter ignites.
const rank = group('rank');
const rankBox = grid.rank;
const rankCx = rankBox.x + rankBox.w / 2;
// The rank sits between the DJ LEVEL label and the rate, clear of both.
const rankCy = rankBox.y + Math.round(rankBox.h / 2);
const topRank = rankLabel === 'AAA' || rankLabel === 'AA';
const rankColor = topRank ? SYN_AMBER : accent;
drawFrame(rank.g, rankBox.x, rankBox.y, rankBox.w, rankBox.h, rankColor, { emphasis: true });
label('DJ LEVEL', rankBox.x + 14, rankBox.y + 12, rank.root, rankColor);
const burstT = stageProgress(elapsed, RANK_DELAY_MS, 1100);
if (burstT > 0 && burstT < 1) {
for (const particle of RANK_BURST) {
const life = burstT / particle.life;
if (life >= 1) continue;
const position = burstParticlePosition(particle, life, 120, 30);
const point = projectPoint(rotateY(position, seconds * 0.4), rankCx, rankCy, 240);
if (!point.visible) continue;
const color = particle.hueShift > 0.06 ? SYN_CYAN : emberColor(1 - life * 0.7);
rank.g
.circle(point.x, point.y, (1 + 2.5 * particle.size) * point.scale)
.fill({ color, alpha: 0.12 * (1 - life) });
rank.g
.circle(point.x, point.y, (0.5 + 0.8 * particle.size) * point.scale)
.fill({ color: SYN_WHITE, alpha: 1 - life });
}
}
const stamp = stageProgress(elapsed, RANK_DELAY_MS, 420);
if (stamp > 0) {
// Lock-on: brackets snap shut on the letter as it lands.
const snap = easeOutCubic(Math.min(1, stamp * 1.6));
const lock = 46 + 60 * (1 - snap);
drawReticle(rank.g, rankCx - lock, rankCy - lock, lock * 2, lock * 2, SYN_FLARE, 0.4 + 0.5 * snap, {
arm: 12,
width: 1.75,
cross: stamp < 1,
});
}
const letter = new Container();
rank.root.addChild(letter);
const heartbeat = (1 - ((seconds * 1.4) % 1)) ** 4;
text(letter, rankLabel, rankCx, rankCy, {
...display(rankLabel.length >= 3 ? 28 : 40, SYN_WHITE),
anchorX: 0.5,
anchorY: 0.5,
maxWidth: 130,
alpha: Math.min(1, stamp * 2),
dropShadow: { color: rankColor, distance: 0, blur: 14 + 8 * heartbeat, alpha: 1 },
});
letter.pivot.set(rankCx, rankCy);
letter.position.set(rankCx, rankCy);
letter.scale.set(stamp >= 1 ? 1 + 0.03 * heartbeat : 1.8 - 0.8 * easeOutBack(stamp));
const rate = frame.ratePercent * easeOutCubic(roll);
text(rank.root, `${rate.toFixed(2)}%`, rankCx, rankBox.y + rankBox.h - 14, {
...display(10, SYN_MIST),
anchorX: 0.5,
anchorY: 0.5,
letterSpacing: 1,
});
rise(rank.root, 250);
// Metric panels.
const metrics: ReadonlyArray<readonly [name: string, value: string, fill: number]> = [
['SCORE', String(rollUpValue(result.score.score, roll)), SYN_WHITE],
['EX SCORE', `${rollUpValue(result.score.exScore, roll)} / ${exMax}`, SYN_WHITE],
['MAX COMBO', String(rollUpValue(result.maxCombo, roll)), SYN_AMBER],
['GAUGE', `${rollUpValue(Math.round(result.gauge), roll)}%`, cleared ? SYN_AMBER : SYN_RED],
['PLAY TIME', `${(result.playSeconds * easeOutCubic(roll)).toFixed(1)}s`, SYN_WHITE],
['NOTES', String(rollUpValue(result.score.total, roll)), SYN_WHITE],
];
metrics.forEach(([name, value, fill], index) => {
const { x, y, w, h } = grid.metrics[index]!;
const panel = group(`metric-${index}`);
glass(panel.g, x, y, w, h, accent);
label(name, x + 14, y + 10, panel.root);
text(panel.root, value, x + w - 14, y + h - 15, {
...display(14, fill),
anchorX: 1,
anchorY: 0.5,
maxWidth: Math.min(120, w - 28),
dropShadow: { color: fill, distance: 0, blur: 6, alpha: 0.7 },
});
rise(panel.root, 320 + index * 80);
});
// Judgement rows.
const judges = group('judgement');
const judgeBox = grid.judges;
glass(judges.g, judgeBox.x, judgeBox.y, judgeBox.w, judgeBox.h, SYN_EMBER);
label('JUDGEMENT', judgeBox.x + 14, judgeBox.y + 12, judges.root, SYN_EMBER);
const rows: ReadonlyArray<readonly [name: string, count: number, color: number]> = [
['PGREAT', result.score.perfect, SYN_FLARE],
['GREAT', result.score.great, SYN_AMBER],
['GOOD', result.score.good, SYN_CYAN],
['BAD', result.score.bad, SYN_MAGENTA],
['POOR', result.score.poor, SYN_RED],
];
const judgeTotal = Math.max(1, result.score.total);
rows.forEach(([name, count, color], index) => {
const y = grid.rowsTop + index * grid.rowPitch;
const grow = easeOutCubic(stageProgress(elapsed, ROLL_DELAY_MS + index * 70, ROLL_MS));
const x = judgeBox.x;
const barX = x + grid.barOffset;
judges.g.circle(x + 18, y + 6, 2.5).fill({ color, alpha: 1 });
judges.g.circle(x + 18, y + 6, 6).fill({ color, alpha: 0.2 });
label(name, x + 30, y + 2, judges.root, color);
judges.g.rect(barX, y + 6, grid.barWidth, 1).fill({ color: SYN_DIM, alpha: 0.35 });
const barW = (grid.barWidth * Math.min(count, judgeTotal) * grow) / judgeTotal;
if (barW > 0) {
judges.g.rect(barX, y + 4, barW, 5).fill({ color, alpha: 0.18 });
judges.g.rect(barX, y + 6, barW, 1.5).fill({ color, alpha: 0.95 });
}
text(judges.root, String(rollUpValue(count, roll)), x + judgeBox.w - 14, y + 6, {
...display(11, SYN_WHITE),
anchorX: 1,
anchorY: 0.5,
});
});
rise(judges.root, 520);
// Graphs as glowing filaments drawing in.
const graphs = group('graphs');
// The two filaments share the judgement rows' top and bottom lines.
const graphBox = grid.graphs;
const graphX = graphBox.x + 14;
const graphW = graphBox.x + graphBox.w - 14 - graphX;
const graphH = (grid.graphsBottom - grid.graphsTop - 24) / 2;
glass(graphs.g, graphBox.x, graphBox.y, graphBox.w, graphBox.h, accent);
label(
`${(result.gaugeGraphType ?? result.gaugeType ?? 'GROOVE').toUpperCase()} GAUGE`,
graphX,
graphBox.y + 12,
graphs.root,
);
label('EX SCORE', graphX, grid.graphsTop + graphH + 12, graphs.root);
const draw = easeOutCubic(stageProgress(elapsed, ROLL_DELAY_MS + 150, ROLL_MS + 300));
filament(
graphs.g,
graphX,
grid.graphsTop,
graphW,
graphH,
result.gaugeHistory.map((s) => ({ x: s.progress, y: s.value / 100 })),
cleared ? SYN_AMBER : SYN_RED,
draw,
);
filament(
graphs.g,
graphX,
grid.graphsBottom - graphH,
graphW,
graphH,
result.scoreHistory.map((s) => ({ x: s.progress, y: exMax > 0 ? s.exScore / exMax : 0 })),
SYN_CYAN,
draw,
);
rise(graphs.root, 600);
// Track column: the chart's card, its facts, and the clear lamp glowing at the foot.
const track = group('track');
const { x: trackX, y: trackTop, w: trackW, h: trackH } = grid.track;
glass(track.g, trackX, trackTop, trackW, trackH, accent);
const trackTextX = trackX + 14;
const trackTextW = trackW - 28;
const columns = grid.trackColumns;
const course = resolveResultCourseCard(result);
if (course !== undefined) {
// A course run lists the charts it played in place of one chart's facts.
label(course.kind, trackTextX, trackTop + 12, track.root, SYN_EMBER);
drawCourseCard(course, {
target: track.root,
g: track.g,
x: trackTextX,
top: trackTop,
w: trackTextW,
bottom: trackTop + trackH - (columns > 1 ? 44 : 50) - 8,
columns,
accent,
elapsedMs: frame.shownMs,
text,
label,
});
} else {
label('TRACK', trackTextX, trackTop + 12, track.root, SYN_EMBER);
// Genre, title, artist — the order every built-in skin uses.
const genreLift = result.chart.genre ? 14 : 0;
if (result.chart.genre) {
label(result.chart.genre.toUpperCase(), trackTextX, trackTop + 30, track.root, SYN_DIM, trackTextW);
}
text(track.root, result.chart.title || 'Untitled chart', trackTextX, trackTop + 30 + genreLift, {
size: 15,
weight: '500',
fill: SYN_WHITE,
fontFamily: SYN_TEXT_FONT,
maxWidth: trackTextW,
dropShadow: { color: accent, alpha: 0.7, blur: 6, distance: 0 },
});
text(track.root, result.chart.artist ?? '', trackTextX, trackTop + 52 + genreLift, {
size: 10,
weight: '300',
fill: SYN_MIST,
fontFamily: SYN_TEXT_FONT,
maxWidth: trackTextW,
});
track.g.rect(trackTextX, trackTop + 88, trackTextW, 1).fill({ color: accent, alpha: 0.3 });
// The fact rows run down one column (landscape) or fill two side by side (portrait), 34 / 30 px apart; a two-player
// play adds the 2P player's.
const columnGap = 24;
const columnW = (trackTextW - columnGap * (columns - 1)) / columns;
const rowPitch = columns > 1 ? 30 : 34;
[...resolveResultTrackRows(result), ...secondPlayerRows(result)].forEach((row, index) => {
const columnX = trackTextX + (index % columns) * (columnW + columnGap);
const rowY = trackTop + 100 + Math.floor(index / columns) * rowPitch;
label(row.label, columnX, rowY + 4, track.root, SYN_DIM, columnW - 50);
text(track.root, row.value, columnX + columnW, rowY + 9, {
...display(columns > 1 ? 13 : 15, SYN_WHITE),
anchorX: 1,
anchorY: 0.5,
maxWidth: columns > 1 ? 56 : trackTextW - 90,
});
track.g.rect(columnX, rowY + 24, columnW, 1).fill({ color: SYN_DIM, alpha: 0.3 });
});
}
const lamp = resolveResultLamp(result);
const lampColor =
lamp === 'PERFECT' ? SYN_WHITE : lamp === 'FULL COMBO' ? SYN_CYAN : lamp === 'CLEAR' ? SYN_AMBER : SYN_RED;
// The lamp sits 16 px off the card's foot (10 px under two fact columns, which take the room).
const lampY = trackTop + trackH - (columns > 1 ? 44 : 50);
drawFrame(track.g, trackTextX, lampY, trackTextW, 34, lampColor, { fill: 0.6, arm: 8 });
text(track.root, lamp, trackTextX + trackTextW / 2, lampY + 17, {
...display(14, SYN_WHITE),
anchorX: 0.5,
anchorY: 0.5,
letterSpacing: 4,
maxWidth: trackTextW - 16,
dropShadow: { color: lampColor, distance: 0, blur: 12, alpha: 1 },
});
rise(track.root, 680);
}
/**
* A course run's card in the track column: the course's name and how far the run went, then every stage chart in order
* (its number, title, level and artist), between the divider and `bottom`, each at its usual height. Stages past
* `bottom` are masked off, and the list scrolls up through them, fades out at the bottom and back in at the top to start
* over (`resolveResultCourseScroll`), so every stage is shown in turn; a stage the run never reached is dimmed. A
* portrait card closes up its header and lays the stages out in `columns` columns, which scroll together.
*/
function drawCourseCard(
course: ResultCourseCard,
area: {
target: Container;
g: Graphics;
x: number;
top: number;
w: number;
bottom: number;
columns: number;
accent: number;
/** How long the result has shown: the stage list scrolls by it. */
elapsedMs: number;
text: (target: Container, value: string, x: number, y: number, options: SkinTextOptions) => unknown;
label: (value: string, x: number, y: number, target: Container, fill?: number, maxWidth?: number) => unknown;
},
): void {
const { target, g, x, top, w, columns, accent, text, label } = area;
text(target, course.title || 'Untitled course', x, top + 30, {
size: 15,
weight: '500',
fill: SYN_WHITE,
fontFamily: SYN_TEXT_FONT,
maxWidth: w,
dropShadow: { color: accent, alpha: 0.7, blur: 6, distance: 0 },
});
// A portrait card is short: its header closes up so the stages get the room.
const compact = columns > 1;
label(course.detail, x, top + (compact ? 53 : 56), target, SYN_MIST, w);
const dividerY = top + (compact ? 68 : 88);
g.rect(x, dividerY, w, 1).fill({ color: accent, alpha: 0.3 });
const rowsTop = dividerY + 6;
const columnGap = 24;
const columnW = (w - columnGap * (columns - 1)) / columns;
const perColumn = Math.max(1, Math.ceil(course.stages.length / columns));
// Every stage keeps its usual height (a portrait card's a little shorter); the ones past `bottom` scroll into view.
const pitch = compact ? 34 : 40;
const viewH = Math.max(0, area.bottom - rowsTop);
const scroll = resolveResultCourseScroll(perColumn * pitch - viewH, area.elapsedMs);
const list = new Container();
list.label = 'synesthesia-result/course-stages';
list.y = -scroll.offsetPx;
list.alpha = scroll.alpha;
const lines = new Graphics();
list.addChild(lines);
const mask = new Graphics().rect(x - 2, rowsTop, w + 4, viewH).fill(0xffffff);
target.addChild(list, mask);
list.mask = mask;
const numberW = 24;
const levelW = 34;
course.stages.forEach((stage, index) => {
const column = Math.floor(index / perColumn);
const rowX = x + column * (columnW + columnGap);
const rowY = rowsTop + (index % perColumn) * pitch;
const row = new Container();
row.label = `synesthesia-result/course-stage-${stage.stage}`;
row.alpha = stage.played ? 1 : 0.35;
list.addChild(row);
const middle = rowY + 9;
text(row, String(stage.stage).padStart(2, '0'), rowX, middle, {
size: 11,
fill: SYN_EMBER,
fontFamily: SYN_DISPLAY_FONT,
anchorY: 0.5,
});
text(row, stage.title || 'Untitled chart', rowX + numberW, middle, {
size: 12,
weight: '500',
fill: SYN_WHITE,
fontFamily: SYN_TEXT_FONT,
anchorY: 0.5,
maxWidth: columnW - numberW - levelW,
});
text(row, stage.level, rowX + columnW, middle, {
size: 12,
fill: SYN_WHITE,
fontFamily: SYN_DISPLAY_FONT,
anchorX: 1,
anchorY: 0.5,
maxWidth: levelW - 4,
});
if (stage.artist !== undefined) {
text(row, stage.artist, rowX + numberW, rowY + 23, {
size: 9,
weight: '300',
fill: SYN_MIST,
fontFamily: SYN_TEXT_FONT,
anchorY: 0.5,
maxWidth: columnW - numberW,
});
}
lines.rect(rowX, rowY + pitch - 3, columnW, 1).fill({ color: SYN_DIM, alpha: 0.3 });
});
}
/** The 2P player's rows of a two-player play (LR2 BATTLE): its EX score and gauge. */
function secondPlayerRows(result: BeMusicResultData): ResultTrackRow[] {
const second = result.secondPlayer;
if (second === undefined) return [];
return [
{ label: '2P EX', value: `${second.score.exScore}/${second.score.total * 2}` },
{ label: '2P GAUGE', value: `${Math.round(second.gauge)}%` },
];
}
function glass(graphics: Graphics, x: number, y: number, w: number, h: number, rim: number): void {
drawFrame(graphics, x, y, w, h, rim, { fill: 0.96, arm: 10 });
}
/**
* Polyline drawn up to `progress` of its horizontal span, stroked twice (bloom + filament) with a glowing head. The
* graphs sample on every judgment, so samples a few milliseconds apart (a judgment and an empty POOR) sit within a
* fraction of a pixel: those are thinned out first, as a near-zero-length segment breaks the stroke's joins into stray
* fans on the bloom. The joins are round: a gauge that drops and climbs back within a few pixels turns the line by
* nearly 180°, and a miter join there juts far past the curve.
*/
export function filament(
graphics: Graphics,
x: number,
y: number,
w: number,
h: number,
points: ReadonlyArray<{ x: number; y: number }>,
color: number,
progress: number,
): void {
graphics.rect(x, y + h, w, 1).fill({ color: SYN_DIM, alpha: 0.3 });
Iif (points.length === 0 || progress <= 0) return;
const clamp = (value: number) => (Number.isFinite(value) ? Math.max(0, Math.min(1, value)) : 0);
const path: number[] = [];
let previous = points[0]!;
path.push(x + clamp(previous.x) * w, y + (1 - clamp(previous.y)) * h);
for (let index = 1; index < points.length; index += 1) {
const point = points[index]!;
if (clamp(point.x) > progress) {
const span = clamp(point.x) - clamp(previous.x);
const t = span > 0 ? (progress - clamp(previous.x)) / span : 0;
path.push(x + progress * w, y + (1 - (clamp(previous.y) + (clamp(point.y) - clamp(previous.y)) * t)) * h);
break;
}
path.push(x + clamp(point.x) * w, y + (1 - clamp(point.y)) * h);
previous = point;
}
const line = thinPolyline(path, 1);
Iif (line.length < 4) line.push(line[0]! + 0.5, line[1]!);
graphics.poly(line, false).stroke({ color, width: 5, alpha: 0.12, join: 'round' });
graphics.poly(line, false).stroke({ color, width: 1.5, alpha: 0.95, join: 'round' });
const headX = line[line.length - 2]!;
const headY = line[line.length - 1]!;
graphics.circle(headX, headY, 6).fill({ color, alpha: 0.2 });
graphics.circle(headX, headY, 2).fill({ color: SYN_WHITE, alpha: 1 });
}
/**
* The polyline `[x0, y0, x1, y1, …]` without the points closer than `minGap` to the last point kept. The first and last
* points stay: the last replaces a kept point too close to it, so the line still ends where it did.
*/
export function thinPolyline(path: readonly number[], minGap: number): number[] {
if (path.length <= 4) return [...path];
const line = [path[0]!, path[1]!];
const near = (x: number, y: number) => Math.hypot(x - line[line.length - 2]!, y - line[line.length - 1]!) < minGap;
for (let index = 2; index < path.length - 2; index += 2) {
if (!near(path[index]!, path[index + 1]!)) line.push(path[index]!, path[index + 1]!);
}
const lastX = path[path.length - 2]!;
const lastY = path[path.length - 1]!;
if (line.length > 2 && near(lastX, lastY)) line.length -= 2;
line.push(lastX, lastY);
return line;
}
|