Board styles - crated script for chesscom board styles, changed moves indicator type to handle different targets

This commit is contained in:
Maciej Caderek
2022-05-01 00:49:40 +02:00
parent b38edef612
commit 924da0ed8f
140 changed files with 1286 additions and 154 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,19 +1,57 @@
import { BoardStyle } from "./../src/types";
import { BoardStyle, Style } from "./../src/types";
import { loadImage, createCanvas } from "canvas";
import Board from "../src/board/Board";
import { CreateCanvas, LoadImage } from "../src/types";
import boardStyles from "../src/board/styles-board/boardStyles";
import fs from "fs";
const size = 128;
const OUT_DIR = "public/boards";
const size = 1200;
// const OUT_DIR = "public/boards";
const OUT_DIR_LICHESS = "public/stylus/lichess/boards";
const OUT_DIR_CHESSCOM = "public/stylus/chesscom/boards";
const ChesscomStylesheet = (
dataURL: string,
boardName: string,
style: Style
) => {
return `
/* ==UserStyle==
@name ${boardName} chess set
@namespace chess.com
@version 1.0.0
@description Chess set for chess.com
@author sharechess.github.io
==/UserStyle== */
@-moz-document domain("chess.com") {
.board {background-image: url(${dataURL}) !important}
.coordinate-light {fill: ${style.coords.onLight} !important}
.coordinate-dark {fill: ${style.coords.onDark} !important}
.highlight {opacity: 1 !important; background-color: ${style.moveIndicator.color} !important}
}
`;
};
const main = async () => {
if (!fs.existsSync(OUT_DIR_CHESSCOM)) {
fs.mkdirSync(OUT_DIR_CHESSCOM, { recursive: true });
}
if (!fs.existsSync(OUT_DIR_LICHESS)) {
fs.mkdirSync(OUT_DIR_LICHESS, { recursive: true });
}
const create = () => createCanvas(size, size);
const load = (src: string) => loadImage(`public${src}`);
for (const boardStyle of Object.keys(boardStyles)) {
console.log(`Generating image for board ${boardStyle}...`);
console.log(`Generating stylesheets for board: ${boardStyle}...`);
const boardNamePretty = boardStyle
.split(/[-_]/)
.map((chunk) => chunk[0].toUpperCase() + chunk.substring(1))
.join(" ");
const board = new Board(
{
@@ -29,13 +67,18 @@ const main = async () => {
await board.renderStatic();
// @ts-ignore
const image = board.canvas.toBuffer();
// const image = board.canvas.toBuffer();
if (!fs.existsSync(OUT_DIR)) {
fs.mkdirSync(OUT_DIR, { recursive: true });
}
const chesscomStylesheet = ChesscomStylesheet(
board.toImgUrl(),
boardNamePretty,
boardStyles[boardStyle as BoardStyle]
);
fs.writeFileSync(`${OUT_DIR}/${boardStyle}.png`, image);
fs.writeFileSync(
`${OUT_DIR_CHESSCOM}/${boardStyle}.user.css`,
chesscomStylesheet
);
}
};

View File

@@ -34,12 +34,12 @@ const drawMoveIndicators = async (
let fromStyle;
let toStyle;
if (moveIndicator.type === "hueShift") {
if (moveIndicator.hueShift !== 0) {
const newLight: Solid = {
type: "solid",
data: {
color: light.data.color
? changeHSL(light.data.color, moveIndicator.data)
? changeHSL(light.data.color, moveIndicator.hueShift)
: "#00ff0055",
},
};
@@ -48,7 +48,7 @@ const drawMoveIndicators = async (
type: "solid",
data: {
color: dark.data.color
? changeHSL(dark.data.color, moveIndicator.data)
? changeHSL(dark.data.color, moveIndicator.hueShift)
: "#00ff0055",
},
};
@@ -58,7 +58,7 @@ const drawMoveIndicators = async (
} else {
fromStyle = {
type: "solid",
data: { color: moveIndicator.data },
data: { color: moveIndicator.color },
} as SquareStyle;
toStyle = fromStyle;
}

View File

@@ -22,8 +22,8 @@ const style: Style = {
},
},
moveIndicator: {
type: "color",
data: "#3cff0055",
hueShift: 0,
color: "#3cff0055",
},
border: {
type: "gradient",

View File

@@ -22,8 +22,8 @@ const style: Style = {
},
},
moveIndicator: {
type: "color",
data: "#ffaa0055",
hueShift: 0,
color: "#ffaa0055",
},
border: {
type: "gradient",

View File

@@ -22,8 +22,8 @@ const style: Style = {
},
},
moveIndicator: {
type: "color",
data: "#00ffff55",
hueShift: 0,
color: "#00ffff55",
},
border: {
type: "gradient",

View File

@@ -22,8 +22,8 @@ const style: Style = {
},
},
moveIndicator: {
type: "color",
data: "#ffaa0055",
hueShift: 0,
color: "#ffaa0055",
},
border: {
type: "gradient",

View File

@@ -22,8 +22,8 @@ const style: Style = {
},
},
moveIndicator: {
type: "color",
data: "#ffff0055",
hueShift: 0,
color: "#ffff0055",
},
border: {
type: "gradient",

View File

@@ -22,8 +22,8 @@ const style: Style = {
},
},
moveIndicator: {
type: "color",
data: "#3cff0055",
hueShift: 0,
color: "#3cff0055",
},
border: {
type: "gradient",

View File

@@ -22,8 +22,8 @@ const style: Style = {
},
},
moveIndicator: {
type: "color",
data: "#3cff0055",
hueShift: 0,
color: "#3cff0055",
},
border: {
type: "gradient",

View File

@@ -22,8 +22,8 @@ const style: Style = {
},
},
moveIndicator: {
type: "color",
data: "#ff00ff55",
hueShift: 0,
color: "#ff00ff55",
},
border: {
type: "gradient",

View File

@@ -22,8 +22,8 @@ const style: Style = {
},
},
moveIndicator: {
type: "color",
data: "#00ffff55",
hueShift: 0,
color: "#00ffff55",
},
border: {
type: "gradient",

View File

@@ -22,8 +22,8 @@ const style: Style = {
},
},
moveIndicator: {
type: "color",
data: "#00ffee55",
hueShift: 0,
color: "#00ffee55",
},
border: {
type: "gradient",

View File

@@ -22,8 +22,8 @@ const style: Style = {
},
},
moveIndicator: {
type: "color",
data: "#00ffee55",
hueShift: 0,
color: "#00ffee55",
},
border: {
type: "gradient",

View File

@@ -22,8 +22,8 @@ const style: Style = {
},
},
moveIndicator: {
type: "color",
data: "#ffaa0055",
hueShift: 0,
color: "#ffaa0055",
},
border: {
type: "gradient",

View File

@@ -21,8 +21,8 @@ const style: Style = {
},
},
moveIndicator: {
type: "color",
data: "#55ff0022",
hueShift: 0,
color: "#55ff0022",
},
border: {
type: "solid",

View File

@@ -21,8 +21,8 @@ const style: Style = {
},
},
moveIndicator: {
type: "color",
data: "#55ff0022",
hueShift: 0,
color: "#55ff0022",
},
border: {
type: "image",

View File

@@ -21,8 +21,8 @@ const style: Style = {
},
},
moveIndicator: {
type: "color",
data: "#55ff0022",
hueShift: 0,
color: "#55ff0022",
},
border: {
type: "image",

View File

@@ -21,8 +21,8 @@ const style: Style = {
},
},
moveIndicator: {
type: "color",
data: "#55ff0022",
hueShift: 0,
color: "#55ff0022",
},
border: {
type: "solid",

View File

@@ -21,8 +21,8 @@ const style: Style = {
},
},
moveIndicator: {
type: "color",
data: "#55ff0022",
hueShift: 0,
color: "#55ff0022",
},
border: {
type: "image",

View File

@@ -21,8 +21,8 @@ const style: Style = {
},
},
moveIndicator: {
type: "color",
data: "#55ff0022",
hueShift: 0,
color: "#55ff0022",
},
border: {
type: "image",

View File

@@ -21,8 +21,8 @@ const style: Style = {
},
},
moveIndicator: {
type: "color",
data: "#ff007733",
hueShift: 0,
color: "#ff007733",
},
border: {
type: "image",

View File

@@ -21,8 +21,8 @@ const style: Style = {
},
},
moveIndicator: {
type: "color",
data: "#ff007733",
hueShift: 0,
color: "#ff007733",
},
border: {
type: "image",

View File

@@ -21,8 +21,8 @@ const style: Style = {
},
},
moveIndicator: {
type: "color",
data: "#55ff0022",
hueShift: 0,
color: "#55ff0022",
},
border: {
type: "image",

View File

@@ -21,8 +21,8 @@ const style: Style = {
},
},
moveIndicator: {
type: "color",
data: "#55ff0022",
hueShift: 0,
color: "#55ff0022",
},
border: {
type: "image",

View File

@@ -21,8 +21,8 @@ const style: Style = {
},
},
moveIndicator: {
type: "color",
data: "#55ff0022",
hueShift: 0,
color: "#55ff0022",
},
border: {
type: "image",

View File

@@ -21,8 +21,8 @@ const style: Style = {
},
},
moveIndicator: {
type: "color",
data: "#55ff0022",
hueShift: 0,
color: "#55ff0022",
},
border: {
type: "image",

View File

@@ -21,8 +21,8 @@ const style: Style = {
},
},
moveIndicator: {
type: "hueShift",
data: 70,
hueShift: 70,
color: "#",
},
border: {
type: "solid",

View File

@@ -21,8 +21,8 @@ const style: Style = {
},
},
moveIndicator: {
type: "color",
data: "#ff000044",
hueShift: 0,
color: "#ff000044",
},
border: {
type: "solid",

View File

@@ -21,8 +21,8 @@ const style: Style = {
},
},
moveIndicator: {
type: "color",
data: "#7dacc97f",
hueShift: 0,
color: "#7dacc97f",
},
border: {
type: "solid",

View File

@@ -21,8 +21,8 @@ const style: Style = {
},
},
moveIndicator: {
type: "color",
data: "#ffff0055",
hueShift: 0,
color: "#ffff0055",
},
border: {
type: "solid",

View File

@@ -21,8 +21,8 @@ const style: Style = {
},
},
moveIndicator: {
type: "color",
data: "#ffff007f",
hueShift: 0,
color: "#ffff007f",
},
border: {
type: "solid",

View File

@@ -21,8 +21,8 @@ const style: Style = {
},
},
moveIndicator: {
type: "color",
data: "#00bfff7f",
hueShift: 0,
color: "#00bfff7f",
},
border: {
type: "solid",

Some files were not shown because too many files have changed in this diff Show More