mindstorm38 / fabric-webstreamer

A Fabric mod to display web resources on screens, support for static images, HLS streaming in-game, including Twitch.
https://modrinth.com/mod/webstreamer
GNU Lesser General Public License v3.0
18 stars 9 forks source link

Add SVG support #26

Closed ajh123 closed 8 months ago

ajh123 commented 8 months ago

This adds support for rendering SVG images. SVG images are good because if you make the width / height bigger then the orignal image the image quality will be the same (useful for signs).

To parse SVGs the jsvg has been included and an additional DisplayLayerSVGImage class was added. This class pulls the SVG from the URL, uses jsvg to convert it to a PNG which then gets displayed in a similar way to other images. The WebDisplay's width and height variables are used to scale the SVG.

Demonstration

mindstorm38 commented 8 months ago

Thank you, I'm reviewing the changes, there are some changes to be made (mostly because I never thought of SVG and some classes were not ready for it).

ajh123 commented 8 months ago

Thanks

ajh123 commented 8 months ago

@mindstorm38

In my dev/svg2 branch I've made a DisplayLayerSVGImage.java and a DisplayLayerSVGMap.java.

Where would you call the constructor for DisplayLayerSVGMap?

mindstorm38 commented 8 months ago

This is great! I don't think that you have to make a record containing URI (it is redundant for the hash as map key), you can also move it to the map class I think. Passing the integer directly to the constructor. To answer your question, you just have to add a else-if case in DisplayLayerManager::getNewLayer and this should be it! It might be needed to pass the resource and keep it in your map class (maybe improved later, but anyway this will be good enough).

ajh123 commented 8 months ago

Closed, see #28 for more details.