This commit is contained in:
Maciej Caderek
2022-02-12 18:52:25 +01:00
parent f4b0d337ac
commit 840545886d
9 changed files with 159 additions and 21 deletions

View File

@@ -13,6 +13,8 @@ import { state, setState } from "./state";
import { render } from "solid-js/web";
import App from "./ui/App";
import download from "./utils/download";
import createImage from "./encoders/createImage";
const boardConfig: BoardConfig = {
size: 1024,
@@ -34,7 +36,8 @@ const gameConfig: GameConfig = {
toPly: null,
loop: true,
format: "GIF",
size: "M",
picSize: "M",
animationSize: "M",
};
const createDownloadLink = async (pgn: string, boardConfig: BoardConfig) => {
@@ -114,7 +117,7 @@ const main = async () => {
},
async loadPGN(pgn: string) {
const game = new Game().loadPGN(pgn);
setState({ pgn, fen: null, moves: game.getMoves() });
setState({ pgn, fen: "", moves: game.getMoves() });
await player.load(game);
},
async loadFEN(fen: string) {
@@ -122,6 +125,10 @@ const main = async () => {
setState({ pgn: null, fen, moves: game.getMoves() });
await player.load(game);
},
async downloadImage() {
const data = await createImage(state.fen, state.board, 1024);
download(data, "fen", "png");
},
};
// @ts-ignore