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

Canvas ui element #113

Open
dlight opened this issue Oct 23, 2019 · 1 comment
Open

Canvas ui element #113

dlight opened this issue Oct 23, 2019 · 1 comment
Labels
feature New feature or request good first issue Good for newcomers help wanted Extra attention is needed question Further information is requested

Comments

@dlight
Copy link
Contributor

dlight commented Oct 23, 2019

For an ui element made out of graphics::Canvas, is it better to

  1. build a new ui::Canvas

  2. make it so that ui::Image can accept either graphics::Image or graphics::Canvas

  3. make it so that there's a Drawable trait that has fn draw<Q: IntoQuad>(&self, quad: Q, target: &mut Target), so that ui::Image accepts a &dyn Drawable trait object.

1 is the most logical given the way the library is currently laid out, but involves duplication. But I think ui::Image shouldn't care whether it's displaying an image or a canvas, so 2) sounds better.

3 seems like a big departure from the way the lib is currently designed, but I'm curious on why coffee doesn't provide such trait already.

@hecrj
Copy link
Owner

hecrj commented Oct 25, 2019

make it so that ui::Image can accept either graphics::Image or graphics::Canvas

Maybe we could make a Canvas::image(&self) -> Image method.

make it so that there's a Drawable trait that has fn draw<Q: IntoQuad>(&self, quad: Q, target: &mut Target), so that ui::Image accepts a &dyn Drawable trait object.

ui::Image needs to also know the drawable dimensions. There are some resources where performing that kind of query isn't straightforward.

seems like a big departure from the way the lib is currently designed, but I'm curious on why coffee doesn't provide such trait already.

Well, it's just that I do not think there is a trait that fits all the different drawable resources. For instance, Mesh and Font do not take an IntoQuad.

I also try to avoid adding abstractions just because they may seem nice. I like to have a couple or more use cases first, and I haven't needed such an abstraction yet!

@hecrj hecrj added feature New feature or request good first issue Good for newcomers help wanted Extra attention is needed question Further information is requested labels Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request good first issue Good for newcomers help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants