Write missing documentation in iced_wgpu
This commit is contained in:
parent
8622e998f2
commit
de638f44a5
6 changed files with 17 additions and 18 deletions
|
|
@ -1,8 +1,4 @@
|
||||||
//! Draw 2D graphics for your users.
|
//! Build and draw geometry.
|
||||||
//!
|
|
||||||
//! A [`Canvas`] widget can be used to draw different kinds of 2D shapes in a
|
|
||||||
//! [`Frame`]. It can be used for animation, data visualization, game graphics,
|
|
||||||
//! and more!
|
|
||||||
pub mod fill;
|
pub mod fill;
|
||||||
pub mod path;
|
pub mod path;
|
||||||
pub mod stroke;
|
pub mod stroke;
|
||||||
|
|
|
||||||
|
|
@ -135,15 +135,15 @@ impl Frame {
|
||||||
|
|
||||||
f(&mut frame);
|
f(&mut frame);
|
||||||
|
|
||||||
let translation = Vector::new(region.x, region.y);
|
let origin = Point::new(region.x, region.y);
|
||||||
|
|
||||||
match (self, frame) {
|
match (self, frame) {
|
||||||
(Self::TinySkia(target), Self::TinySkia(frame)) => {
|
(Self::TinySkia(target), Self::TinySkia(frame)) => {
|
||||||
target.clip(frame, translation);
|
target.clip(frame, origin);
|
||||||
}
|
}
|
||||||
#[cfg(feature = "wgpu")]
|
#[cfg(feature = "wgpu")]
|
||||||
(Self::Wgpu(target), Self::Wgpu(frame)) => {
|
(Self::Wgpu(target), Self::Wgpu(frame)) => {
|
||||||
target.clip(frame, translation);
|
target.clip(frame, origin);
|
||||||
}
|
}
|
||||||
#[allow(unreachable_patterns)]
|
#[allow(unreachable_patterns)]
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
)]
|
)]
|
||||||
#![deny(
|
#![deny(
|
||||||
missing_debug_implementations,
|
missing_debug_implementations,
|
||||||
//missing_docs,
|
missing_docs,
|
||||||
unused_results,
|
unused_results,
|
||||||
clippy::extra_unused_lifetimes,
|
clippy::extra_unused_lifetimes,
|
||||||
clippy::from_over_into,
|
clippy::from_over_into,
|
||||||
|
|
|
||||||
|
|
@ -127,9 +127,9 @@ impl Frame {
|
||||||
self.transform = self.stack.pop().expect("Pop transform");
|
self.transform = self.stack.pop().expect("Pop transform");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clip(&mut self, frame: Self, translation: Vector) {
|
pub fn clip(&mut self, frame: Self, at: Point) {
|
||||||
self.primitives.push(Primitive::Translate {
|
self.primitives.push(Primitive::Translate {
|
||||||
translation,
|
translation: Vector::new(at.x, at.y),
|
||||||
content: Box::new(frame.into_primitive()),
|
content: Box::new(frame.into_primitive()),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
//! Build and draw geometry.
|
||||||
use crate::core::{Gradient, Point, Rectangle, Size, Vector};
|
use crate::core::{Gradient, Point, Rectangle, Size, Vector};
|
||||||
use crate::graphics::geometry::fill::{self, Fill};
|
use crate::graphics::geometry::fill::{self, Fill};
|
||||||
use crate::graphics::geometry::{
|
use crate::graphics::geometry::{
|
||||||
|
|
@ -9,9 +10,7 @@ use lyon::geom::euclid;
|
||||||
use lyon::tessellation;
|
use lyon::tessellation;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
/// The frame of a [`Canvas`].
|
/// A frame for drawing some geometry.
|
||||||
///
|
|
||||||
/// [`Canvas`]: crate::widget::Canvas
|
|
||||||
#[allow(missing_debug_implementations)]
|
#[allow(missing_debug_implementations)]
|
||||||
pub struct Frame {
|
pub struct Frame {
|
||||||
size: Size,
|
size: Size,
|
||||||
|
|
@ -353,10 +352,12 @@ impl Frame {
|
||||||
self.pop_transform();
|
self.pop_transform();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Pushes the current transform in the transform stack.
|
||||||
pub fn push_transform(&mut self) {
|
pub fn push_transform(&mut self) {
|
||||||
self.transforms.previous.push(self.transforms.current);
|
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) {
|
pub fn pop_transform(&mut self) {
|
||||||
self.transforms.current = self.transforms.previous.pop().unwrap();
|
self.transforms.current = self.transforms.previous.pop().unwrap();
|
||||||
}
|
}
|
||||||
|
|
@ -373,14 +374,16 @@ impl Frame {
|
||||||
|
|
||||||
f(&mut 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 size = frame.size();
|
||||||
let primitives = frame.into_primitives();
|
let primitives = frame.into_primitives();
|
||||||
|
let translation = Vector::new(at.x, at.y);
|
||||||
|
|
||||||
let (text, meshes) = primitives
|
let (text, meshes) = primitives
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
)]
|
)]
|
||||||
#![deny(
|
#![deny(
|
||||||
missing_debug_implementations,
|
missing_debug_implementations,
|
||||||
//missing_docs,
|
missing_docs,
|
||||||
unsafe_code,
|
unsafe_code,
|
||||||
unused_results,
|
unused_results,
|
||||||
clippy::extra_unused_lifetimes,
|
clippy::extra_unused_lifetimes,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue