Introduce draw_with_bounds to canvas::Cache

Also:
  - Change `Rectangle::INFINITE` to have coordinates at `f32::NEG_INFINITY`
  - Change `Frame::with_clip` to _not_ adjust the coordinate system
  - Rename `Size::INFINITY` to `INFINITE`
This commit is contained in:
Héctor Ramón Jiménez 2025-08-17 22:31:58 +02:00
parent c1f7345ceb
commit f2aa570aac
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
13 changed files with 56 additions and 45 deletions

View file

@ -64,21 +64,14 @@ pub struct Frame {
}
impl Frame {
pub fn new(size: Size) -> Self {
Self::with_clip(Rectangle::with_size(size))
}
pub fn with_clip(clip_bounds: Rectangle) -> Self {
pub fn new(bounds: Rectangle) -> Self {
Self {
clip_bounds,
clip_bounds: bounds,
stack: Vec::new(),
primitives: Vec::new(),
images: Vec::new(),
text: Vec::new(),
transform: tiny_skia::Transform::from_translate(
clip_bounds.x,
clip_bounds.y,
),
transform: tiny_skia::Transform::identity(),
}
}
}
@ -238,7 +231,7 @@ impl geometry::frame::Backend for Frame {
align_x: text.align_x,
align_y: text.align_y,
shaping: text.shaping,
clip_bounds: Rectangle::with_size(Size::INFINITY),
clip_bounds: Rectangle::with_size(Size::INFINITE),
});
} else {
text.draw_with(|path, color| self.fill(&path, color));
@ -265,7 +258,7 @@ impl geometry::frame::Backend for Frame {
}
fn draft(&mut self, clip_bounds: Rectangle) -> Self {
Self::with_clip(clip_bounds)
Self::new(clip_bounds)
}
fn paste(&mut self, frame: Self) {

View file

@ -294,8 +294,8 @@ impl graphics::geometry::Renderer for Renderer {
type Geometry = Geometry;
type Frame = geometry::Frame;
fn new_frame(&self, size: core::Size) -> Self::Frame {
geometry::Frame::new(size)
fn new_frame(&self, bounds: Rectangle) -> Self::Frame {
geometry::Frame::new(bounds)
}
fn draw_geometry(&mut self, geometry: Self::Geometry) {