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 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 | 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x 24x | import { drawQuickPlayOptions, LANDSCAPE_QUICK_OPTIONS_INSET } from './select-play-options.ts';
import { formatSelectBreadcrumb } from './layout.ts';
import { Container, Graphics, Sprite, Texture } from 'pixi.js';
import { bindGlassSurface, drawGlassSurface, frostedGlassEnabled } from './glass.ts';
import { createFlock, stepFlock } from './boids.ts';
import { ChargeCloud } from './charge-cloud.ts';
import { KICK_REST, stepKick, type KickState } from './kick.ts';
import { drawPointCloud, drawReticle, drawSchool, sharedShapeBatch } from './draw.ts';
import {
floorRise,
flyPast,
cameraBasis,
emberColor,
hsvToHex,
mixCamera,
particleRiverPointInto,
pointCloudPyramid,
projectPoint,
projectViewInto,
REST_CAMERA,
roamingCamera,
scratchProjected,
viewPoint,
wanderPoint,
type RiverOptions,
} from './space.ts';
import {
SPECTRUM_RIDGE_HEIGHT,
SpectrumHistory,
floorRowStep,
spectrumLevels,
spectrumRise,
} from './spectrum-floor.ts';
import {
SYN_AMBER,
SYN_DIM,
SYN_DISPLAY_FONT,
SYN_FLARE,
SYN_MIST,
SYN_TEXT_FONT,
SYN_VOID,
SYN_WHITE,
sceneHue,
synGlowTexture,
} from './style.ts';
import {
AUDIO_BAND_COUNT,
easeOutCubic,
audioDrive,
type BeMusicAudioFrame,
type BeMusicSelectLayout,
type LibraryEntry,
type LibraryChart,
describeBestRecord,
describeCourseCard,
formatPlayVariantLabel,
resolveChartStats,
resolveDifficultyName,
hash01,
resolveChartRowFacts,
stageProgress,
selectListRows,
browseEntryBadge,
browseEntryCount,
browseEntryTitle,
type BeMusicChartBestRecord,
type BestRecordSummary,
} from '@be-music/player-skin-sdk';
import {
addHitArea,
type PixiSelectFrame,
type PixiSelectRenderer,
type PixiSelectSkin,
type SkinTextOptions,
fadeChildrenFrom,
} from '../pixi-kit/index.ts';
import { addSynesthesiaText } from './figures.ts';
import { drawSelectEntryArrow, drawSelectEntryIcon, drawSelectEntryMark } from './select-entry-mark.ts';
import { drawBarLamp, drawBestRecordPanel, LampLights } from './select-record.ts';
import {
recordLaunchHandoff,
resolveDecideLayout,
resolveLaunchWarp,
resolveWarpStarSpeed,
SELECT_LAUNCH_OUTRO_MS,
} from './launch-warp.ts';
import {
createWarpStarScratch,
drawLaunchTitle,
paintSpace,
poseWarpStar,
resolveStarTrail,
STAR_COUNT,
WARP_STAR_COUNT,
} from './warp-field.ts';
const LAYOUT: BeMusicSelectLayout = { listX: 322, listTop: 92, listBottomInset: 65, rowHeight: 28 };
/**
* The portrait list: full width under the focused-song card and the search bar, with taller rows (two lines each, and
* a thumb's height to tap).
*/
const PORTRAIT_LAYOUT: BeMusicSelectLayout = { listX: 16, listTop: 456, listBottomInset: 99, rowHeight: 36 };
/** The focused-song card on the portrait stage. */
const PORTRAIT_CARD = { x: 12, y: 52, w: 456, h: 348 } as const;
/** Fixed widths of a song row's fact columns (right to left: tempo, length, note count), so they align down the list. */
const ROW_BPM_W = 76;
const ROW_LENGTH_W = 30;
const ROW_NOTES_W = 84;
/**
* Where a row's level orb and title start from its left edge, landscape and portrait: clear of the clear lamp and its
* glow along the edge.
*/
const ROW_LEVEL_X = 22;
const ROW_TITLE_X = 40;
const PORTRAIT_ROW_LEVEL_X = 25;
const PORTRAIT_ROW_TITLE_X = 45;
/** The DJ Rank column of a song row, left of the note count. */
const ROW_RANK_W = 24;
/** How faint a course that cannot start is drawn in the list. */
const DISABLED_ROW_ALPHA = 0.45;
/**
* The widest a folder or course row's count may run (`12 charts`, `4 stages · 1 missing`): such a row has no fact
* columns, so its count takes what it needs up to this and the title gets the rest.
*/
const ROW_COUNT_MAX_W = 150;
const SLIDE_MS = 320;
const INTRO_STAGGER_MS = 45;
const RIVER_PARTICLES = 340;
/** How far the select camera roams around the pyramid field. */
const CAMERA_RANGE = { x: 240, y: 110, yaw: 0.38, pitch: 0.16 } as const;
const CAMERA_CYCLE_S = 6;
const SCHOOL_SIZE = 80;
/** Screen gap (px) the floor rows' points aim for, so near rows read as waveforms. */
const FLOOR_SCREEN_GAP = 6;
/**
* Three schools in the floor frame (floor at y 150), each with its own box, light, and seed, and each glowing with its
* own range of the music: the ember school with the bass, the blue with the mids, the magenta with the highs.
*/
const SCHOOL_SPECS = [
{
seed: 29,
palette: 'ember',
band: 'bass',
bounds: { minX: -700, maxX: 500, minY: -240, maxY: 90, minZ: 140, maxZ: 900 },
},
{
seed: 57,
palette: 'blue',
band: 'mid',
bounds: { minX: -300, maxX: 900, minY: -300, maxY: 40, minZ: 300, maxZ: 1300 },
},
{
seed: 91,
palette: 'magenta',
band: 'high',
bounds: { minX: -900, maxX: 900, minY: -280, maxY: 60, minZ: 800, maxZ: 1900 },
},
] as const;
/** Depth the world shots pivot around — the pyramid field. */
const WORLD_ORBIT = 900;
const PYRAMIDS = [pointCloudPyramid(12, 900), pointCloudPyramid(4, 560), pointCloudPyramid(9, 520)];
export const synesthesiaSelectSkin: PixiSelectSkin = {
outroMs: SELECT_LAUNCH_OUTRO_MS,
searchTextSize: 10,
portraitSearchTextSize: 11,
layout: LAYOUT,
portraitLayout: PORTRAIT_LAYOUT,
createRenderer: () => new SynesthesiaSelectRenderer(),
};
function labelStyle(fill: number = SYN_DIM): SkinTextOptions {
return { size: 9, fill, fontFamily: SYN_DISPLAY_FONT, letterSpacing: 2 };
}
/**
* `JUDGE <rank>` (the chart's #RANK / #DEFEXRANK), starting at `left` and centred on `centerY`. Label and value share one
* size, so their capitals line up top and bottom; colour and tracking tell them apart.
*/
function drawJudgeRank(
addText: (text: string, x: number, y: number, options?: SkinTextOptions) => Container,
chartEntry: LibraryChart | undefined,
left: number,
centerY: number,
): void {
const label = addText('JUDGE', left, centerY, { ...labelStyle(), anchorY: 0.5 });
addText(chartEntry ? resolveChartStats(chartEntry).judgeRank : '-', left + label.width + 8, centerY, {
size: 9,
fill: SYN_WHITE,
fontFamily: SYN_DISPLAY_FONT,
anchorY: 0.5,
dropShadow: { color: SYN_WHITE, distance: 0, blur: 6, alpha: 0.4 },
});
}
function drawDifficulty(
graphics: Graphics,
addText: (text: string, x: number, y: number, options?: SkinTextOptions) => Container,
chart: LibraryChart | undefined,
x: number,
y: number,
): void {
const label = addText('DIFFICULTY', x, y, { ...labelStyle(), anchorY: 0.5 });
const badgeX = x + label.width + 10;
graphics.rect(badgeX, y - 8, 108, 16).stroke({ color: SYN_AMBER, width: 1, alpha: 0.7 });
addText(resolveDifficultyName(chart) ?? '-', badgeX + 54, y, {
...labelStyle(),
fill: SYN_AMBER,
anchorY: 0.5,
maxWidth: 98,
anchorX: 0.5,
});
}
/**
* A secondary button (AUTO, README): an outline with corner reticles and its label centred in the display face. A
* disabled one (a chart with no README) is drawn faint.
*/
function drawSecondaryButton(
chrome: Graphics,
addText: (text: string, x: number, y: number, options?: SkinTextOptions) => Container,
label: string,
x: number,
y: number,
w: number,
h: number,
size: number,
enabled: boolean,
letterSpacing = 3,
): void {
chrome.rect(x, y, w, h).stroke({ color: SYN_MIST, width: 1, alpha: enabled ? 0.45 : 0.15 });
drawReticle(chrome, x, y, w, h, SYN_MIST, enabled ? 0.8 : 0.25, { arm: 5, width: 1 });
addText(label, x + w / 2, y + h / 2, {
size,
fill: SYN_MIST,
fontFamily: SYN_DISPLAY_FONT,
letterSpacing,
anchorX: 0.5,
anchorY: 0.5,
alpha: enabled ? 1 : 0.3,
});
}
/** The README chip's size: a small outline on the info card's genre line. */
const README_CHIP_W = 56;
const README_CHIP_H = 18;
/**
* README at (`x`, `y`): a small outlined chip that opens the chart's README, drawn faint and without a hit area on a
* chart that has none.
*/
function drawReadmeChip(
chrome: Graphics,
addText: (text: string, x: number, y: number, options?: SkinTextOptions) => Container,
frame: PixiSelectFrame,
x: number,
y: number,
): void {
const enabled = frame.hasReadme === true;
drawSecondaryButton(chrome, addText, 'README', x, y, README_CHIP_W, README_CHIP_H, 8, enabled, 2);
if (enabled) addHitArea(x - 2, y - 4, README_CHIP_W + 4, README_CHIP_H + 8, 'pointer', frame.actions.toggleReadme);
}
function framePanel(graphics: Graphics, x: number, y: number, w: number, h: number, rim: number): void {
drawGlassSurface(graphics, x, y, w, h, 0.94);
graphics.rect(x, y, w, h).stroke({ color: rim, width: 1, alpha: 0.28 });
drawReticle(graphics, x - 1, y - 1, w + 2, h + 2, SYN_WHITE, 0.85, { arm: 10, width: 1.25 });
}
/**
* Synesthesia song select, set in a cosmic particle world. The persistent back layer is a particle world — data dust
* pouring out of the vanishing point at the focused chart's tempo, point-cloud pyramids, a floor of light points, a
* golden river of particles, and a roaming visualizer-style audio orb — redrawn cheaply in `tick`. The front layer snaps a lock-on reticle onto the focused card.
*/
class SynesthesiaSelectRenderer implements PixiSelectRenderer {
private banner: { image: ImageBitmap; texture: Texture } | undefined;
private drawBanner(
frame: PixiSelectFrame,
x: number,
y: number,
width: number,
maxHeight: number,
fillWidth = false,
): void {
const image = frame.focusedChart ? frame.chartImage(frame.focusedChart, 'banner') : undefined;
if (this.banner?.image !== image) {
this.banner?.texture.destroy(true);
this.banner = image ? { image, texture: Texture.from(image) } : undefined;
}
if (!this.banner || !image || maxHeight <= 0) return;
const scale = fillWidth ? width / image.width : Math.min(width / image.width, maxHeight / image.height);
const height = image.height * scale;
const sprite = new Sprite(this.banner.texture);
sprite.position.set(x, y - Math.max(0, height - maxHeight) / 2);
sprite.width = image.width * scale;
sprite.height = height;
frame.layer.addChild(sprite);
if (height > maxHeight) {
// Tall artwork still fills the card width; the card clips the excess evenly at the top and bottom.
const mask = new Graphics().rect(x, y, width, maxHeight).fill(SYN_WHITE);
frame.layer.addChild(mask);
sprite.mask = mask;
}
}
public readonly backLayer = new Container();
public readonly frontLayer = new Container();
private readonly glass = new Graphics();
private readonly ground = new Graphics();
/** Additive particle world: floor, pyramids, river, and the orb's tails. */
private readonly world = new Graphics();
private readonly stars: Sprite[] = [];
/** Holds {@link stars}; the one layer that stays lit through the launch warp. */
private readonly starLayer = new Container();
/** Scratch objects for the allocation-free projection in `tick`'s per-particle loops. */
private readonly scratchBasis = cameraBasis(REST_CAMERA);
private readonly scratchPoint = { x: 0, y: 0, z: 0 };
private readonly scratchHead = scratchProjected();
private readonly scratchTail = scratchProjected();
private readonly starScratch = createWarpStarScratch();
private readonly riverOptions: RiverOptions = { length: 1800, speed: 120, amplitude: 36, width: 20, seed: 2 };
/** Each star's trail during the launch warp, drawn behind the stars. */
private readonly trails = new Graphics();
private readonly lock = new Graphics();
private readonly cursorGlow = new Sprite();
private cursorChangedAt = Number.NEGATIVE_INFINITY;
/** The foreground orb: a charge cloud, and the clock of its last simulation step. */
private readonly chargeCloud = new ChargeCloud();
/** Whether this rebuild's panels are frosted (the skin's frosted glass setting). */
private frosted = true;
private lastOrbSeconds: number | undefined;
/** The low end's kick envelope, which puffs up the fish. */
private kick: KickState = KICK_REST;
private readonly flocks = SCHOOL_SPECS.map((spec) => createFlock(spec.seed, SCHOOL_SIZE, spec.bounds));
private built = false;
private designWidth = 640;
private designHeight = 480;
/** Accumulated star / grid travel (speed-weighted seconds), so a speed change never makes the field jump. */
private travel = 0;
/** The recent spectrum the floor is shaped from (see spectrum-floor.ts). */
private readonly spectrum = new SpectrumHistory();
private readonly spectrumScratch = new Float32Array(AUDIO_BAND_COUNT);
private lastTickMs: number | undefined;
private effects: PixiSelectFrame['effects'] = 'full';
private activeCard: { x: number; y: number; w: number; h: number } | undefined;
/** This rebuild's clear lamps, blinking and cycling in `tick`. */
private readonly lampLights = new LampLights();
public constructor() {
this.backLayer.label = 'synesthesia-select/space';
this.frontLayer.label = 'synesthesia-select/front';
}
public render(input: PixiSelectFrame): boolean {
this.effects = input.effects;
this.frosted = frostedGlassEnabled(input.settings);
const frame =
input.effects === 'off'
? { ...input, sceneStartedAt: Number.NEGATIVE_INFINITY, cursorChangedAt: Number.NEGATIVE_INFINITY }
: input;
this.ensureBuilt(frame.designWidth, frame.designHeight);
this.activeCard = undefined;
this.lampLights.reset();
this.glass.clear();
const portrait = frame.designHeight > frame.designWidth;
let needsFrame = portrait ? this.renderPortraitChrome(frame) : this.renderChrome(frame);
const layout = portrait ? PORTRAIT_LAYOUT : LAYOUT;
const listWidth = frame.designWidth - layout.listX - (portrait ? 12 : 14);
// Rows follow the list's pull (`frame.listScroll`): fractional slots, faded where they slide past the window's edge.
for (const { entryIndex, slot, alpha } of selectListRows(frame, layout.rowHeight)) {
const entry = frame.entries[entryIndex]!;
const from = frame.layer.children.length;
needsFrame =
(portrait
? this.renderPortraitRow(frame, entry, entryIndex, slot, listWidth)
: this.renderRow(frame, entry, entryIndex, slot, listWidth)) || needsFrame;
// A course that cannot start (a stage missing) is drawn faint, as a disabled control is.
const disabled = entry.kind === 'course' && !entry.course.playable;
fadeChildrenFrom(frame.layer, from, disabled ? alpha * DISABLED_ROW_ALPHA : alpha);
}
const visible = this.activeCard !== undefined;
this.cursorGlow.visible = visible;
this.lock.visible = visible;
this.cursorChangedAt = frame.cursorChangedAt;
if (frame.launchAt !== undefined) {
this.renderOutro(frame);
this.lampLights.settle();
return true;
}
this.lampLights.settle();
return needsFrame;
}
/**
* Launch outro — the start of the warp: the panels and list fade away while the camera settles onto a straight dash
* through the particle field (in `tick`), and the chosen title starts to condense at the centre out of wide-tracked
* light, a lock-on reticle closing around it. The decide screen carries the warp on from here (see launch-warp.ts).
*/
private renderOutro(frame: PixiSelectFrame): void {
const pose = resolveLaunchWarp(frame.nowMs - (frame.launchAt ?? frame.nowMs), frame.effects);
const { designWidth, designHeight, layer } = frame;
// Fade the list and panels out of the way, leaving black space and the particles rushing past.
const away = pose.away;
for (const child of layer.children) {
child.alpha *= away;
if (child.label === 'synesthesia-select/header') child.y -= 38 * (1 - away);
if (child.label === 'synesthesia-select/footer') child.y += 32 * (1 - away);
}
drawLaunchTitle(layer, frame.focusedChart, resolveDecideLayout(designWidth, designHeight), designWidth, pose, 1);
}
public tick(
nowMs: number,
focusedChart: LibraryChart | undefined,
launchAt?: number,
audio?: BeMusicAudioFrame,
): void {
this.lampLights.tick(nowMs, this.effects === 'off');
// Ambient motion: frozen with effects off, half speed when reduced.
const rate = this.effects === 'off' ? 0 : this.effects === 'reduced' ? 0.5 : 1;
// The BGM / chart preview drives the space: dust speeds with loudness, the floor swells on the bass,
// the schools pulse, and the orb's orbits breathe with the spectrum.
const drive = audioDrive(audio, this.effects);
const seconds = (nowMs / 1000) * rate;
const dt = this.lastTickMs === undefined ? 0 : Math.min(0.1, (nowMs - this.lastTickMs) / 1000);
this.lastTickMs = nowMs;
// Kicks puff up the fish.
this.kick = stepKick(this.kick, drive.bands, drive.onset, dt);
const launch = launchAt !== undefined ? resolveLaunchWarp(nowMs - launchAt, this.effects) : undefined;
const warp = launch?.warp ?? 0;
const bpm = focusedChart?.bpm;
const beatsPerSecond = (bpm !== undefined && Number.isFinite(bpm) && bpm > 0 ? Math.min(bpm, 300) : 120) / 60;
const beatPhase = (seconds * beatsPerSecond) % 1;
const pulse = (1 - beatPhase) ** 3;
const hue = sceneHue(seconds, beatPhase);
const accent = hsvToHex(hue, 0.6, 1);
// Camera: the backdrop roams between random shots (flying, sometimes hard-cutting) with a handheld drift.
// Reduced effects halve the moves; off keeps it at rest.
// On launch the camera settles and flies dead straight, so the warp reads as a dash through the particles.
const settle = launch?.settle ?? 0;
const camera = mixCamera(
REST_CAMERA,
roamingCamera(seconds, 13, CAMERA_RANGE, CAMERA_CYCLE_S),
(this.effects === 'off' ? 0 : this.effects === 'reduced' ? 0.5 : 1) * (1 - settle),
);
// Data dust pouring out of the vanishing point — speed follows the focused chart's tempo. Launching steers the
// vanishing point to the centre of the screen, where the chosen title appears, and opens the throttle — kept to a
// speed the eye can follow, with each particle trailing its own path so the dash reads as forward motion.
const cx = this.designWidth * (0.58 - 0.08 * settle);
const cy = this.designHeight * (0.44 + 0.06 * settle);
const speed = resolveWarpStarSpeed(bpm, warp, this.effects, drive.level);
const trail = resolveStarTrail(speed, warp, settle);
const trails = this.trails;
trails.clear();
this.travel += dt * speed * (warp > 0 ? 1 : rate);
const basis = cameraBasis(camera, this.scratchBasis);
const shownStars = Math.round(STAR_COUNT + (WARP_STAR_COUNT - STAR_COUNT) * settle);
for (let index = 0; index < this.stars.length; index += 1) {
const star = this.stars[index]!;
if (index >= shownStars) {
star.visible = false;
continue;
}
poseWarpStar(star, trails, index, this.travel, basis, cx, cy, warp, trail, this.starScratch);
}
sharedShapeBatch.flush();
// The decide screen carries the warp on from this frame.
if (launchAt !== undefined && focusedChart !== undefined) {
recordLaunchHandoff({
chartId: focusedChart.id,
launchAtMs: launchAt,
lastFrameMs: nowMs,
travel: this.travel,
level: drive.level,
});
}
// The cursor's lock-on lets go as the warp starts, and everything but the rushing particles falls away, so the
// decide screen takes over a sky of stars alone.
this.frontLayer.alpha = 1 - settle;
const behind = 1 - settle;
for (const node of this.backLayer.children) {
if (node !== this.starLayer && node !== this.trails && node !== this.ground) node.alpha = behind;
}
const world = this.world;
world.clear();
const floorY = this.designHeight * 0.7;
// Point-cloud pyramids, far to near.
const view = { cx, cy: floorY, focal: 200, camera, orbit: WORLD_ORBIT };
for (const [pyramid, x, z, scale, yaw] of [
[PYRAMIDS[0]!, -120, 1700, 700, 0.3],
[PYRAMIDS[1]!, -760, 1100, 420, 0.7],
[PYRAMIDS[2]!, 620, 1250, 440, -0.4],
] as const) {
drawPointCloud(world, pyramid, { scale, x, y: 150, z, yaw: yaw + seconds * 0.03 }, view, {
colorOf: (point) => emberColor(0.3 + 0.6 * point.weight),
alpha: 0.7 * (1 - warp),
size: 0.9,
seconds,
shimmer: 0.3,
referenceScale: 200 / (200 + z),
});
}
// Floor of light points scrolling toward the viewer, written with the music's spectrum: bass on the left to highs on
// the right, rising as ridges that leave the viewer and roll out into the distance, over low Perlin-noise ground.
this.spectrum.push(spectrumLevels(drive.bands, this.spectrumScratch), dt);
const spacing = 100;
const offset = this.travel % spacing;
// Floor points and the river go out as a few batched instructions.
const batch = sharedShapeBatch;
for (let z = spacing - offset; z < 2600; z += spacing) {
const nearness = 1 - z / 2600;
const size = 0.6 + 1.5 * nearness * nearness;
const color = emberColor(0.3 + 0.65 * nearness);
const alpha = Math.min(1, (0.12 + 0.7 * nearness * nearness) * (0.7 + 0.3 * pulse) * (1 + drive.bass));
// Near rows get more points, so they read as continuous waveforms.
const step = floorRowStep(z, 200, FLOOR_SCREEN_GAP);
for (let x = -1800; x <= 1800; x += step) {
// The band follows where the point sits on screen: bass at the left edge, highs at the right.
const ground = projectViewInto(this.scratchHead, x, 150, z, basis, cx, floorY, 200, WORLD_ORBIT);
if (!ground.visible || ground.x < -4 || ground.x > this.designWidth + 4) continue;
const ridge = spectrumRise(this.spectrum, ground.x / this.designWidth, z);
const rise = ridge + floorRise(x, z + this.travel, seconds, 10);
const point = projectViewInto(this.scratchHead, x, 150 - rise, z, basis, cx, floorY, 200, WORLD_ORBIT);
if (!point.visible || point.x < -4 || point.x > this.designWidth + 4 || point.y > this.designHeight + 4) {
continue;
}
// Crests catch more light than the valleys.
const lit = Math.min(1, alpha * (1 + (1.4 * ridge) / SPECTRUM_RIDGE_HEIGHT));
batch.rect(world, color, lit, point.x - size / 2, point.y - size / 2, size, size);
}
}
// A golden river of particles sweeping across the floor.
const riverOptions = this.riverOptions;
riverOptions.speed = 120 + beatsPerSecond * 60;
riverOptions.amplitude = 36 * (1 + 1.3 * drive.mid);
const local = this.scratchPoint;
for (let index = 0; index < RIVER_PARTICLES; index += 1) {
particleRiverPointInto(local, index, this.travel / 90, riverOptions);
const y = 110 + local.y;
const z = 620 + local.z;
const head = projectViewInto(
this.scratchHead,
local.x,
y,
z + local.x * 0.5,
basis,
cx,
floorY,
200,
WORLD_ORBIT,
);
const tailX = local.x - 30;
const tail = projectViewInto(this.scratchTail, tailX, y, z + tailX * 0.5, basis, cx, floorY, 200, WORLD_ORBIT);
if (!head.visible || !tail.visible) continue;
const heat = hash01(index * 3 + 7);
batch.line(
world,
heat > 0.85 ? SYN_WHITE : emberColor(0.5 + 0.5 * heat),
(0.25 + 0.55 * heat) * (1 - warp),
0.4 + 1 * Math.min(1, head.scale) * (0.5 + heat),
tail.x,
tail.y,
head.x,
head.y,
);
}
batch.flush();
// Schools of light fish sweeping through the pyramids: tight on the beat, scattering when the cursor moves.
if (rate > 0) {
const scatter = Math.max(Math.max(0, 1 - (nowMs - this.cursorChangedAt) / 600) ** 2, 0.8 * drive.onset) + warp;
const shown = this.effects === 'reduced' ? 1 : this.flocks.length;
for (let school = 0; school < shown; school += 1) {
stepFlock(this.flocks[school]!, dt * rate, {
seconds: seconds + school * 41.7,
gather: Math.max(pulse * 0.6, drive.bass),
scatter,
});
drawSchool(
world,
this.flocks[school]!,
(out, point) => projectViewInto(out, point.x, point.y, point.z, basis, cx, floorY, 200, WORLD_ORBIT),
{
alpha: 0.95 * (1 - warp),
palette: SCHOOL_SPECS[school]!.palette,
swell: this.kick.swell,
glowLevel: drive[SCHOOL_SPECS[school]!.band],
seconds,
},
);
}
}
// The audio orb roams the space right up by the camera; on launch the camera flies past it, so it streams out of
// the vanishing point with the stars, swelling until it leaves the screen.
const big = wanderPoint(seconds * 0.6, 5, { minX: -210, maxX: 230, minY: -140, maxY: -20, minZ: -70, maxZ: 150 });
// The foreground orb is a charge cloud: dark magnet orbs in a fluid of particles, stepped on the GPU.
const bigAt = projectPoint(viewPoint(big, camera, WORLD_ORBIT), cx, floorY, 200);
const passing = flyPast(bigAt.x, bigAt.y, 135 * bigAt.scale * (1 + 0.03 * pulse), cx, cy, warp);
this.chargeCloud.update({
x: passing.x,
y: passing.y,
scale: bigAt.visible ? passing.scale : 0,
seconds,
dt: this.lastOrbSeconds === undefined ? 0 : seconds - this.lastOrbSeconds,
drive,
alpha: bigAt.visible ? passing.alpha : 0,
});
this.lastOrbSeconds = seconds;
// Lock-on reticle snapping onto the focused card, plus a breathing glow under it.
const card = this.activeCard;
this.lock.clear();
if (card) {
const snap = easeOutCubic(stageProgress(nowMs - this.cursorChangedAt, 0, 220));
const grow = 18 * (1 - snap);
drawReticle(
this.lock,
card.x - 5 - grow,
card.y - 4 - grow * 0.5,
card.w + 10 + grow * 2,
card.h + 8 + grow,
SYN_FLARE,
0.5 + 0.5 * snap,
{ arm: 9, width: 1.75 },
);
this.cursorGlow.position.set(card.x + card.w / 2, card.y + card.h / 2);
this.cursorGlow.width = card.w * 1.15;
this.cursorGlow.height = card.h * 3.2;
this.cursorGlow.tint = accent;
this.cursorGlow.alpha = 0.16 + 0.18 * pulse;
}
}
public dispose(): void {
this.banner?.texture.destroy(true);
this.banner = undefined;
this.chargeCloud.destroy();
this.backLayer.destroy({ children: true });
this.frontLayer.destroy({ children: true });
}
private ensureBuilt(designWidth: number, designHeight: number): void {
// The stage can change between draws (a rotation): the ground is repainted for the new size.
if (designWidth !== this.designWidth || designHeight !== this.designHeight || !this.built) {
this.designWidth = designWidth;
this.designHeight = designHeight;
paintSpace(this.ground, designWidth, designHeight);
}
if (this.built) return;
this.built = true;
const glow = synGlowTexture();
const starLayer = this.starLayer;
starLayer.blendMode = 'add';
for (let index = 0; index < WARP_STAR_COUNT; index += 1) {
const star = new Sprite(glow);
star.anchor.set(0.5);
star.blendMode = 'add';
starLayer.addChild(star);
this.stars.push(star);
}
this.world.blendMode = 'add';
this.trails.blendMode = 'add';
this.backLayer.addChild(this.ground, this.world, this.trails, starLayer, this.chargeCloud.view, this.glass);
this.cursorGlow.texture = glow;
this.cursorGlow.anchor.set(0.5);
this.cursorGlow.blendMode = 'add';
this.frontLayer.addChild(this.cursorGlow, this.lock);
}
private renderChrome(frame: PixiSelectFrame): boolean {
const { layer, designWidth, designHeight, entries, focusedChart: chartEntry } = frame;
const chrome = new Graphics();
if (this.frosted) bindGlassSurface(chrome, this.glass);
chrome.label = 'synesthesia-select/chrome';
const hue = sceneHue(frame.nowMs / 1000);
const accent = hsvToHex(hue, 0.6, 1);
const addText = (text: string, x: number, y: number, options: SkinTextOptions = {}) => {
const node = addSynesthesiaText(layer, text, x, y, options);
if (y < 38) node.label = 'synesthesia-select/header';
else if (y >= designHeight - 36) node.label = 'synesthesia-select/footer';
return node;
};
// A focused course takes the song's place: its name, then its kind and stage count.
const course =
chartEntry === undefined && frame.focusedCourse !== undefined
? describeCourseCard(frame.focusedCourse, frame.courseBestRecord?.(frame.focusedCourse))
: undefined;
const chartTitle = chartEntry?.title ?? course?.title ?? 'No chart selected';
const chartArtist = chartEntry?.artist || chartEntry?.subtitle || course?.detail || '';
const playLevel = chartEntry?.playLevel !== undefined ? String(chartEntry.playLevel) : '-';
const chartBPM = chartEntry?.bpm !== undefined ? String(Math.round(chartEntry.bpm)) : '-';
const modeLabel = chartEntry ? formatPlayVariantLabel(chartEntry) : '- KEYS';
const categoryName = formatSelectBreadcrumb(frame.folderPath, frame.folderLabel, frame.searchQuery);
const position =
entries.length > 0 ? `${Math.min(frame.selectedIndex + 1, entries.length)} / ${entries.length}` : '0 / 0';
// Header: title as light, a hairline, and the folder on the right.
const header = new Graphics();
header.label = 'synesthesia-select/header';
layer.addChild(header);
header.rect(0, 0, designWidth, 38).fill({ color: SYN_VOID, alpha: 0.5 });
header.rect(0, 38, designWidth, 1).fill({ color: accent, alpha: 0.5 });
const intro = easeOutCubic(stageProgress(frame.nowMs - frame.sceneStartedAt, 0, 900));
addText('MUSIC SELECT', 18, 13, {
size: 12,
fill: SYN_WHITE,
fontFamily: SYN_DISPLAY_FONT,
letterSpacing: 4 + 8 * (1 - intro) + 2,
alpha: intro,
dropShadow: { color: accent, distance: 0, blur: 8, alpha: 0.9 },
});
addText(categoryName, designWidth - 18, 6, {
size: 10,
weight: '500',
fill: SYN_MIST,
fontFamily: SYN_TEXT_FONT,
anchorX: 1,
maxWidth: designWidth - 300,
});
const scope = frame.searchQuery ? 'SEARCH RESULTS' : frame.folderLabel ? 'CHARTS' : 'FOLDERS';
addText(`${scope} · ${entries.length} shown / ${frame.totalCharts} charts`, designWidth - 18, 22, {
...labelStyle(),
anchorX: 1,
maxWidth: designWidth - 300,
});
// Info panel.
const cardTop = 56;
const bannerTop = 351;
const bannerWidth = 258;
const bannerBottomPadding = 12;
const cardBottom = designHeight - LANDSCAPE_QUICK_OPTIONS_INSET - 8;
const bannerMaxHeight = Math.max(0, cardBottom - bannerTop - bannerBottomPadding);
const banner = chartEntry ? frame.chartImage(chartEntry, 'banner') : undefined;
const bannerHeight = banner ? Math.min(bannerMaxHeight, (bannerWidth * banner.height) / banner.width) : 0;
const cardHeight = bannerTop + bannerHeight + bannerBottomPadding - cardTop;
framePanel(chrome, 14, cardTop, 290, cardHeight, accent);
// The genre heads the card, in the accent light, where a fixed caption used to sit.
const genre = chartEntry?.genre?.trim() || (chartEntry ? '----' : undefined);
const slide = 1 - easeOutCubic(stageProgress(frame.nowMs - frame.cursorChangedAt, 0, SLIDE_MS));
addText(chartTitle, 30 + slide * 24, 86, {
size: 18,
weight: '500',
fill: SYN_WHITE,
fontFamily: SYN_TEXT_FONT,
maxWidth: 258,
alpha: 1 - slide,
dropShadow: { color: accent, distance: 0, blur: 10, alpha: 0.8 },
});
if (genre) {
addText(genre.toUpperCase(), 30 + slide * 16, 70, {
size: 9,
weight: '500',
fill: accent,
fontFamily: SYN_TEXT_FONT,
letterSpacing: 2,
// Clear of the README chip at the row's end.
maxWidth: chartEntry ? 258 - README_CHIP_W - 8 : 258,
alpha: 1 - slide,
});
}
// README at the card's top right, on the genre line; the title starts under it.
if (chartEntry) drawReadmeChip(chrome, addText, frame, 288 - README_CHIP_W, 66);
if (chartArtist) {
addText(chartArtist, 30 + slide * 40, 114, {
size: 10,
weight: '300',
fill: SYN_MIST,
fontFamily: SYN_TEXT_FONT,
maxWidth: 258,
alpha: 1 - slide,
});
}
chrome.rect(30, 133, 258, 1).fill({ color: accent, alpha: 0.35 });
const stats: ReadonlyArray<readonly [x: number, w: number, label: string, value: string, fill: number]> = [
[30, 80, 'MODE', modeLabel, SYN_WHITE],
[118, 76, 'BPM', chartBPM, SYN_WHITE],
[202, 86, 'LEVEL', playLevel, SYN_AMBER],
];
const statsY = 143;
for (const [x, w, label, value, fill] of stats) {
chrome.rect(x, statsY, w, 44).fill({ color: SYN_VOID, alpha: 0.5 });
chrome.rect(x, statsY, w, 44).stroke({ color: accent, width: 1, alpha: 0.25 });
drawReticle(chrome, x, statsY, w, 44, SYN_MIST, 0.6, { arm: 5, width: 1 });
addText(label, x + 10, statsY + 8, labelStyle());
addText(value, x + 10, statsY + 22, {
size: 14,
fill,
fontFamily: SYN_DISPLAY_FONT,
maxWidth: w - 18,
dropShadow: { color: fill, distance: 0, blur: 6, alpha: 0.6 },
});
}
// The judge rank (#RANK / #DEFEXRANK) under the stat chips.
drawDifficulty(chrome, addText, chartEntry, 30, 201);
drawJudgeRank(addText, chartEntry, 30, 220);
// The file name and the list position share the row under the judge rank.
if (chartEntry?.fileLabel) {
addText(chartEntry.fileLabel, 30, 238, {
size: 9,
weight: '300',
fill: SYN_DIM,
fontFamily: SYN_TEXT_FONT,
anchorY: 0.5,
// Clear of the list position at the row's end.
maxWidth: 200,
});
}
addText(position, 288, 238, { size: 9, fill: SYN_MIST, fontFamily: SYN_DISPLAY_FONT, anchorX: 1, anchorY: 0.5 });
// The player's best on the focused chart or course: lamp, score, DJ Rank. Nothing on a folder.
if (chartEntry !== undefined || frame.focusedCourse !== undefined) {
drawBestRecordPanel(chrome, layer, addText, this.lampLights, focusedBestRecord(frame), {
x: 30,
y: 250,
w: 258,
accent,
nowMs: frame.nowMs,
still: frame.effects === 'off',
});
}
// PLAY (primary glowing pill) / AUTO PLAY (secondary outline).
const buttonY = bannerTop - 50;
chrome.rect(26, buttonY, 105, 40).fill({ color: accent, alpha: 0.16 });
chrome.rect(30, buttonY + 4, 97, 32).fill({ color: accent, alpha: 0.88 });
drawReticle(chrome, 26, buttonY, 105, 40, SYN_WHITE, 0.95, { arm: 8, width: 1.5 });
addText('PLAY', 78.5, buttonY + 20, {
size: 14,
fill: SYN_VOID,
fontFamily: SYN_DISPLAY_FONT,
letterSpacing: 6,
anchorX: 0.5,
anchorY: 0.5,
});
// AUTO's right edge sits on the content column's (288), like the LEVEL chip above it.
const practice = chartEntry !== undefined ? frame.actions.practice : undefined;
drawSecondaryButton(chrome, addText, 'PRACTICE', 137, buttonY + 7, 87, 26, 8, practice !== undefined, 1.5);
drawSecondaryButton(chrome, addText, 'AUTO', 232, buttonY + 7, 56, 26, 8, true, 2);
addHitArea(26, buttonY, 105, 40, 'pointer', frame.actions.play);
if (practice) addHitArea(137, buttonY + 4, 87, 32, 'pointer', practice);
addHitArea(232, buttonY + 4, 56, 32, 'pointer', frame.actions.autoPlay);
this.drawBanner(frame, 30, bannerTop, bannerWidth, bannerMaxHeight, true);
// Search and library.
framePanel(chrome, 322, 54, designWidth - 336, 30, accent);
addText('SEARCH', 334, 69, { ...labelStyle(accent), anchorY: 0.5 });
// While the player types in the host's field laid over the box, the field shows the text.
if (!frame.searchEditing) {
addText(frame.searchQuery || 'Title / artist / genre', 418, 69, {
size: 10,
anchorY: 0.5,
weight: '300',
fill: frame.searchQuery ? SYN_WHITE : SYN_DIM,
fontFamily: SYN_TEXT_FONT,
maxWidth: designWidth - 436,
});
}
// The label and the text strip both start typing; the strip comes last, so the host lays its field over the text.
addHitArea(322, 54, 92, 30, 'text', frame.actions.activateSearch);
addHitArea(414, 54, designWidth - 428, 30, 'text', frame.actions.activateSearch);
drawQuickPlayOptions(chrome, addText, frame, accent, false);
layer.addChildAt(chrome, 0);
return slide > 0 || intro < 1;
}
/**
* Portrait select: the header, the focused song as a card across the top (genre, title, artist, the mode / tempo /
* level chips, PLAY and AUTO), the search bar, and the library line at the foot; the list runs
* full width between them. Nothing is set smaller than 10 design px.
*/
private renderPortraitChrome(frame: PixiSelectFrame): boolean {
const { layer, designWidth, designHeight, entries, focusedChart: chartEntry } = frame;
const chrome = new Graphics();
if (this.frosted) bindGlassSurface(chrome, this.glass);
chrome.label = 'synesthesia-select/chrome';
const accent = hsvToHex(sceneHue(frame.nowMs / 1000), 0.6, 1);
const addText = (text: string, x: number, y: number, options: SkinTextOptions = {}) => {
const node = addSynesthesiaText(layer, text, x, y, options);
if (y < 38) node.label = 'synesthesia-select/header';
else if (y >= designHeight - 36) node.label = 'synesthesia-select/footer';
return node;
};
const label = (fill: number = SYN_DIM): SkinTextOptions => ({ ...labelStyle(fill), size: 10 });
const course =
chartEntry === undefined && frame.focusedCourse !== undefined
? describeCourseCard(frame.focusedCourse, frame.courseBestRecord?.(frame.focusedCourse))
: undefined;
const chartArtist = chartEntry?.artist || chartEntry?.subtitle || course?.detail || '';
const playLevel = chartEntry?.playLevel !== undefined ? String(chartEntry.playLevel) : '-';
const categoryName = formatSelectBreadcrumb(frame.folderPath, frame.folderLabel, frame.searchQuery);
const position =
entries.length > 0 ? `${Math.min(frame.selectedIndex + 1, entries.length)} / ${entries.length}` : '0 / 0';
// Header: title as light, a hairline, and the folder on the right.
const header = new Graphics();
header.label = 'synesthesia-select/header';
layer.addChild(header);
header.rect(0, 0, designWidth, 40).fill({ color: SYN_VOID, alpha: 0.5 });
header.rect(0, 40, designWidth, 1).fill({ color: accent, alpha: 0.5 });
const intro = easeOutCubic(stageProgress(frame.nowMs - frame.sceneStartedAt, 0, 900));
addText('MUSIC SELECT', 16, 14, {
size: 12,
fill: SYN_WHITE,
fontFamily: SYN_DISPLAY_FONT,
letterSpacing: 4 + 8 * (1 - intro) + 2,
alpha: intro,
dropShadow: { color: accent, distance: 0, blur: 8, alpha: 0.9 },
});
addText(categoryName, designWidth - 16, 15, {
size: 11,
weight: '500',
fill: SYN_MIST,
fontFamily: SYN_TEXT_FONT,
anchorX: 1,
maxWidth: 200,
});
// The focused-song card.
const card = PORTRAIT_CARD;
framePanel(chrome, card.x, card.y, card.w, card.h, accent);
const left = card.x + 16;
const innerW = card.w - 32;
const slide = 1 - easeOutCubic(stageProgress(frame.nowMs - frame.cursorChangedAt, 0, SLIDE_MS));
const genre = chartEntry?.genre?.trim() || (chartEntry ? '----' : undefined);
if (genre) {
addText(genre.toUpperCase(), left + slide * 16, card.y + 14, {
size: 10,
weight: '500',
fill: accent,
fontFamily: SYN_TEXT_FONT,
letterSpacing: 2,
// Clear of the README chip at the row's end.
maxWidth: chartEntry ? innerW - README_CHIP_W - 8 : innerW,
alpha: 1 - slide,
});
}
// README at the card's top right, on the genre line; the title starts under it.
if (chartEntry) drawReadmeChip(chrome, addText, frame, left + innerW - README_CHIP_W, card.y + 10);
addText(chartEntry?.title ?? course?.title ?? 'No chart selected', left + slide * 24, card.y + 30, {
size: 18,
weight: '500',
fill: SYN_WHITE,
fontFamily: SYN_TEXT_FONT,
maxWidth: innerW,
alpha: 1 - slide,
dropShadow: { color: accent, distance: 0, blur: 10, alpha: 0.8 },
});
if (chartArtist) {
addText(chartArtist, left + slide * 40, card.y + 56, {
size: 11,
weight: '300',
fill: SYN_MIST,
fontFamily: SYN_TEXT_FONT,
maxWidth: innerW,
alpha: 1 - slide,
});
}
chrome.rect(left, card.y + 78, innerW, 1).fill({ color: accent, alpha: 0.35 });
const chipGap = 8;
const chipW = (innerW - 2 * chipGap) / 3;
const stats: ReadonlyArray<readonly [label: string, value: string, fill: number]> = [
['MODE', chartEntry ? formatPlayVariantLabel(chartEntry) : '- KEYS', SYN_WHITE],
['BPM', chartEntry?.bpm !== undefined ? String(Math.round(chartEntry.bpm)) : '-', SYN_WHITE],
['LEVEL', playLevel, SYN_AMBER],
];
stats.forEach(([name, value, fill], index) => {
const x = left + index * (chipW + chipGap);
const y = card.y + 90;
chrome.rect(x, y, chipW, 46).fill({ color: SYN_VOID, alpha: 0.5 });
chrome.rect(x, y, chipW, 46).stroke({ color: accent, width: 1, alpha: 0.25 });
drawReticle(chrome, x, y, chipW, 46, SYN_MIST, 0.6, { arm: 5, width: 1 });
addText(name, x + 10, y + 8, label());
addText(value, x + 10, y + 23, {
size: 14,
fill,
fontFamily: SYN_DISPLAY_FONT,
maxWidth: chipW - 18,
dropShadow: { color: fill, distance: 0, blur: 6, alpha: 0.6 },
});
});
// The judge rank (#RANK / #DEFEXRANK) under the stat chips.
drawDifficulty(chrome, addText, chartEntry, left, card.y + 154);
drawJudgeRank(addText, chartEntry, left + 238, card.y + 154);
// The file name and the list position share the row under the judge rank.
const fileRowY = card.y + 180;
addText(position, left + innerW, fileRowY, { ...label(SYN_MIST), anchorX: 1, anchorY: 0.5 });
if (chartEntry?.fileLabel) {
addText(chartEntry.fileLabel, left, fileRowY, {
size: 10,
weight: '300',
fill: SYN_DIM,
fontFamily: SYN_TEXT_FONT,
anchorY: 0.5,
// Clear of the list position at the row's end.
maxWidth: innerW - 64,
});
}
// The player's best on the focused chart or course: lamp, score, DJ Rank. Nothing on a folder.
if (chartEntry !== undefined || frame.focusedCourse !== undefined) {
drawBestRecordPanel(chrome, frame.layer, addText, this.lampLights, focusedBestRecord(frame), {
x: left,
y: card.y + 194,
w: innerW,
accent,
nowMs: frame.nowMs,
still: frame.effects === 'off',
size: 10,
});
}
// PLAY (primary glowing pill) / AUTO PLAY (secondary outline), thumb-sized.
const buttonY = card.y + 246;
const playW = Math.round(innerW * 0.42);
chrome.rect(left - 4, buttonY - 4, playW + 8, 44).fill({ color: accent, alpha: 0.16 });
chrome.rect(left, buttonY, playW, 36).fill({ color: accent, alpha: 0.88 });
drawReticle(chrome, left - 4, buttonY - 4, playW + 8, 44, SYN_WHITE, 0.95, { arm: 8, width: 1.5 });
addText('PLAY', left + playW / 2, buttonY + 18, {
size: 14,
fill: SYN_VOID,
fontFamily: SYN_DISPLAY_FONT,
letterSpacing: 6,
anchorX: 0.5,
anchorY: 0.5,
});
const practice = chartEntry !== undefined ? frame.actions.practice : undefined;
const practiceX = left + playW + 12;
const practiceW = Math.round(innerW * 0.32);
drawSecondaryButton(
chrome,
addText,
'PRACTICE',
practiceX,
buttonY + 2,
practiceW,
32,
10,
practice !== undefined,
2,
);
if (practice) addHitArea(practiceX, buttonY - 2, practiceW, 40, 'pointer', practice);
const autoX = practiceX + practiceW + 8;
const autoW = left + innerW - autoX;
drawSecondaryButton(chrome, addText, 'AUTO', autoX, buttonY + 2, autoW, 32, 10, true);
addHitArea(left - 4, buttonY - 4, playW + 8, 44, 'pointer', frame.actions.play);
addHitArea(autoX - 2, buttonY - 2, autoW + 4, 40, 'pointer', frame.actions.autoPlay);
const banner = chartEntry ? frame.chartImage(chartEntry, 'banner') : undefined;
const bannerHeight = banner ? Math.min(48, (innerW * banner.height) / banner.width) : 0;
this.drawBanner(frame, left, card.y + 286 + (card.h - 286 - bannerHeight) / 2, innerW, 48);
// Search.
const searchY = card.y + card.h + 10;
framePanel(chrome, card.x, searchY, card.w, 32, accent);
addText('SEARCH', left, searchY + 16, { ...label(accent), anchorY: 0.5 });
// While the player types in the host's field laid over the box, the field shows the text.
if (!frame.searchEditing) {
addText(frame.searchQuery || 'Title / artist / genre', left + 84, searchY + 16, {
size: 11,
anchorY: 0.5,
weight: '300',
fill: frame.searchQuery ? SYN_WHITE : SYN_DIM,
fontFamily: SYN_TEXT_FONT,
maxWidth: innerW - 84,
});
}
// The label and the text strip both start typing; the strip comes last, so the host lays its field over the text.
addHitArea(card.x, searchY, left + 80 - card.x, 32, 'text', frame.actions.activateSearch);
addHitArea(left + 80, searchY, card.x + card.w - (left + 80), 32, 'text', frame.actions.activateSearch);
// Library line at the foot.
drawQuickPlayOptions(chrome, addText, frame, accent, true);
const footY = designHeight - 17;
const footer = new Graphics();
footer.label = 'synesthesia-select/footer';
layer.addChild(footer);
footer.rect(0, designHeight - 32, designWidth, 1).fill({ color: accent, alpha: 0.3 });
addText(`${entries.length} shown / ${frame.totalCharts} charts`, 16, footY, {
size: 11,
fill: SYN_MIST,
fontFamily: SYN_DISPLAY_FONT,
anchorY: 0.5,
});
addText(frame.searchQuery ? 'SEARCH RESULTS' : frame.folderLabel ? 'CHARTS' : 'FOLDERS', designWidth - 16, footY, {
...label(),
anchorX: 1,
anchorY: 0.5,
});
layer.addChildAt(chrome, 0);
return slide > 0 || intro < 1;
}
/**
* One portrait list row: the level orb, the title over the artist, and the tempo over the note count on the right —
* two lines in a row a thumb tall.
*/
private renderPortraitRow(
frame: PixiSelectFrame,
entry: LibraryEntry,
entryIndex: number,
visibleIndex: number,
listWidth: number,
): boolean {
const { listX, listTop, rowHeight } = PORTRAIT_LAYOUT;
const y = listTop + visibleIndex * rowHeight;
const rowH = rowHeight - 4;
const active = entryIndex === frame.selectedIndex;
const chartEntry = entry.kind === 'chart' ? entry.chart : undefined;
const accent = hsvToHex(sceneHue(frame.nowMs / 1000), 0.6, 1);
const slide = active ? 1 - easeOutCubic(stageProgress(frame.nowMs - frame.cursorChangedAt, 0, SLIDE_MS)) : 0;
const intro =
1 -
easeOutCubic(
stageProgress(frame.nowMs - frame.sceneStartedAt, 120 + Math.max(0, visibleIndex) * INTRO_STAGGER_MS, 420),
);
// The focused row steps out a little to the left; the list is full width, so it does not grow.
const rowX = (active ? listX - 4 : listX) + slide * 18 + intro * 80;
const rowW = listWidth + (active ? 4 : 0);
const alpha = 1 - intro;
const row = new Graphics();
if (this.frosted) bindGlassSurface(row, this.glass);
row.alpha = alpha;
row.label = `fallback-row[idx=${entryIndex},kind=${entry.kind}${active ? ',active' : ''}]`;
drawGlassSurface(row, rowX, y, rowW, rowH, 0.96 * alpha);
if (active) {
row.rect(rowX, y, rowW, rowH).fill({ color: accent, alpha: 0.24 });
row.rect(rowX, y, rowW, rowH).stroke({ color: SYN_FLARE, width: 1, alpha: 0.6 });
this.activeCard = { x: rowX, y, w: rowW, h: rowH };
} else {
row.rect(rowX, y, rowW, rowH).stroke({ color: accent, width: 1, alpha: 0.16 });
}
const midY = y + rowH / 2;
const level = chartEntry ? browseEntryBadge(entry) : '';
const orbColor = chartEntry ? levelColor(Math.min(1, Number.parseFloat(level) / 12 || 0)) : SYN_MIST;
if (entry.kind === 'chart') {
row.circle(rowX + PORTRAIT_ROW_LEVEL_X, midY, 12).fill({ color: orbColor, alpha: active ? 0.35 : 0.18 });
} else {
drawSelectEntryIcon(row, entry, rowX + 19, midY);
}
frame.layer.addChild(row);
// The best clear lamp lights the bar's leading edge, rippling down the list.
drawBarLamp(
frame.layer,
this.lampLights,
entryBestRecord(frame, entry)?.lamp,
rowX + 1,
y + 2,
rowH - 4,
entryIndex * 0.07,
frame.nowMs,
frame.effects === 'off',
);
if (chartEntry)
addSynesthesiaText(frame.layer, level, rowX + PORTRAIT_ROW_LEVEL_X, midY, {
size: 10,
fill: SYN_WHITE,
fontFamily: SYN_DISPLAY_FONT,
anchorX: 0.5,
anchorY: 0.5,
alpha,
maxWidth: 22,
});
const facts = chartEntry ? resolveChartRowFacts(chartEntry) : undefined;
let factsW = 84;
if (entry.kind === 'folder') drawSelectEntryArrow(row, rowX + rowW - 12, midY);
const factsRight = rowX + rowW - (entry.kind === 'folder' ? 26 : 10);
const factStyle = (fill: number, maxWidth: number = factsW): SkinTextOptions => ({
size: 10,
fill,
fontFamily: SYN_DISPLAY_FONT,
letterSpacing: 0.5,
anchorX: 1,
anchorY: 0.5,
alpha,
maxWidth,
marquee: active,
});
if (facts) {
addSynesthesiaText(
frame.layer,
`${facts.bpm} BPM`,
factsRight,
midY - 7,
factStyle(active ? SYN_WHITE : SYN_MIST),
);
addSynesthesiaText(frame.layer, `${facts.notes} NOTES`, factsRight, midY + 8, factStyle(SYN_DIM));
} else {
// A folder or course count takes what it needs (`4 stages · 1 missing`), up to ROW_COUNT_MAX_W.
const count = browseEntryCount(entry) ?? '';
const countNode = addSynesthesiaText(frame.layer, count, factsRight, midY, factStyle(SYN_MIST, ROW_COUNT_MAX_W));
factsW = count ? Math.max(factsW, Math.min(ROW_COUNT_MAX_W, countNode.width)) : factsW;
}
const textX = drawSelectEntryMark(
row,
frame.layer,
entry,
rowX + (chartEntry ? PORTRAIT_ROW_TITLE_X : 36),
midY,
alpha,
);
const textW = Math.max(24, factsRight - factsW - 10 - textX);
const artist = chartEntry?.artist?.trim();
const title = addSynesthesiaText(frame.layer, browseEntryTitle(entry), textX, artist ? midY - 7 : midY, {
size: 12,
weight: active ? '500' : '300',
fill: SYN_WHITE,
fontFamily: SYN_TEXT_FONT,
anchorY: 0.5,
alpha,
maxWidth: textW,
marquee: active,
...(active ? { dropShadow: { color: accent, distance: 0, blur: 8, alpha: 0.9 } } : {}),
});
title.label = `fallback-title[idx=${entryIndex}]`;
if (artist) {
addSynesthesiaText(frame.layer, artist, textX, midY + 8, {
size: 10,
weight: '300',
fill: active ? SYN_MIST : SYN_DIM,
fontFamily: SYN_TEXT_FONT,
anchorY: 0.5,
alpha,
maxWidth: textW,
marquee: active,
});
}
return slide > 0 || intro > 0;
}
private renderRow(
frame: PixiSelectFrame,
entry: LibraryEntry,
entryIndex: number,
visibleIndex: number,
listWidth: number,
): boolean {
const { listX, listTop, rowHeight } = LAYOUT;
const y = listTop + visibleIndex * rowHeight;
const active = entryIndex === frame.selectedIndex;
const chartEntry = entry.kind === 'chart' ? entry.chart : undefined;
const hue = sceneHue(frame.nowMs / 1000);
const accent = hsvToHex(hue, 0.6, 1);
const slide = active ? 1 - easeOutCubic(stageProgress(frame.nowMs - frame.cursorChangedAt, 0, SLIDE_MS)) : 0;
const intro =
1 -
easeOutCubic(
stageProgress(frame.nowMs - frame.sceneStartedAt, 120 + Math.max(0, visibleIndex) * INTRO_STAGGER_MS, 420),
);
const rowX = (active ? listX - 8 : listX) + slide * 26 + intro * 120;
const rowW = active ? listWidth + 8 : listWidth;
const alpha = 1 - intro;
const row = new Graphics();
if (this.frosted) bindGlassSurface(row, this.glass);
row.alpha = alpha;
row.label = `fallback-row[idx=${entryIndex},kind=${entry.kind}${active ? ',active' : ''}]`;
drawGlassSurface(row, rowX, y, rowW, rowHeight - 4, 0.96 * alpha);
if (active) {
row.rect(rowX, y, rowW, rowHeight - 4).fill({ color: accent, alpha: 0.24 });
row.rect(rowX, y, rowW, rowHeight - 4).stroke({ color: SYN_FLARE, width: 1, alpha: 0.6 });
this.activeCard = { x: rowX, y, w: rowW, h: rowHeight - 4 };
} else {
row.rect(rowX, y, rowW, rowHeight - 4).stroke({ color: accent, width: 1, alpha: 0.16 });
}
const record = entryBestRecord(frame, entry);
// Level as a glowing orb on the leading edge.
const level = chartEntry ? browseEntryBadge(entry) : '';
const orbColor = chartEntry ? levelColor(Math.min(1, Number.parseFloat(level) / 12 || 0)) : SYN_MIST;
const midY = y + (rowHeight - 4) / 2;
if (entry.kind === 'chart') {
row.circle(rowX + ROW_LEVEL_X, midY, 9).fill({ color: orbColor, alpha: active ? 0.35 : 0.18 });
} else {
drawSelectEntryIcon(row, entry, rowX + 17, midY);
}
frame.layer.addChild(row);
// The best clear lamp lights the bar's leading edge, rippling down the list.
drawBarLamp(
frame.layer,
this.lampLights,
record?.lamp,
rowX + 1,
y + 2,
rowHeight - 8,
entryIndex * 0.07,
frame.nowMs,
frame.effects === 'off',
);
if (chartEntry)
addSynesthesiaText(frame.layer, level, rowX + ROW_LEVEL_X, midY, {
size: level.length > 2 ? 7 : 9,
fill: SYN_WHITE,
fontFamily: SYN_DISPLAY_FONT,
anchorX: 0.5,
anchorY: 0.5,
alpha,
maxWidth: 16,
});
// On the right, the facts a player checks before picking — gimmick tags, note count, length and tempo range — in
// fixed columns so they line up down the list. Folders show their size instead.
const facts = chartEntry ? resolveChartRowFacts(chartEntry) : undefined;
const meta = facts ? `${facts.bpm} BPM` : (browseEntryCount(entry) ?? '');
if (entry.kind === 'folder') drawSelectEntryArrow(row, rowX + rowW - 13, midY);
const factsRight = rowX + rowW - (entry.kind === 'folder' ? 27 : 14);
const metaNode = addSynesthesiaText(frame.layer, meta, factsRight, midY, {
size: 9,
fill: active ? SYN_WHITE : SYN_DIM,
fontFamily: SYN_DISPLAY_FONT,
letterSpacing: 1,
anchorX: 1,
anchorY: 0.5,
alpha,
maxWidth: facts ? ROW_BPM_W : ROW_COUNT_MAX_W,
marquee: active,
});
metaNode.label = `fallback-meta[idx=${entryIndex}]`;
let factsLeft = factsRight - (facts ? ROW_BPM_W : meta ? Math.min(ROW_COUNT_MAX_W, metaNode.width) : 0) - 12;
if (facts) {
const factStyle = (fill: number) => ({
size: 9,
fill,
fontFamily: SYN_DISPLAY_FONT,
letterSpacing: 1,
anchorX: 1,
anchorY: 0.5,
alpha,
});
const ink = active ? SYN_WHITE : SYN_MIST;
addSynesthesiaText(frame.layer, facts.length, factsLeft, midY, { ...factStyle(ink), maxWidth: ROW_LENGTH_W });
factsLeft -= ROW_LENGTH_W + 12;
addSynesthesiaText(frame.layer, 'NOTES', factsLeft, midY, { ...factStyle(SYN_DIM), size: 7 });
addSynesthesiaText(frame.layer, facts.notes, factsLeft - 46, midY, {
...factStyle(ink),
maxWidth: ROW_NOTES_W - 48,
});
factsLeft -= ROW_NOTES_W + 8;
// The DJ Rank of the best EX score, in its own column so the ranks line up down the list.
const rank = chartEntry ? describeBestRecord(record, chartEntry.totalNotes)?.rank : undefined;
if (rank !== undefined) {
addSynesthesiaText(frame.layer, rank, factsLeft, midY, {
...factStyle(rank === 'AAA' ? SYN_AMBER : ink),
maxWidth: ROW_RANK_W,
});
}
factsLeft -= ROW_RANK_W + 8;
// Gimmick tags glow as small outlined capsules in the accent light.
for (let index = facts.tags.length - 1; index >= 0; index -= 1) {
const tag = facts.tags[index]!;
const chipW = 10 + tag.length * 6.5;
factsLeft -= chipW;
row
.roundRect(factsLeft, midY - 6, chipW, 12, 6)
.stroke({ color: active ? SYN_FLARE : accent, width: 1, alpha: 0.7 });
addSynesthesiaText(frame.layer, tag, factsLeft + chipW / 2, midY, {
size: 7,
fill: active ? SYN_WHITE : SYN_MIST,
fontFamily: SYN_DISPLAY_FONT,
letterSpacing: 0.5,
anchorX: 0.5,
anchorY: 0.5,
alpha,
maxWidth: chipW - 4,
});
factsLeft -= 5;
}
factsLeft -= 6;
}
const textX = drawSelectEntryMark(row, frame.layer, entry, rowX + (chartEntry ? ROW_TITLE_X : 34), midY, alpha);
const title = addSynesthesiaText(frame.layer, browseEntryTitle(entry), textX, midY, {
size: 11,
weight: active ? '500' : '300',
fill: SYN_WHITE,
fontFamily: SYN_TEXT_FONT,
anchorY: 0.5,
alpha,
maxWidth: Math.max(24, factsLeft - textX),
// Only the focused row scrolls a long title; the others clip it at its start.
marquee: active,
...(active ? { dropShadow: { color: accent, distance: 0, blur: 8, alpha: 0.9 } } : {}),
});
title.label = `fallback-title[idx=${entryIndex}]`;
// The artist trails the title in a dimmer light while there is room for it.
const artist = chartEntry?.artist?.trim();
const artistX = textX + title.width + 10;
if (artist && factsLeft - artistX >= 40) {
addSynesthesiaText(frame.layer, artist, artistX, midY, {
size: 9,
weight: '300',
fill: active ? SYN_MIST : SYN_DIM,
fontFamily: SYN_TEXT_FONT,
anchorY: 0.5,
alpha,
maxWidth: factsLeft - artistX,
marquee: active,
});
}
return slide > 0 || intro > 0;
}
}
/** The player's best record on a bar's chart or course, when the host keeps one. */
function entryBestRecord(frame: PixiSelectFrame, entry: LibraryEntry): BeMusicChartBestRecord | undefined {
if (entry.kind === 'chart') return frame.chartBestRecord(entry.chart);
if (entry.kind === 'course') return frame.courseBestRecord?.(entry.course);
return undefined;
}
/** The best record on the focused chart (with its rate and DJ Rank) or course, as the info card shows it. */
function focusedBestRecord(frame: PixiSelectFrame): BestRecordSummary | undefined {
if (frame.focusedChart !== undefined) {
return describeBestRecord(frame.chartBestRecord(frame.focusedChart), frame.focusedChart.totalNotes);
}
return frame.focusedCourse !== undefined
? describeBestRecord(frame.courseBestRecord?.(frame.focusedCourse))
: undefined;
}
/** Level light for `ratio` (0..1): electric blue for easy charts through magenta to ember for the hardest. */
function levelColor(ratio: number): number {
return hsvToHex(0.58 + Math.max(0, Math.min(1, ratio)) * 0.5, 0.72, 1);
}
|