Implement Canvas support for iced_tiny_skia

This commit is contained in:
Héctor Ramón Jiménez 2023-03-01 21:34:26 +01:00
parent 3f6e28fa9b
commit 5fd5d1cdf8
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
65 changed files with 1354 additions and 570 deletions

View file

@ -5,8 +5,8 @@ use iced::widget::canvas::event::{self, Event};
use iced::widget::canvas::{self, Canvas};
use iced::widget::{column, row, slider, text};
use iced::{
Application, Color, Command, Length, Point, Rectangle, Settings, Size,
Theme,
Application, Color, Command, Length, Point, Rectangle, Renderer, Settings,
Size, Theme,
};
use rand::Rng;
@ -97,7 +97,7 @@ struct SierpinskiGraph {
cache: canvas::Cache,
}
impl canvas::Program<Message> for SierpinskiGraph {
impl canvas::Program<Message, Renderer> for SierpinskiGraph {
type State = ();
fn update(
@ -134,11 +134,12 @@ impl canvas::Program<Message> for SierpinskiGraph {
fn draw(
&self,
_state: &Self::State,
renderer: &Renderer,
_theme: &Theme,
bounds: Rectangle,
_cursor: canvas::Cursor,
) -> Vec<canvas::Geometry> {
let geom = self.cache.draw(bounds.size(), |frame| {
let geom = self.cache.draw(renderer, bounds.size(), |frame| {
frame.stroke(
&canvas::Path::rectangle(Point::ORIGIN, frame.size()),
canvas::Stroke::default(),