This commit is contained in:
Maciej Caderek
2022-02-18 22:24:04 +01:00
parent 4dff0f19fa
commit 9aae91baff
14 changed files with 40 additions and 17 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@@ -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++) {

View File

@@ -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);
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;
}

View File

@@ -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,

View File

@@ -36,6 +36,7 @@ const style: Style = {
onDark: "#eee",
onBorder: "#ffffffbb",
},
ico: "/textures/wood01_ico.png",
};
export default style;

View File

@@ -36,6 +36,7 @@ const style: Style = {
onDark: "#eee",
onBorder: "#ffffffbb",
},
ico: "/textures/wood02_ico.png",
};
export default style;

View File

@@ -36,6 +36,7 @@ const style: Style = {
onDark: "#eee",
onBorder: "#ffffffbb",
},
ico: "/textures/wood03_ico.png",
};
export default style;

View File

@@ -36,6 +36,7 @@ const style: Style = {
onDark: "#eee",
onBorder: "#ffffffbb",
},
ico: "/textures/wood04_ico.png",
};
export default style;

View File

@@ -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<File>;

View File

@@ -8,6 +8,7 @@
border: solid 5px black;
margin: 5px;
cursor: pointer;
width: 72px;
}
.boards__ico--active {

View File

@@ -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][]) {
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);
}