Skip to content

A Canvas widget for the `Gooey` UI framework

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

khonsulabs/gooey-canvas

gooey-canvas

crate version Live Build Status HTML Coverage Report for main branch Documentation for main branch

This crate provides a Canvas widget, allowing 2d-graphics drawing via the Renderer trait.

Standalone:

Canvas::new(|renderer: CanvasRenderer| {
    renderer.fill_rect(
        &renderer.bounds().inflate(-64., -64.),
        Color::RED,
    );
})

Or as the content of a Component:

builder
    .on_render(|renderer: CanvasRenderer| {
        renderer.fill_rect(
            &renderer.bounds().inflate(-64., -64.),
            Color::RED,
        );
    })
    .finish()

Rendered in light mode (background color of the window shines through the edges):

Basic Demo Light

And dark mode:

Basic Demo Dark

Supported Frontends

Support for each frontend is controlled with feature flags. By default, frontend-browser and frontend-kludgine are both enabled.

  • frontend-browser: Enables support for the gooey-browser frontend.
  • frontend-kludgine: Enables support for the gooey-rasterizer frontend with the gooey-kludgine renderer.

Why isn't this in gooey-widgets?

One of the design philosophies of Gooey is to make the cross-platform user-interface code be unaware of the current frontend. To implement this widget, the widget implementation needs to hide the frontend from the user. The only way to do this is to have direct knowldge of all the compatible frontends.

Because this is a powerful widget, we didn't want this widget to be limited to supporting only the frontends supported by the gooey crate. Thus, this crate is separate from the main repository because other frontends will need to add support directly to this crate for Canvas to work.

Each frontend will be gated behind feature flags.

About

This is being developed by and for Khonsu Labs for Cosmic Verge. I hope it will be useful to others as well.

This code is dual-licensed under the MIT License and Apache License 2.0. Fonts in this repository are not included by default, and are solely licensed under the Apache License 2.0.

About

A Canvas widget for the `Gooey` UI framework

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages