Published
Edited
Feb 4, 2022
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
widthClamp = Math.min(width, 1500)
Insert cell
{
let ctx = canvas.getContext("2d");
boardColors.forEach((r, idxr) =>
r.forEach((c, idxc) => {
let eighth = (widthClamp * boardSize) / 8;
ctx.fillStyle = c;
ctx.fillRect(eighth * idxc, eighth * idxr, eighth, eighth);
})
);
ctx.fillText("hi", 0, widthClamp * boardSize);
return ctx;
}
Insert cell
canvas = {
return html`<canvas style="overflow:scroll; width:${widthClamp}px; height:${widthClamp}px;" width=${
widthClamp * boardSize
} height=${widthClamp * boardSize}"></canvas>`;
}
Insert cell
boardColors = boardArr.map((r, idx) =>
idx % 2
? r.map((c, idxc) => (idxc % 2 ? "black" : "white"))
: r.map((c, idxc) => (idxc % 2 ? "white" : "black"))
)
Insert cell
boardArr = [...Array(8)].map((c) => [...Array(8)])
Insert cell
boardRaw = splitData.filter((r) => r.length === 3 || r.length === 6)
Insert cell
whiteIcons = iconsRaw.slice(16, 32)
Insert cell
blackIcons = iconsRaw.slice(0, 16)
Insert cell
iconsRaw = splitData
.filter((r) => r.length === 2)
.map((r) => r[1].split(/[<>]/g))
.map((r) => r[1])
.filter((i) => i)
Insert cell
splitData = chessIconWiki.source
.split("=")
.slice(40, 181)
.map((i) => i.split(";"))
Insert cell
chessIconWiki = fetch(
"https://en.wikipedia.org/w/rest.php/v1/page/Chess_symbols_in_Unicode?format=json&origin=*"
).then((r) => r.json())
Insert cell
Insert cell
Insert cell
// Get chess piece and board details. Size, count, etc.
// Generate images based on chess piece icons and generate chess board
// Generate rule cheat sheet
// Generate a file, probably best if it's pdf
// User can print a chess set with chess board and pieces to cut out without using a lot of ink.
// --> Is there a way to estimate how much ink a file will use?
// Extra: Use your own images for the pieces and your own board background
Insert cell
// Rule cheat sheet
Insert cell
// import pdf generator
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more