체스·마작 실제 그림: 체스 기물은 Cburnett(CC BY-SA 3.0), 마작패는 Shizhao 퍼블릭 도메인 SVG
- 체스: 직접 그린 기물을 Wikimedia Commons Cburnett 12장(Chess_{k,q,r,b,n,p}{l,d}t45.svg)으로 바꿈.
최소화 SVG(합계 약 11 KB)를 chess/pieces/에 두고 art.ts의 pieceSrc()로 판 SVG 안 <image>로 그림
(Vite가 체스 청크에 data URL로 넣음). 미끄러짐·내려앉기·잡힘·끌기·키보드·aria는 그대로.
30초 규칙 요약 그림판도 같은 기물, 다크 모드에서 판 밖 흑 아이콘에 옅은 테두리. 규칙 화면에 출처 한 줄.
- 마작: 직접 그린 패 앞면을 Shizhao 컬러 세트 34장(MJ*.svg, PD-self / 서풍 CC0)으로 바꿈.
윤곽·흰 바탕을 지우고 svgo로 줄인 37장(적도라 5mr·5pr·5sr 포함, 약 120 KB)을 mahjong/tiles/에 둠.
패 몸통·뒷면·선택·흐림·애니메이션·aria는 그대로, 왼쪽 위에 숫자/한글(동·남·서·북·백·발·중)을 겹치고
작은 패(30px 미만)에서는 크게 써서 버림패·휴대폰 손패에서도 읽힘. 마작 청크에만 들어감. 규칙 화면에 출처 한 줄.
- 출처 파일 ATTRIBUTION.txt(각 폴더), docs/games/chess.md §9 "기물 그림", docs/games/mahjong.md §9.2 "패 그림".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import { TurnTimer, useServerNow } from '../../components/TurnTimer';
|
||||
import { haptic } from '../../lib/feedback';
|
||||
import { BOARD_MOTION_CSS, useMoveDiff } from '../board-motion';
|
||||
import type { BoardProps, GameUI, OptionsProps } from '../types';
|
||||
import { CHESS_PIECE_CREDIT, pieceSrc } from './art';
|
||||
import { chessCues, chessMotion } from './fx';
|
||||
import { helpNow } from './help';
|
||||
import { nopeSound, pickSound, playChess } from './sound';
|
||||
@@ -37,91 +38,27 @@ function squareAt(x: number, y: number, bottom: Color): string {
|
||||
const pieceAt = (v: ChessView, sq: string) => v.board[idxOf(sq)] ?? null;
|
||||
const colorOfPiece = (p: string): Color => (p === p.toUpperCase() ? 'white' : 'black');
|
||||
|
||||
// ---------------------------------------------------------------- pieces (hand-drawn SVG, 100×100 box)
|
||||
|
||||
const BASE = 'M20 91 H80 Q84 91 84 87 V84 Q84 79 79 79 H21 Q16 79 16 84 V87 Q16 91 20 91 Z';
|
||||
const ROYAL_BODY = 'M30 79 L36 57 H64 L70 79 Z';
|
||||
const SHAPES: Record<PieceType, { fill: string[]; balls?: [number, number, number][]; detail?: string[] }> = {
|
||||
p: {
|
||||
fill: [
|
||||
'M33 79 C35 68 39 62 43 58 H57 C61 62 65 68 67 79 Z',
|
||||
'M38 59 H62 Q65 59 65 56 Q65 52 61 52 H39 Q35 52 35 56 Q35 59 38 59 Z',
|
||||
],
|
||||
balls: [[50, 38, 14]],
|
||||
},
|
||||
r: {
|
||||
fill: ['M30 79 L34 47 H66 L70 79 Z', 'M28 47 L27 19 H37 V26 H45 V19 H55 V26 H63 V19 H73 L72 47 Z'],
|
||||
detail: ['M33 39 H67', 'M33 66 H67'],
|
||||
},
|
||||
b: {
|
||||
fill: [
|
||||
'M35 79 C36 72 40 68 42 64 H58 C60 68 64 72 65 79 Z',
|
||||
'M37 65 H63 Q66 65 66 62 Q66 58 62 58 H38 Q34 58 34 62 Q34 65 37 65 Z',
|
||||
'M50 17 C62 26 68 38 65 49 Q63 56 58 58 H42 Q37 56 35 49 C32 38 38 26 50 17 Z',
|
||||
],
|
||||
balls: [[50, 13, 5.5]],
|
||||
detail: ['M57 29 L47 42'],
|
||||
},
|
||||
n: {
|
||||
fill: [
|
||||
'M33 79 C32 66 37 58 46 51 C41 51 36 53 31 57 C27 60 21 58 20 52 C19 47 23 43 28 39 L43 25 C45 20 48 16 52 12 L56 19 C71 22 80 40 77 79 Z',
|
||||
],
|
||||
detail: ['M61 26 C69 36 72 52 70 70'],
|
||||
balls: [
|
||||
[44, 32, 2.8],
|
||||
[26, 51, 1.6],
|
||||
],
|
||||
},
|
||||
q: {
|
||||
fill: [ROYAL_BODY, 'M32 57 L19 30 L33 44 L35 24 L44 41 L50 19 L56 41 L65 24 L67 44 L81 30 L68 57 Z'],
|
||||
balls: [
|
||||
[19, 29, 4.5],
|
||||
[35, 23, 4.5],
|
||||
[50, 17, 4.5],
|
||||
[65, 23, 4.5],
|
||||
[81, 29, 4.5],
|
||||
],
|
||||
detail: ['M34 63 H66'],
|
||||
},
|
||||
k: {
|
||||
fill: [
|
||||
ROYAL_BODY,
|
||||
'M32 57 C23 48 25 33 36 33 C43 33 47 38 50 44 C53 38 57 33 64 33 C75 33 77 48 68 57 Z',
|
||||
'M47 8 H53 V16 H60 V22 H53 V36 H47 V22 H40 V16 H47 Z',
|
||||
],
|
||||
detail: ['M34 63 H66', 'M50 44 V57'],
|
||||
},
|
||||
};
|
||||
// ---------------------------------------------------------------- pieces (Cburnett artwork, 100×100 box)
|
||||
|
||||
/**
|
||||
* One piece in a 100×100 box. The board draws that box at 0.92 of a square, 0.04 in from the corner; the artwork has
|
||||
* its own margin, so the image is grown by that inset and fills exactly one square.
|
||||
*/
|
||||
function PieceShape({ type, color }: { type: PieceType; color: Color }) {
|
||||
const shape = SHAPES[type];
|
||||
const fill = color === 'white' ? '#fbfaf5' : '#2c2a28';
|
||||
const stroke = color === 'white' ? '#1d1b19' : '#0c0b0a';
|
||||
const detail = color === 'white' ? '#1d1b19' : '#ece7dc';
|
||||
return (
|
||||
<g strokeLinejoin="round" strokeLinecap="round">
|
||||
<path d={BASE} fill={fill} stroke={stroke} strokeWidth={3.2} />
|
||||
{shape.fill.map((d, i) => (
|
||||
<path key={i} d={d} fill={fill} stroke={stroke} strokeWidth={3.2} />
|
||||
))}
|
||||
{shape.balls?.map(([cx, cy, r], i) =>
|
||||
type === 'n' ? (
|
||||
<circle key={i} cx={cx} cy={cy} r={r} fill={detail} />
|
||||
) : (
|
||||
<circle key={i} cx={cx} cy={cy} r={r} fill={fill} stroke={stroke} strokeWidth={3.2} />
|
||||
),
|
||||
)}
|
||||
{shape.detail?.map((d, i) => (
|
||||
<path key={`d${i}`} d={d} fill="none" stroke={detail} strokeWidth={2.6} />
|
||||
))}
|
||||
</g>
|
||||
);
|
||||
return <image href={pieceSrc(type, color)} x={-4.35} y={-4.35} width={108.7} height={108.7} />;
|
||||
}
|
||||
|
||||
/** A piece as a standalone inline icon (player bars, picker, rules). */
|
||||
function PieceIcon({ type, color, size = 22 }: { type: PieceType; color: Color; size?: number }) {
|
||||
return (
|
||||
<svg width={size} height={size} viewBox="0 0 100 100" aria-hidden style={{ display: 'inline-block', verticalAlign: 'middle' }}>
|
||||
<svg
|
||||
className={color === 'black' ? 'ch-icon-dark' : undefined}
|
||||
width={size}
|
||||
height={size}
|
||||
viewBox="0 0 100 100"
|
||||
aria-hidden
|
||||
style={{ display: 'inline-block', verticalAlign: 'middle' }}
|
||||
>
|
||||
<PieceShape type={type} color={color} />
|
||||
</svg>
|
||||
);
|
||||
@@ -147,6 +84,8 @@ const CHESS_CSS = `
|
||||
@keyframes ch-check { 0% { opacity: 0; transform: scale(.4); } 45% { opacity: 1; transform: scale(1.18); } 70% { transform: scale(.94); } 100% { opacity: 1; transform: scale(1); } }
|
||||
.ch-fade { animation: ch-fade .3s ease-out both; }
|
||||
@keyframes ch-fade { from { opacity: 0; } }
|
||||
:root[data-theme='dark'] .ch-icon-dark { filter: drop-shadow(0 0 .6px #e5e7eb) drop-shadow(0 0 .6px #e5e7eb); }
|
||||
@media (prefers-color-scheme: dark) { :root[data-theme='auto'] .ch-icon-dark { filter: drop-shadow(0 0 .6px #e5e7eb) drop-shadow(0 0 .6px #e5e7eb); } }
|
||||
`;
|
||||
|
||||
function ChessBoard({ view: v, act, pending }: BoardProps<ChessView>) {
|
||||
@@ -961,6 +900,7 @@ function Rules({ options }: { options?: ChessOptions }) {
|
||||
않으면 대국이 취소돼요.
|
||||
</p>
|
||||
<p>조작: 기물을 누르면 갈 수 있는 칸에 점이 찍혀요(잡을 수 있는 칸은 동그라미). 그 칸을 누르거나 기물을 끌어다 놓으면 둬요.</p>
|
||||
<p className="small muted">{CHESS_PIECE_CREDIT}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user