This commit is contained in:
Maciej Caderek
2022-02-14 00:00:41 +01:00
parent 6274236ac7
commit e0b79a7071
26 changed files with 608 additions and 358 deletions

View File

@@ -1,6 +1,7 @@
import { BoardConfig } from "./../types";
import { BoardConfig, Size } from "./../types";
import Board from "../board/Board";
import Game from "../game/Game";
import sizeToPX from "./sizeToPX";
import GIF from "./GIF";
import WebM from "./WebM";
import MP4 from "./MP4";
@@ -16,10 +17,11 @@ const getData = (board: Board, encoder: GIF | WebM | MP4) => {
const createAnimation = async (
pgn: string,
boardConfig: BoardConfig,
format: "GIF" | "WebM" | "MP4"
format: "GIF" | "WebM" | "MP4",
size: Size
) => {
const game = new Game().loadPGN(pgn);
const board = new Board(boardConfig);
const board = new Board({ ...boardConfig, size: sizeToPX[size] });
const encoder =
format === "GIF"
? new GIF(board.width, board.height, true)

View File

@@ -10,7 +10,6 @@ const createImage = async (
boardConfig: BoardConfig,
size: Size
) => {
console.log({ fen, pgn, ply, size });
const game = new Game();
if (pgn) {

View File

@@ -1,5 +1,5 @@
const sizeToPX = {
XS: 256,
XS: 360,
S: 512,
M: 720,
L: 1024,