diff --git a/public/textures/wood01_ico.png b/public/textures/wood01_ico.png new file mode 100644 index 0000000..d1da339 Binary files /dev/null and b/public/textures/wood01_ico.png differ diff --git a/public/textures/wood02_ico.png b/public/textures/wood02_ico.png new file mode 100644 index 0000000..fc3a456 Binary files /dev/null and b/public/textures/wood02_ico.png differ diff --git a/public/textures/wood03_ico.png b/public/textures/wood03_ico.png new file mode 100644 index 0000000..dffb7b4 Binary files /dev/null and b/public/textures/wood03_ico.png differ diff --git a/public/textures/wood04_ico.png b/public/textures/wood04_ico.png new file mode 100644 index 0000000..3633ac9 Binary files /dev/null and b/public/textures/wood04_ico.png differ diff --git a/src/board/Board.ts b/src/board/Board.ts index a8a43ee..0cc9861 100644 --- a/src/board/Board.ts +++ b/src/board/Board.ts @@ -245,7 +245,8 @@ class Board { this.innerSize, this.cfg.showBorder ? this.borderWidth : 0, (this.cfg.showBorder ? this.borderWidth : 0) + this.margin, - background + background, + this.cfg.tiles ); for (let rank = 0; rank < this.cfg.tiles; rank++) { diff --git a/src/board/layers/drawRectangle.ts b/src/board/layers/drawRectangle.ts index ab8af00..dadc200 100644 --- a/src/board/layers/drawRectangle.ts +++ b/src/board/layers/drawRectangle.ts @@ -8,11 +8,28 @@ const drawRectangle = async ( height: number, x: number, y: number, - squareStyle: SquareStyle + squareStyle: SquareStyle, + tiles: number = 8 ) => { if (squareStyle.type === "image") { const img = await loadImage(squareStyle.data.src); - ctx.drawImage(img, x, y, width, height); + + if (tiles < 8) { + ctx.drawImage( + img, + 0, + 0, + img.width * (tiles / 8), + img.height * (tiles / 8), + x, + y, + width, + height + ); + } else { + ctx.drawImage(img, x, y, width, height); + } + return; } diff --git a/src/board/styles-board/index.ts b/src/board/styles-board/index.ts index 68ec492..c3c6ac8 100644 --- a/src/board/styles-board/index.ts +++ b/src/board/styles-board/index.ts @@ -13,7 +13,6 @@ import calm from "./gradient/calm"; import laguna from "./gradient/laguna"; import sunset from "./gradient/sunset"; -// import kittens from "./pic/kittens"; import wood1 from "./pic/wood1"; import wood2 from "./pic/wood2"; import wood3 from "./pic/wood3"; @@ -32,7 +31,6 @@ const styles = { calm, laguna, sunset, - // kittens, wood1, wood2, wood3, diff --git a/src/board/styles-board/pic/wood1.ts b/src/board/styles-board/pic/wood1.ts index 604d553..2ddbabc 100644 --- a/src/board/styles-board/pic/wood1.ts +++ b/src/board/styles-board/pic/wood1.ts @@ -36,6 +36,7 @@ const style: Style = { onDark: "#eee", onBorder: "#ffffffbb", }, + ico: "/textures/wood01_ico.png", }; export default style; diff --git a/src/board/styles-board/pic/wood2.ts b/src/board/styles-board/pic/wood2.ts index 3e08653..7ab5c00 100644 --- a/src/board/styles-board/pic/wood2.ts +++ b/src/board/styles-board/pic/wood2.ts @@ -36,6 +36,7 @@ const style: Style = { onDark: "#eee", onBorder: "#ffffffbb", }, + ico: "/textures/wood02_ico.png", }; export default style; diff --git a/src/board/styles-board/pic/wood3.ts b/src/board/styles-board/pic/wood3.ts index 41b4415..82c073b 100644 --- a/src/board/styles-board/pic/wood3.ts +++ b/src/board/styles-board/pic/wood3.ts @@ -36,6 +36,7 @@ const style: Style = { onDark: "#eee", onBorder: "#ffffffbb", }, + ico: "/textures/wood03_ico.png", }; export default style; diff --git a/src/board/styles-board/pic/wood4.ts b/src/board/styles-board/pic/wood4.ts index 0f97e01..c72123f 100644 --- a/src/board/styles-board/pic/wood4.ts +++ b/src/board/styles-board/pic/wood4.ts @@ -36,6 +36,7 @@ const style: Style = { onDark: "#eee", onBorder: "#ffffffbb", }, + ico: "/textures/wood04_ico.png", }; export default style; diff --git a/src/types.ts b/src/types.ts index 00745a6..0c4ba63 100644 --- a/src/types.ts +++ b/src/types.ts @@ -69,6 +69,7 @@ export type Style = { moveIndicator: MoveIndicator; border: SquareStyle; coords: Coords; + ico?: string; }; export type PieceType = "k" | "q" | "r" | "b" | "n" | "p"; @@ -206,10 +207,3 @@ export type Header = { Site: string | null; Result: string | null; }; - -export type CreateAnimation = ( - pgn: string, - boardConfig: BoardConfig, - size: Size, - includeTitleScreen: boolean -) => Promise; diff --git a/src/ui/components/Boards.css b/src/ui/components/Boards.css index 66858f6..95d4912 100644 --- a/src/ui/components/Boards.css +++ b/src/ui/components/Boards.css @@ -8,6 +8,7 @@ border: solid 5px black; margin: 5px; cursor: pointer; + width: 72px; } .boards__ico--active { diff --git a/src/ui/components/Boards.tsx b/src/ui/components/Boards.tsx index b9b9fed..769c5c1 100644 --- a/src/ui/components/Boards.tsx +++ b/src/ui/components/Boards.tsx @@ -17,21 +17,29 @@ const prepareBoards = async () => { const boards = []; const board = new Board({ - size: 72, + size: 144, tiles: 2, showBorder: true, showExtraInfo: false, }); for (const [key, style] of Object.entries(styles) as [BoardStyle, Style][]) { - await board.updateConfig({ boardStyle: key }); - await board.frame(null); - board.render(); + let img: string; + + if (style.ico) { + img = style.ico; + } else { + await board.updateConfig({ boardStyle: key }); + await board.frame(null); + board.render(); + img = board.toImgUrl(); + } + boards.push({ key, name: style.name, category: style.category, - img: board.toImgUrl(), + img, } as BoardPreview); }