summaryrefslogtreecommitdiffstats
path: root/wgpu/src/geometry.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-05-11 15:37:56 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-05-11 15:37:56 +0200
commitde638f44a5c62459008a5c024b39c2443b72bf25 (patch)
tree68792277ddcebcf39dab8006926b017daf704510 /wgpu/src/geometry.rs
parent8622e998f2701e7f4ca8d2f71c85150f436a9945 (diff)
downloadiced-de638f44a5c62459008a5c024b39c2443b72bf25.tar.gz
iced-de638f44a5c62459008a5c024b39c2443b72bf25.tar.bz2
iced-de638f44a5c62459008a5c024b39c2443b72bf25.zip
Write missing documentation in `iced_wgpu`
Diffstat (limited to 'wgpu/src/geometry.rs')
-rw-r--r--wgpu/src/geometry.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/wgpu/src/geometry.rs b/wgpu/src/geometry.rs
index 8cfed1e5..7e17a7ad 100644
--- a/wgpu/src/geometry.rs
+++ b/wgpu/src/geometry.rs
@@ -1,3 +1,4 @@
+//! Build and draw geometry.
use crate::core::{Gradient, Point, Rectangle, Size, Vector};
use crate::graphics::geometry::fill::{self, Fill};
use crate::graphics::geometry::{
@@ -9,9 +10,7 @@ use lyon::geom::euclid;
use lyon::tessellation;
use std::borrow::Cow;
-/// The frame of a [`Canvas`].
-///
-/// [`Canvas`]: crate::widget::Canvas
+/// A frame for drawing some geometry.
#[allow(missing_debug_implementations)]
pub struct Frame {
size: Size,
@@ -353,10 +352,12 @@ impl Frame {
self.pop_transform();
}
+ /// Pushes the current transform in the transform stack.
pub fn push_transform(&mut self) {
self.transforms.previous.push(self.transforms.current);
}
+ /// Pops a transform from the transform stack and sets it as the current transform.
pub fn pop_transform(&mut self) {
self.transforms.current = self.transforms.previous.pop().unwrap();
}
@@ -373,14 +374,16 @@ impl Frame {
f(&mut frame);
- let translation = Vector::new(region.x, region.y);
+ let origin = Point::new(region.x, region.y);
- self.clip(frame, translation);
+ self.clip(frame, origin);
}
- pub fn clip(&mut self, frame: Frame, translation: Vector) {
+ /// Draws the clipped contents of the given [`Frame`] with origin at the given [`Point`].
+ pub fn clip(&mut self, frame: Frame, at: Point) {
let size = frame.size();
let primitives = frame.into_primitives();
+ let translation = Vector::new(at.x, at.y);
let (text, meshes) = primitives
.into_iter()