Pixplicity / sharp

Scalable vector graphics for Android
Apache License 2.0
1.03k stars 117 forks source link

Remove needless coupling between View and SharpDrawable #33

Closed jtietema closed 7 years ago

jtietema commented 7 years ago

To get a SharpDrawable you need to pass a View instance for the sole purpose, that the SharpDrawable can "prepare" that View. That doesn't make much sense if you don't want to pass that SharpDrawable to a View. In my case I would like to use it to render to a Canvas, so now I am forced to instantiate a View just to satisfy the API parameters and then throw it away.

Maybe it would make more sense to "prepare" the View in the Sharp#into() method?

pflammertsma commented 7 years ago

I'll rethink my approach, and good points.

Note that you don't need a SharpDrawable for your canvas; I'd suggest using a SharpPicture instead since the drawable is only really a wrapper.

On Fri, Feb 3, 2017, 03:36 Jeroen Tietema notifications@github.com wrote:

To get a SharpDrawable you need to pass a View instance for the sole purpose, that the SharpDrawable can "prepare" that View. That doesn't make much sense if you don't want to pass that SharpDrawable to a View. In my case I would like to use it to render to a Canvas, so now I am forced to instantiate a View just to satisfy the API parameters and then throw it away.

Maybe it would make more sense to "prepare" the View in the Sharp#into() method?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Pixplicity/sharp/issues/33, or mute the thread https://github.com/notifications/unsubscribe-auth/AARdY4E8BMzU86bZPHKAsl0Ysd1iZiB6ks5rYpK5gaJpZM4L15Xh .

jtietema commented 7 years ago

I see, but that means I have to make a special exception for the drawing of an SVG. It would be nice if can just draw it as any other Drawable 😉

pflammertsma commented 7 years ago

Note that you can safely provide null as the view argument for the SharpDrawable constructor.

pflammertsma commented 7 years ago

Resolved in 1.1.0.