lyze237 / gdx-TinyVG

TinyVG parser and renderer for libGDX
https://svg-to-tvg-server.fly.dev/
Apache License 2.0
25 stars 3 forks source link

Added TinyVGRegionDrawable and TinyVGRegionImage. #13

Closed raeleus closed 2 years ago

raeleus commented 2 years ago

Per your suggestion via Discord, I have created a version of the TinyVGDrawable that is backed by a TextureRegion instead of being rendered live every frame. This is an effective strategy so long as you don't also re-render the TextureRegion every frame as well. This is mitigated by the user through calling the update() method only when a change to scale or size is done.

Asking the user to manually update is a tedious request, so TinyVGRegionImage was created as a solution to this. It is an Image Widget that can automatically call update() on the TinyVGDrawable whenever layout() is called. This is the easiest implementation of TinyVG TextureRegions in Scene2D, but can still be taxing on hardware. For example, if a user allows the user to resize the LWJGL3 window, layout() may be called multiple times while the user drags the mouse. layout() also stalls considerably if the image is stretched to large proportions.

An alternative use of TinyVGRegionImage is to set the scale of the original TinyVG ahead of time. This automatically sets the minWidth and minHeight of the widget. In this case, you should set autoRedrawing to false. This is a good option to match the DPI of a target device without sacrificing detail or performance.

lyze237 commented 2 years ago

Amazing, that's great!