Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Svg cleanup #372

Merged
merged 18 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
222 changes: 3 additions & 219 deletions src/client/css/play.css
Original file line number Diff line number Diff line change
Expand Up @@ -1037,246 +1037,30 @@ button.join-button, button.copy-button {
transform: translate(-50%, -50%);
background-color: rgba(255, 255, 255, 0.949);
box-shadow: 0px 0px 12px 0px rgba(0, 0, 0, 0.918);
background-image: url("/img/game/spritesheet64_cburnett.png");
/* The html document pre-loads only the png because it doesn't know if webp or avif is supported. */
/* @supports (background-image: url('/img/game/spritesheet64_cburnett.webp')) {
background-image: url('/img/game/spritesheet64_cburnett.webp');
}
@supports (background-image: url('/img/game/spritesheet64_cburnett.avif')) {
background-image: url('/img/game/spritesheet64_cburnett.avif');
} */
background-repeat: no-repeat;
background-size: 0;
}

.promotecolor {
display: flex;
justify-content: space-evenly;
flex-wrap: wrap;
background-image: inherit;
background-repeat: no-repeat;
background-size: 0;
}

.promotepiececontainer {
background-image: inherit;
background-repeat: no-repeat;
background-size: 0;
.promotepiece {
width: 80px;
height: 80px;
padding: 3px;
margin: 3px;
border-radius: 10px;
}

.promotepiececontainer:hover {
.promotepiece:hover {
background-color: rgba(0, 0, 0, 0.099);
}

.promotepiececontainer:active {
.promotepiece:active {
background-color: rgba(0, 0, 0, 0.158);
}

.promotepiece {
width: 80px;
height: 80px;
background-image: inherit;
background-repeat: no-repeat;
/* NEEDS TO BE as many times greater than 100% as there are pieces in a row in the spritesheet! 8 pieces => 800% */
background-size: 800%;
}

/* Spritesheet piece locations */

.pawnsW {
background-position-x: calc(100%/7 * 0);
background-position-y: calc(100%/7 * 0);
}

.pawnsB {
background-position-x: calc(100%/7 * 1);
background-position-y: calc(100%/7 * 0);
}

.knightsW {
background-position-x: calc(100%/7 * 2);
background-position-y: calc(100%/7 * 0);
}

.knightsB {
background-position-x: calc(100%/7 * 3);
background-position-y: calc(100%/7 * 0);
}

.bishopsW {
background-position-x: calc(100%/7 * 4);
background-position-y: calc(100%/7 * 0);
}

.bishopsB {
background-position-x: calc(100%/7 * 5);
background-position-y: calc(100%/7 * 0);
}

.rooksW {
background-position-x: calc(100%/7 * 6);
background-position-y: calc(100%/7 * 0);
}

.rooksB {
background-position-x: calc(100%/7 * 7);
background-position-y: calc(100%/7 * 0);
}

.queensW {
background-position-x: calc(100%/7 * 0);
background-position-y: calc(100%/7 * 1);
}

.queensB {
background-position-x: calc(100%/7 * 1);
background-position-y: calc(100%/7 * 1);
}

.kingsW {
background-position-x: calc(100%/7 * 2);
background-position-y: calc(100%/7 * 1);
}

.kingsB {
background-position-x: calc(100%/7 * 3);
background-position-y: calc(100%/7 * 1);
}

.chancellorsW {
background-position-x: calc(100%/7 * 4);
background-position-y: calc(100%/7 * 1);
}

.chancellorsB {
background-position-x: calc(100%/7 * 5);
background-position-y: calc(100%/7 * 1);
}

.archbishopsW {
background-position-x: calc(100%/7 * 6);
background-position-y: calc(100%/7 * 1);
}

.archbishopsB {
background-position-x: calc(100%/7 * 7);
background-position-y: calc(100%/7 * 1);
}

.amazonsW {
background-position-x: calc(100%/7 * 0);
background-position-y: calc(100%/7 * 2);
}

.amazonsB {
background-position-x: calc(100%/7 * 1);
background-position-y: calc(100%/7 * 2);
}

.guardsW {
background-position-x: calc(100%/7 * 2);
background-position-y: calc(100%/7 * 2);
}

.guardsB {
background-position-x: calc(100%/7 * 3);
background-position-y: calc(100%/7 * 2);
}

.hawksW {
background-position-x: calc(100%/7 * 6);
background-position-y: calc(100%/7 * 2);
}

.hawksB {
background-position-x: calc(100%/7 * 7);
background-position-y: calc(100%/7 * 2);
}

.camelsW {
background-position-x: calc(100%/7 * 0);
background-position-y: calc(100%/7 * 3);
}

.camelsB {
background-position-x: calc(100%/7 * 1);
background-position-y: calc(100%/7 * 3);
}

.giraffesW {
background-position-x: calc(100%/7 * 2);
background-position-y: calc(100%/7 * 3);
}

.giraffesB {
background-position-x: calc(100%/7 * 3);
background-position-y: calc(100%/7 * 3);
}

.zebrasW {
background-position-x: calc(100%/7 * 4);
background-position-y: calc(100%/7 * 3);
}

.zebrasB {
background-position-x: calc(100%/7 * 5);
background-position-y: calc(100%/7 * 3);
}

.knightridersW {
background-position-x: calc(100%/7 * 6);
background-position-y: calc(100%/7 * 3);
}

.knightridersB {
background-position-x: calc(100%/7 * 7);
background-position-y: calc(100%/7 * 3);
}

.rosesW {
background-position-x: calc(100%/7 * 4);
background-position-y: calc(100%/7 * 4);
}

.rosesB {
background-position-x: calc(100%/7 * 5);
background-position-y: calc(100%/7 * 4);
}

.centaursW {
background-position-x: calc(100%/7 * 6);
background-position-y: calc(100%/7 * 4);
}

.centaursB {
background-position-x: calc(100%/7 * 7);
background-position-y: calc(100%/7 * 4);
}

.royalCentaursW {
background-position-x: calc(100%/7 * 0);
background-position-y: calc(100%/7 * 5);
}

.royalCentaursB {
background-position-x: calc(100%/7 * 1);
background-position-y: calc(100%/7 * 5);
}

.royalQueensW {
background-position-x: calc(100%/7 * 2);
background-position-y: calc(100%/7 * 5);
}

.royalQueensB {
background-position-x: calc(100%/7 * 3);
background-position-y: calc(100%/7 * 5);
}


/* Pause UI */
Expand Down
12 changes: 4 additions & 8 deletions src/client/scripts/esm/chess/api/fetchPieceSVGs.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@

/**
* Fetches SVG elements from a specified SVG file based on an array of element IDs.
* Returns an array of matching SVG elements.
* Fetches piece SVGs from the server.
*/



/**
* Fetches SVG elements from an SVG file located at the provided relative URL and
* returns an array of SVG elements matching the provided IDs.
Expand All @@ -26,14 +24,12 @@ async function fetchPieceSVGs(relativeURL: string, svgIds: string[]): Promise<SV
const svgElements: SVGElement[] = [];

// Loop through the array of svgIds and fetch each corresponding SVG element
for (const svgId of svgIds) {
svgIds.forEach(svgId => {
const svgElement = svgDoc.querySelector(`#${svgId}`) as SVGElement;
if (!svgElement) {
throw new Error(`SVG with ID ${svgId} not found`);
}
if (!svgElement) throw new Error(`SVG with ID ${svgId} not found from server-sent svg data.`);
// Push the found SVG element into the array
svgElements.push(svgElement);
}
});

// Return the array of SVG elements
return svgElements;
Expand Down
Loading
Loading