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

Store piece sprites as vector graphics #69

Open
tsevasa opened this issue Jul 11, 2024 · 9 comments
Open

Store piece sprites as vector graphics #69

tsevasa opened this issue Jul 11, 2024 · 9 comments
Labels
enhancement New feature or request

Comments

@tsevasa
Copy link
Contributor

tsevasa commented Jul 11, 2024

Lichess stores all its piece sprites as vector graphics (see here, for example) and each piece is less than 1KB in file size. In contrast, our spritesheet is a png file and takes up 1MB in total.

We should also store piece sprites in svg format.

@Naviary2
Copy link
Member

This would be great, and a huge performance boost!! As long as we can convert the vector graphics back into textures on startup!

@Naviary2 Naviary2 added the enhancement New feature or request label Jul 11, 2024
@Naviary2
Copy link
Member

All piece's have now been converted to an SVG! Next we can take steps towards using those svgs and re-forming the spritesheet on the client-side with them!

See discussion here
https://discord.com/channels/1114425729569017918/1261070585476288674

@Naviary2
Copy link
Member

I imagine we would group all the classical pieces into one http request (as svgs are just text afterall, there has to be some way to split them into individual svgs eith javascript afterward), and other fairy pieces may or may not be in groups! Atleast, a pair of a black and white piece should atleast be merged into one request.

@Heinrich-XIAO
Copy link
Contributor

I imagine we would group all the classical pieces into one http request (as svgs are just text afterall, there has to be some way to split them into individual svgs eith javascript afterward), and other fairy pieces may or may not be in groups! Atleast, a pair of a black and white piece should atleast be merged into one request.

We could combine them in one big JSON object or something.

@Heinrich-XIAO
Copy link
Contributor

image

@Naviary2
Copy link
Member

Naviary2 commented Oct 5, 2024

image

Is this the time it takes the request the spritesheet?

@Heinrich-XIAO
Copy link
Contributor

image

Is this the time it takes the request the spritesheet?

Yeah. The 1MB file.

@Naviary2
Copy link
Member

Naviary2 commented Oct 7, 2024

We don't even need to combine them all. If 95% of games are classical, we can just merge all the classical piece's svgs into one request, and only send the other fairy pieces when needed

@Naviary2
Copy link
Member

Naviary2 commented Nov 21, 2024

All pieces have already been converted into SVG's and been compressed. All we need to do from here is:

  • Write a method JavaScript method that will take a list of SVGs and create a spritesheet PNG from them (maybe could use inspiration from checkerboardgenerator.js?? Idk, ask ChatGPT how to do this)
    EDIT: Like this
  • Merge all the classical piece SVGs into one API request.
  • Create APIs for fetching all the other fairy pieces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants