canvas icon indicating copy to clipboard operation
canvas copied to clipboard

Custom renderers

Open bmuessig opened this issue 2 years ago • 3 comments

Hi @tdewolff,

thanks a lot for providing this well-written and useful library.

I am currently in the process of writing a custom renderer for a JSON-based vector format I developed and use in many projects. The internal renderers do most of their path rendering directly in path.go with access to the private backing array.

Is there a way to do this with similar efficiency via the public API? I've had a quick look at Scanner, but it does not appear to provide the same amount of command detail as is available internally.

A perhaps more modular renderer system would be useful for the next major version, where renderers are implemented externally and could be put into their own repositories (especially OpenGL, which has many dependencies).

bmuessig avatar Apr 09 '23 11:04 bmuessig

Hey Benedikt, thanks for the kind words, I'm happy to hear that the library is proving useful to you!

I've added the Path.Data function to get the private d []float64 data field, however the Scanner interface actually allows you to fully retrieve all path data and is a cleaner approach. What does the scanner not allow you to get?

tdewolff avatar Apr 09 '23 16:04 tdewolff

I've added the Path.Data function to get the private d []float64 data field

Thank you very much for the quick reply and the addition.

however the Scanner interface actually allows you to fully retrieve all path data and is a cleaner approach. What does the scanner not allow you to get?

You are right, I have no idea how I did not see the Scanner.Cmd() at first glance - perhaps it somehow got lost in my IDE autocomplete. It appears to be all there.

What I thought might be useful for the next major version would be to implement the existing renderers via the Scanner interface to avoid baking them into the Path struct.

bmuessig avatar Apr 09 '23 17:04 bmuessig

That's a great idea, especially for the OpenGL renderer and maybe the Fyne and Gio renderers!

tdewolff avatar Apr 09 '23 19:04 tdewolff