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

Drawing to an image #110

Open
superlou opened this issue Feb 21, 2024 · 0 comments
Open

Drawing to an image #110

superlou opened this issue Feb 21, 2024 · 0 comments

Comments

@superlou
Copy link

After some discussion in #88, a mechanism to allow users to cheaply scale the canvas up or down would be to allow an API for drawing to an ImageHandle, which could then be scaled using hardware acceleration. From the discussion, this was where we were heading:

pub fn draw_to_image(
    &mut self,
    image: &ImageHandle,
    operations: FnOnce(&mut Graphics2D)
)

// So to draw a rectangle to an image, you'd call it as follows (in on_draw()):
// The operations done in the closure would apply to the image, rather than the main window.
graphics.draw_to_image(&image, |graphics| {
    graphics.draw_rectangle(...);
});

Then, use draw_rectangle_image(...) to draw the image into a scaled/positioned rectangle. This would also require adding a function to create an empty image/texture.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant