fertig-classic-games/src/games/phase10/Phase10Art.js

631 lines
20 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Phase 10 art — all baked once into canvas textures (no image files).
//
// p10-cards atlas at 2× — frames '<color>-<1..12>', 'wild', 'skip'
// p10-back retro striped card back (used when no sprite back is chosen)
// p10-glow soft card-sized outline (selection / target glow, tinted)
// p10-spot radial light pool (turn spotlight, additive)
// p10-table-<n> the whole room for n players: wood-panel wall, chrome-rim
// card table with tufted vinyl, seat placemats, pile spots
//
// The score pad paper and the ghost hand come from the Nerts art module
// (ensurePad / ensureGhostHand). Geometry is Phase10Table.js, so mats and pile
// spots line up with where the scene puts cards.
import { prepareCasinoArt, canvas, rr, poly, mix, lerp, noisePattern } from '../../ui/casino/CasinoArt.js';
import { COLORS_LIST } from './PhaseSpec.js';
import {
P, W, H, CARD_W, CARD_H, FELT_K, RAIL_FACE_PX, SEAT_HEX, SQ,
outline, layoutFor, matCorners, poseScale,
} from './Phase10Table.js';
const RES = 2;
const CW = CARD_W * RES;
const CH = CARD_H * RES;
const FONT = 'Righteous, "Arial Black", sans-serif';
export const CARD_COLORS = {
red: { hi: '#f0634f', mid: '#d23a2c', lo: '#8f1d16', ink: '#b22a1f' },
blue: { hi: '#5a92ec', mid: '#2b62c8', lo: '#173a7c', ink: '#1f4fa8' },
yellow: { hi: '#ffd44f', mid: '#f0ae1a', lo: '#a86c08', ink: '#b77b06' },
green: { hi: '#5cc77a', mid: '#2e9a4f', lo: '#185c2c', ink: '#1f7a3b' },
};
const CREAM = '#fbf4e2';
// Table-top vinyl: deep retro teal, so it reads apart from the wood paneling
// and the straw placemats.
const VINYL = '#1d5250';
const VINYL_TUFT = '#0c2a29';
const CREAM_DK = '#e9dcbd';
// ── Cards ────────────────────────────────────────────────────────────────────
function cardBase(ctx, x, y) {
rr(ctx, x + 2, y + 2, CW - 4, CH - 4, 16);
ctx.fillStyle = CREAM;
ctx.fill();
ctx.save();
ctx.clip();
ctx.fillStyle = noisePattern(ctx, 96, 14);
ctx.fillRect(x, y, CW, CH);
ctx.restore();
rr(ctx, x + 2, y + 2, CW - 4, CH - 4, 16);
ctx.lineWidth = 2.5;
ctx.strokeStyle = 'rgba(40,28,14,0.55)';
ctx.stroke();
}
function panelPath(ctx, x, y) {
rr(ctx, x + 13, y + 13, CW - 26, CH - 26, 12);
}
// Colour-blind helper shapes, one per colour.
function shape(ctx, color, cx, cy, r, fill) {
ctx.save();
ctx.fillStyle = fill;
ctx.beginPath();
if (color === 'red') ctx.arc(cx, cy, r, 0, Math.PI * 2);
else if (color === 'blue') ctx.rect(cx - r * 0.88, cy - r * 0.88, r * 1.76, r * 1.76);
else if (color === 'yellow') { ctx.moveTo(cx, cy - r * 1.1); ctx.lineTo(cx + r * 1.05, cy + r * 0.8); ctx.lineTo(cx - r * 1.05, cy + r * 0.8); ctx.closePath(); }
else { ctx.moveTo(cx, cy - r * 1.15); ctx.lineTo(cx + r, cy); ctx.lineTo(cx, cy + r * 1.15); ctx.lineTo(cx - r, cy); ctx.closePath(); }
ctx.fill();
ctx.restore();
}
function cornerIndex(ctx, x, y, text, color, fill, underline) {
const draw = () => {
ctx.font = `${text.length > 1 ? 40 : 46}px ${FONT}`;
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.fillStyle = fill;
ctx.fillText(text, 0, 0);
if (underline) ctx.fillRect(-12, 25, 24, 4);
if (color) shape(ctx, color, 0, 46, 9, fill);
};
ctx.save();
ctx.translate(x + 38, y + 46);
draw();
ctx.restore();
ctx.save();
ctx.translate(x + CW - 38, y + CH - 46);
ctx.rotate(Math.PI);
draw();
ctx.restore();
}
function lozenge(ctx, cx, cy, w, h) {
ctx.beginPath();
ctx.ellipse(cx, cy, w / 2, h / 2, -0.32, 0, Math.PI * 2);
}
function drawNumberCard(ctx, x, y, color, value) {
const c = CARD_COLORS[color];
cardBase(ctx, x, y);
ctx.save();
panelPath(ctx, x, y);
const g = ctx.createLinearGradient(x, y, x + CW, y + CH);
g.addColorStop(0, c.hi);
g.addColorStop(0.55, c.mid);
g.addColorStop(1, c.lo);
ctx.fillStyle = g;
ctx.fill();
ctx.clip();
// 70s pinstripes through the middle
ctx.globalAlpha = 0.16;
ctx.fillStyle = CREAM;
for (let i = -3; i <= 3; i++) {
ctx.save();
ctx.translate(x + CW / 2, y + CH / 2);
ctx.rotate(-0.32);
ctx.fillRect(-CW, i * 22 - 5, CW * 2, 7);
ctx.restore();
}
ctx.globalAlpha = 1;
ctx.restore();
// cream bubble with the big number
const cx = x + CW / 2, cy = y + CH / 2;
ctx.save();
ctx.shadowColor = 'rgba(0,0,0,0.35)';
ctx.shadowBlur = 8;
ctx.shadowOffsetY = 3;
lozenge(ctx, cx, cy, 142, 176);
ctx.fillStyle = CREAM;
ctx.fill();
ctx.restore();
lozenge(ctx, cx, cy, 142, 176);
ctx.lineWidth = 3;
ctx.strokeStyle = c.lo;
ctx.stroke();
const txt = String(value);
ctx.font = `${txt.length > 1 ? 92 : 108}px ${FONT}`;
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.lineWidth = 8;
ctx.strokeStyle = 'rgba(30,20,10,0.55)';
ctx.strokeText(txt, cx, cy + 4);
ctx.fillStyle = c.ink;
ctx.fillText(txt, cx, cy + 4);
if (value === 6 || value === 9) {
ctx.fillStyle = c.ink;
ctx.fillRect(cx - 22, cy + 52, 44, 7);
}
cornerIndex(ctx, x, y, txt, color, CREAM, value === 6 || value === 9);
// gloss
ctx.save();
panelPath(ctx, x, y);
ctx.clip();
const gl = ctx.createLinearGradient(x, y, x + CW * 0.6, y + CH * 0.5);
gl.addColorStop(0, 'rgba(255,255,255,0.28)');
gl.addColorStop(0.5, 'rgba(255,255,255,0.04)');
gl.addColorStop(1, 'rgba(255,255,255,0)');
ctx.fillStyle = gl;
ctx.fillRect(x, y, CW, CH);
ctx.restore();
}
function drawWild(ctx, x, y) {
cardBase(ctx, x, y);
ctx.save();
panelPath(ctx, x, y);
ctx.clip();
const order = ['red', 'yellow', 'green', 'blue'];
ctx.translate(x + CW / 2, y + CH / 2);
ctx.rotate(-0.5);
for (let i = 0; i < 8; i++) {
ctx.fillStyle = CARD_COLORS[order[i % 4]].mid;
ctx.fillRect(-CW * 1.5 + i * 58 - 58, -CH, 58, CH * 2);
}
ctx.restore();
const cx = x + CW / 2, cy = y + CH / 2;
ctx.save();
ctx.shadowColor = 'rgba(0,0,0,0.4)';
ctx.shadowBlur = 8;
ctx.shadowOffsetY = 3;
lozenge(ctx, cx, cy, 148, 182);
ctx.fillStyle = '#2a1d12';
ctx.fill();
ctx.restore();
lozenge(ctx, cx, cy, 148, 182);
ctx.lineWidth = 4;
ctx.strokeStyle = CREAM;
ctx.stroke();
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.font = `100px ${FONT}`;
const grad = ctx.createLinearGradient(cx - 40, cy - 50, cx + 40, cy + 40);
grad.addColorStop(0, CARD_COLORS.yellow.hi);
grad.addColorStop(0.5, CARD_COLORS.red.hi);
grad.addColorStop(1, CARD_COLORS.blue.hi);
ctx.fillStyle = grad;
ctx.fillText('W', cx, cy - 6);
ctx.font = `30px ${FONT}`;
ctx.fillStyle = CREAM;
ctx.fillText('WILD', cx, cy + 58);
cornerIndex(ctx, x, y, 'W', null, CREAM, false);
}
function drawSkip(ctx, x, y) {
cardBase(ctx, x, y);
ctx.save();
panelPath(ctx, x, y);
const g = ctx.createLinearGradient(x, y, x, y + CH);
g.addColorStop(0, '#3a3430');
g.addColorStop(1, '#141110');
ctx.fillStyle = g;
ctx.fill();
ctx.clip();
ctx.globalAlpha = 0.12;
ctx.fillStyle = '#ff8a5b';
for (let i = -4; i <= 4; i++) ctx.fillRect(x + CW / 2 + i * 26 - 3, y, 6, CH);
ctx.globalAlpha = 1;
ctx.restore();
const cx = x + CW / 2, cy = y + CH / 2 - 6;
ctx.lineCap = 'round';
ctx.lineWidth = 16;
ctx.strokeStyle = '#ff6b4a';
ctx.beginPath();
ctx.arc(cx, cy, 52, 0, Math.PI * 2);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(cx - 36, cy - 36);
ctx.lineTo(cx + 36, cy + 36);
ctx.stroke();
ctx.lineCap = 'butt';
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.font = `32px ${FONT}`;
ctx.fillStyle = CREAM;
ctx.fillText('SKIP', cx, cy + 86);
cornerIndex(ctx, x, y, 'S', null, '#ff9a7a', false);
}
export function frameKey(card) {
if (card.value === 'wild') return 'wild';
if (card.value === 'skip') return 'skip';
return `${card.color}-${card.value}`;
}
function bakeCards(scene) {
const keys = [];
for (const col of COLORS_LIST) for (let v = 1; v <= 12; v++) keys.push([`${col}-${v}`, (ctx, x, y) => drawNumberCard(ctx, x, y, col, v)]);
keys.push(['wild', drawWild], ['skip', drawSkip]);
const cols = 10;
const rows = Math.ceil(keys.length / cols);
const c = canvas(cols * CW, rows * CH);
const ctx = c.getContext('2d');
keys.forEach(([, draw], i) => draw(ctx, (i % cols) * CW, Math.floor(i / cols) * CH));
const tex = scene.textures.addCanvas('p10-cards', c);
keys.forEach(([k], i) => tex.add(k, 0, (i % cols) * CW, Math.floor(i / cols) * CH, CW, CH));
}
function bakeBack(scene) {
const c = canvas(CW, CH);
const ctx = c.getContext('2d');
rr(ctx, 2, 2, CW - 4, CH - 4, 16);
ctx.fillStyle = '#3b2416';
ctx.fill();
ctx.save();
ctx.clip();
// stacked 70s stripes arching across the card
const bands = ['#f2ead8', '#f0ae1a', '#e2702a', '#b5402a', '#6b2a1c'];
for (let i = 0; i < bands.length; i++) {
ctx.beginPath();
ctx.ellipse(CW / 2, CH * 1.05, CW * (1.05 - i * 0.14), CH * (0.82 - i * 0.11), 0, Math.PI, 0);
ctx.lineWidth = 15;
ctx.strokeStyle = bands[i];
ctx.stroke();
}
for (let i = 0; i < bands.length; i++) {
ctx.beginPath();
ctx.ellipse(CW / 2, -CH * 0.05, CW * (1.05 - i * 0.14), CH * (0.82 - i * 0.11), 0, 0, Math.PI);
ctx.lineWidth = 15;
ctx.strokeStyle = bands[i];
ctx.stroke();
}
ctx.fillStyle = noisePattern(ctx, 96, 20);
ctx.fillRect(0, 0, CW, CH);
ctx.restore();
// centre medallion
ctx.beginPath();
ctx.arc(CW / 2, CH / 2, 40, 0, Math.PI * 2);
ctx.fillStyle = '#2a1a10';
ctx.fill();
ctx.lineWidth = 4;
ctx.strokeStyle = '#f0ae1a';
ctx.stroke();
ctx.font = `40px ${FONT}`;
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.fillStyle = '#f2ead8';
ctx.fillText('10', CW / 2, CH / 2 + 2);
rr(ctx, 9, 9, CW - 18, CH - 18, 11);
ctx.lineWidth = 3;
ctx.strokeStyle = 'rgba(242,234,216,0.75)';
ctx.stroke();
rr(ctx, 2, 2, CW - 4, CH - 4, 16);
ctx.lineWidth = 2.5;
ctx.strokeStyle = 'rgba(0,0,0,0.6)';
ctx.stroke();
scene.textures.addCanvas('p10-back', c);
}
function bakeGlow(scene) {
const pad = 30;
const c = canvas(CW + pad * 2, CH + pad * 2);
const ctx = c.getContext('2d');
ctx.shadowColor = '#ffffff';
ctx.shadowBlur = 22;
rr(ctx, pad, pad, CW, CH, 18);
ctx.lineWidth = 8;
ctx.strokeStyle = '#ffffff';
ctx.stroke();
ctx.stroke();
scene.textures.addCanvas('p10-glow', c);
}
function bakeSpot(scene) {
const S = 256;
const c = canvas(S, S);
const ctx = c.getContext('2d');
const g = ctx.createRadialGradient(S / 2, S / 2, 0, S / 2, S / 2, S / 2);
g.addColorStop(0, 'rgba(255,255,255,1)');
g.addColorStop(0.45, 'rgba(255,255,255,0.45)');
g.addColorStop(1, 'rgba(255,255,255,0)');
ctx.fillStyle = g;
ctx.fillRect(0, 0, S, S);
scene.textures.addCanvas('p10-spot', c);
}
// ── The room ────────────────────────────────────────────────────────────────
function drawWall(ctx) {
// vertical wood paneling with V-grooves
const base = ctx.createLinearGradient(0, 0, 0, H);
base.addColorStop(0, '#2c1a0e');
base.addColorStop(0.5, '#4a2c16');
base.addColorStop(1, '#22140a');
ctx.fillStyle = base;
ctx.fillRect(0, 0, W, H);
let x = 0;
let i = 0;
while (x < W) {
const w = 74 + ((i * 37) % 3) * 9;
const tone = ['#5a361b', '#4d2d16', '#63401f', '#523118'][i % 4];
ctx.globalAlpha = 0.55;
ctx.fillStyle = tone;
ctx.fillRect(x + 2, 0, w - 4, H);
// grain
ctx.globalAlpha = 0.14;
for (let k = 0; k < 9; k++) {
const gx = x + 6 + Math.random() * (w - 12);
ctx.beginPath();
ctx.moveTo(gx, 0);
for (let y = 0; y <= H; y += 60) ctx.lineTo(gx + Math.sin(y * 0.01 + k + i) * 3, y);
ctx.lineWidth = 1 + Math.random() * 2;
ctx.strokeStyle = Math.random() < 0.5 ? '#1a0d05' : '#8a5a2c';
ctx.stroke();
}
ctx.globalAlpha = 1;
// groove
ctx.fillStyle = '#140a04';
ctx.fillRect(x, 0, 2, H);
ctx.fillStyle = 'rgba(255,200,140,0.1)';
ctx.fillRect(x + 2, 0, 1, H);
x += w;
i++;
}
ctx.fillStyle = noisePattern(ctx, 128, 16);
ctx.fillRect(0, 0, W, H);
// warm lamp wash at the top, dark corners
const lamp = ctx.createRadialGradient(W / 2, 120, 40, W / 2, 200, 1100);
lamp.addColorStop(0, 'rgba(255,190,110,0.28)');
lamp.addColorStop(0.5, 'rgba(255,170,90,0.06)');
lamp.addColorStop(1, 'rgba(0,0,0,0.5)');
ctx.fillStyle = lamp;
ctx.fillRect(0, 0, W, H);
}
function drawFloorShadow(ctx) {
const OFF = 6000;
const pts = outline(1.0, 18).map(p => ({ x: p.x - OFF, y: p.y + RAIL_FACE_PX * p.s + 8 }));
ctx.save();
ctx.shadowColor = 'rgba(0,0,0,0.8)';
ctx.shadowBlur = 70;
ctx.shadowOffsetX = OFF;
ctx.shadowOffsetY = 30;
poly(ctx, pts);
ctx.fillStyle = '#000';
ctx.fill();
ctx.restore();
}
function drawFrontFace(ctx) {
// chrome edge band: bright / dark stripes like a diner table
const top = outline(1.0, 18);
const tones = ['#f4f6f8', '#c9ced4', '#7d848c', '#e4e8ec', '#9aa1a9', '#5b6168', '#3b3f44'];
for (let i = 0; i <= 14; i++) {
const f = i / 14;
poly(ctx, top.map(p => ({ x: p.x, y: p.y + RAIL_FACE_PX * p.s * f })));
ctx.fillStyle = tones[Math.min(tones.length - 1, Math.floor(f * tones.length))];
ctx.fill();
}
// ribbed grooves
for (const f of [0.3, 0.55, 0.8]) {
poly(ctx, top.map(p => ({ x: p.x, y: p.y + RAIL_FACE_PX * p.s * f })), true);
ctx.lineWidth = 1.5;
ctx.strokeStyle = 'rgba(30,32,36,0.5)';
ctx.stroke();
}
poly(ctx, top.map(p => ({ x: p.x, y: p.y + RAIL_FACE_PX * p.s })));
ctx.lineWidth = 2;
ctx.strokeStyle = 'rgba(0,0,0,0.85)';
ctx.stroke();
}
function bandPath(ctx, k0, k1) {
const outer = outline(k1, 18), inner = outline(k0, 18);
ctx.beginPath();
outer.forEach((p, i) => (i ? ctx.lineTo(p.x, p.y) : ctx.moveTo(p.x, p.y)));
ctx.closePath();
inner.forEach((p, i) => (i ? ctx.lineTo(p.x, p.y) : ctx.moveTo(p.x, p.y)));
ctx.closePath();
}
function ring(ctx, k, width, color) {
poly(ctx, outline(k, 18));
ctx.lineWidth = width;
ctx.strokeStyle = color;
ctx.stroke();
}
function drawRim(ctx) {
ctx.save();
bandPath(ctx, FELT_K, 1.0);
ctx.fillStyle = '#aab0b7';
ctx.fill('evenodd');
ctx.clip('evenodd');
for (let i = 0; i <= 18; i++) {
const f = i / 18;
const crown = Math.sin(f * Math.PI);
ring(ctx, lerp(FELT_K, 1.0, f), 4, mix('#4c5258', '#ffffff', Math.pow(crown, 2.2) * 0.95));
}
// lamp reflections along the far chrome
const c = P.project(0, 0.0);
const glint = ctx.createRadialGradient(c.x, c.y, 10, c.x, c.y, 420);
glint.addColorStop(0, 'rgba(255,240,210,0.65)');
glint.addColorStop(1, 'rgba(255,240,210,0)');
ctx.fillStyle = glint;
ctx.fillRect(0, 0, W, H);
ctx.restore();
ring(ctx, 1.0, 2, 'rgba(0,0,0,0.6)');
// black rubber gasket where the vinyl meets the chrome
ring(ctx, FELT_K + 0.002, 5, '#141416');
}
function drawVinyl(ctx) {
const felt = outline(FELT_K, 18);
ctx.save();
poly(ctx, felt);
ctx.clip();
ctx.fillStyle = VINYL;
ctx.fillRect(0, 0, W, H);
ctx.fillStyle = noisePattern(ctx, 192, 26);
ctx.fillRect(0, 0, W, H);
// tufted diamond quilting in table space (perspective-correct)
const du = 0.16, dv = 0.16 * 0.56;
const line = (u0, v0, u1, v1, color, width, dy = 0) => {
const a = P.project(u0, v0), b = P.project(u1, v1);
ctx.beginPath();
ctx.moveTo(a.x, a.y + dy);
ctx.lineTo(b.x, b.y + dy);
ctx.lineWidth = width;
ctx.strokeStyle = color;
ctx.stroke();
};
for (let k = -20; k <= 20; k++) {
const u = k * du;
// two diagonal families: (u + t, t) and (u - t, t) scaled to the diamond aspect
const a0 = { u: u, v: -0.05 }, a1 = { u: u + (1.1 / dv) * du, v: 1.05 };
const b1 = { u: u - (1.1 / dv) * du, v: 1.05 };
line(a0.u, a0.v, a1.u, a1.v, 'rgba(0,18,20,0.4)', 3);
line(a0.u, a0.v, a1.u, a1.v, 'rgba(170,240,230,0.08)', 1.5, 2);
line(a0.u, a0.v, b1.u, b1.v, 'rgba(0,18,20,0.4)', 3);
line(a0.u, a0.v, b1.u, b1.v, 'rgba(170,240,230,0.08)', 1.5, 2);
}
// tuft buttons at the crossings
// the two families cross every half-step down, alternating half-step across
for (let row = 0; row * (dv / 2) <= 1.1; row++) {
const v = -0.05 + row * (dv / 2);
const off = row % 2 ? du / 2 : 0;
for (let k = -8; k <= 8; k++) {
const p = P.project(k * du + off, v);
ctx.beginPath();
ctx.ellipse(p.x, p.y, 4.5 * p.s, 3.6 * p.s, 0, 0, Math.PI * 2);
ctx.fillStyle = VINYL_TUFT;
ctx.fill();
ctx.beginPath();
ctx.ellipse(p.x - 1, p.y - 1, 1.8 * p.s, 1.3 * p.s, 0, 0, Math.PI * 2);
ctx.fillStyle = 'rgba(190,250,240,0.28)';
ctx.fill();
}
}
// overhead lamp pool + vignette
const c = P.project(0, 0.5);
const lamp = ctx.createRadialGradient(c.x, c.y, 60, c.x, c.y, 1050);
lamp.addColorStop(0, 'rgba(255,214,150,0.26)');
lamp.addColorStop(0.45, 'rgba(255,214,150,0.08)');
lamp.addColorStop(1, 'rgba(255,214,150,0)');
ctx.fillStyle = lamp;
ctx.fillRect(0, 0, W, H);
const vig = ctx.createRadialGradient(c.x, c.y, 360, c.x, c.y, 1150);
vig.addColorStop(0, 'rgba(0,0,0,0)');
vig.addColorStop(1, 'rgba(0,0,0,0.55)');
ctx.fillStyle = vig;
ctx.fillRect(0, 0, W, H);
for (let i = 0; i < 10; i++) ring(ctx, FELT_K - i * 0.004, 4, `rgba(0,0,0,${0.32 * (1 - i / 10)})`);
ctx.restore();
}
function drawMats(ctx, L) {
for (const st of L.seats) {
const hex = SEAT_HEX[st.seat];
const pts = matCorners(L, st.seat, 10);
ctx.save();
ctx.shadowColor = 'rgba(0,0,0,0.5)';
ctx.shadowBlur = 14;
ctx.shadowOffsetY = 5;
poly(ctx, pts);
ctx.fillStyle = '#c99a52';
ctx.fill();
ctx.restore();
ctx.save();
poly(ctx, pts);
ctx.clip();
// woven straw placemat: two families of fine stripes
const top = Math.min(...pts.map(p => p.y)), btm = Math.max(...pts.map(p => p.y));
const lft = Math.min(...pts.map(p => p.x)), rgt = Math.max(...pts.map(p => p.x));
const g = ctx.createLinearGradient(0, top, 0, btm);
g.addColorStop(0, '#d9ac62');
g.addColorStop(1, '#a8772f');
ctx.fillStyle = g;
ctx.fillRect(lft, top, rgt - lft, btm - top);
ctx.globalAlpha = 0.18;
for (let y = top; y < btm; y += 5) {
ctx.fillStyle = (Math.round(y / 5) % 2) ? '#6b4214' : '#f6d79a';
ctx.fillRect(lft, y, rgt - lft, 2);
}
ctx.globalAlpha = 0.08;
for (let x = lft; x < rgt; x += 9) {
ctx.fillStyle = '#4a2a0c';
ctx.fillRect(x, top, 2, btm - top);
}
ctx.globalAlpha = 1;
ctx.fillStyle = noisePattern(ctx, 96, 22);
ctx.fillRect(lft, top, rgt - lft, btm - top);
// subtle darkening so cards pop
ctx.fillStyle = 'rgba(40,20,6,0.18)';
ctx.fillRect(lft, top, rgt - lft, btm - top);
ctx.restore();
// seat-coloured piping + stitch
poly(ctx, pts);
ctx.lineWidth = 5;
ctx.strokeStyle = hex;
ctx.stroke();
poly(ctx, matCorners(L, st.seat, 3));
ctx.setLineDash([7, 6]);
ctx.lineWidth = 1.4;
ctx.strokeStyle = 'rgba(255,244,214,0.55)';
ctx.stroke();
ctx.setLineDash([]);
}
}
function pileSpot(ctx, pose, label) {
const { sx, sy } = poseScale(pose.s, pose.rot, SQ);
ctx.save();
ctx.translate(pose.x, pose.y);
ctx.scale(sx, sy);
rr(ctx, -CARD_W / 2 - 8, -CARD_H / 2 - 8, CARD_W + 16, CARD_H + 16, 14);
ctx.fillStyle = 'rgba(0,0,0,0.22)';
ctx.fill();
ctx.setLineDash([9, 7]);
ctx.lineWidth = 2.2 / sx;
ctx.strokeStyle = 'rgba(242,214,160,0.45)';
ctx.stroke();
ctx.setLineDash([]);
ctx.restore();
ctx.font = `16px "Julius Sans One", sans-serif`;
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.fillStyle = 'rgba(242,214,160,0.5)';
ctx.fillText(label, pose.x, pose.y - (CARD_H / 2) * sy - 26);
}
function bakeTable(scene, key, playerCount) {
const L = layoutFor(playerCount);
const c = canvas(W, H);
const ctx = c.getContext('2d');
drawWall(ctx);
drawFloorShadow(ctx);
drawFrontFace(ctx);
drawRim(ctx);
drawVinyl(ctx);
ctx.save();
poly(ctx, outline(FELT_K, 18));
ctx.clip();
drawMats(ctx, L);
pileSpot(ctx, L.deck, 'DRAW');
pileSpot(ctx, L.discard, 'DISCARD');
ctx.restore();
scene.textures.addCanvas(key, c);
}
export async function preparePhase10Art(scene, playerCount) {
await prepareCasinoArt(scene);
if (!scene.textures.exists('p10-cards')) bakeCards(scene);
if (!scene.textures.exists('p10-back')) bakeBack(scene);
if (!scene.textures.exists('p10-glow')) bakeGlow(scene);
if (!scene.textures.exists('p10-spot')) bakeSpot(scene);
const key = `p10-table-${playerCount}`;
if (!scene.textures.exists(key)) bakeTable(scene, key, playerCount);
return key;
}
export { CW as CARD_TEX_W, CH as CARD_TEX_H, CREAM, CREAM_DK };