summaryrefslogtreecommitdiffstats
path: root/wgpu
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2020-04-02 16:53:54 +0200
committerLibravatar GitHub <noreply@github.com>2020-04-02 16:53:54 +0200
commit3aafd2c1f7539806449b116fa98d6bf0fff94de8 (patch)
tree727eb202e24d66836065e89c279d400c053563c0 /wgpu
parent2fa6edf7a8b2a6e06b42ff9879fe81cbd1a957c6 (diff)
parent4a498ed0e3d0526ce9f47b7eefa0b2716f9b27a8 (diff)
downloadiced-3aafd2c1f7539806449b116fa98d6bf0fff94de8.tar.gz
iced-3aafd2c1f7539806449b116fa98d6bf0fff94de8.tar.bz2
iced-3aafd2c1f7539806449b116fa98d6bf0fff94de8.zip
Merge pull request #252 from hecrj/improvement/documentation
Update and improve documentation
Diffstat (limited to 'wgpu')
-rw-r--r--wgpu/CHANGELOG.md14
-rw-r--r--wgpu/README.md3
-rw-r--r--wgpu/src/lib.rs3
-rw-r--r--wgpu/src/widget/canvas.rs54
-rw-r--r--wgpu/src/widget/canvas/layer/cache.rs2
-rw-r--r--wgpu/src/widget/canvas/path.rs1
-rw-r--r--wgpu/src/widget/pane_grid.rs7
7 files changed, 65 insertions, 19 deletions
diff --git a/wgpu/CHANGELOG.md b/wgpu/CHANGELOG.md
deleted file mode 100644
index f9708308..00000000
--- a/wgpu/CHANGELOG.md
+++ /dev/null
@@ -1,14 +0,0 @@
-# Changelog
-All notable changes to this project will be documented in this file.
-
-The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
-and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-
-## [Unreleased]
-
-## [0.1.0] - 2019-11-25
-### Added
-- First release! :tada:
-
-[Unreleased]: https://github.com/hecrj/iced/compare/wgpu-0.1.0...HEAD
-[0.1.0]: https://github.com/hecrj/iced/releases/tag/wgpu-0.1.0
diff --git a/wgpu/README.md b/wgpu/README.md
index 38c6ddb6..cd80379e 100644
--- a/wgpu/README.md
+++ b/wgpu/README.md
@@ -11,8 +11,9 @@
Currently, `iced_wgpu` supports the following primitives:
- Text, which is rendered using [`wgpu_glyph`]. No shaping at all.
- Quads or rectangles, with rounded borders and a solid background color.
-- Images, lazily loaded from the filesystem.
- Clip areas, useful to implement scrollables or hide overflowing content.
+- Images and SVG, loaded from memory or the file system.
+- Meshes of triangles, useful to draw geometry freely.
![iced_wgpu](../docs/graphs/wgpu.png)
diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs
index 4e0cbc60..f00c7d2c 100644
--- a/wgpu/src/lib.rs
+++ b/wgpu/src/lib.rs
@@ -11,8 +11,9 @@
//! Currently, `iced_wgpu` supports the following primitives:
//! - Text, which is rendered using [`wgpu_glyph`]. No shaping at all.
//! - Quads or rectangles, with rounded borders and a solid background color.
-//! - Images, lazily loaded from the filesystem.
//! - Clip areas, useful to implement scrollables or hide overflowing content.
+//! - Images and SVG, loaded from memory or the file system.
+//! - Meshes of triangles, useful to draw geometry freely.
//!
//! [Iced]: https://github.com/hecrj/iced
//! [`iced_native`]: https://github.com/hecrj/iced/tree/master/native
diff --git a/wgpu/src/widget/canvas.rs b/wgpu/src/widget/canvas.rs
index 3a9605c9..325f90ce 100644
--- a/wgpu/src/widget/canvas.rs
+++ b/wgpu/src/widget/canvas.rs
@@ -33,11 +33,61 @@ pub use text::Text;
/// A widget capable of drawing 2D graphics.
///
/// A [`Canvas`] may contain multiple layers. A [`Layer`] is drawn using the
-/// painter's algorithm. In other words, layers will be drawn on top of each in
-/// the same order they are pushed into the [`Canvas`].
+/// painter's algorithm. In other words, layers will be drawn on top of each
+/// other in the same order they are pushed into the [`Canvas`].
///
/// [`Canvas`]: struct.Canvas.html
/// [`Layer`]: layer/trait.Layer.html
+///
+/// # Examples
+/// The repository has a couple of [examples] showcasing how to use a
+/// [`Canvas`]:
+///
+/// - [`clock`], an application that uses the [`Canvas`] widget to draw a clock
+/// and its hands to display the current time.
+/// - [`solar_system`], an animated solar system drawn using the [`Canvas`] widget
+/// and showcasing how to compose different transforms.
+///
+/// [examples]: https://github.com/hecrj/iced/tree/0.1/examples
+/// [`clock`]: https://github.com/hecrj/iced/tree/0.1/examples/clock
+/// [`solar_system`]: https://github.com/hecrj/iced/tree/0.1/examples/solar_system
+///
+/// ## Drawing a simple circle
+/// If you want to get a quick overview, here's how we can draw a simple circle:
+///
+/// ```no_run
+/// # mod iced {
+/// # pub use iced_wgpu::canvas;
+/// # pub use iced_native::Color;
+/// # }
+/// use iced::canvas::{self, layer, Canvas, Drawable, Fill, Frame, Path};
+/// use iced::Color;
+///
+/// // First, we define the data we need for drawing
+/// #[derive(Debug)]
+/// struct Circle {
+/// radius: f32,
+/// }
+///
+/// // Then, we implement the `Drawable` trait
+/// impl Drawable for Circle {
+/// fn draw(&self, frame: &mut Frame) {
+/// // We create a `Path` representing a simple circle
+/// let circle = Path::new(|p| p.circle(frame.center(), self.radius));
+///
+/// // And fill it with some color
+/// frame.fill(&circle, Fill::Color(Color::BLACK));
+/// }
+/// }
+///
+/// // We can use a `Cache` to avoid unnecessary re-tessellation
+/// let cache: layer::Cache<Circle> = layer::Cache::new();
+///
+/// // Finally, we simply provide the data to our `Cache` and push the resulting
+/// // layer into a `Canvas`
+/// let canvas = Canvas::new()
+/// .push(cache.with(&Circle { radius: 50.0 }));
+/// ```
#[derive(Debug)]
pub struct Canvas<'a> {
width: Length,
diff --git a/wgpu/src/widget/canvas/layer/cache.rs b/wgpu/src/widget/canvas/layer/cache.rs
index f7002459..20a095bd 100644
--- a/wgpu/src/widget/canvas/layer/cache.rs
+++ b/wgpu/src/widget/canvas/layer/cache.rs
@@ -12,7 +12,7 @@ use std::{cell::RefCell, marker::PhantomData, sync::Arc};
/// change or it is explicitly cleared.
///
/// [`Layer`]: ../trait.Layer.html
-/// [`Cached`]: struct.Cached.html
+/// [`Cache`]: struct.Cache.html
#[derive(Debug)]
pub struct Cache<T: Drawable> {
input: PhantomData<T>,
diff --git a/wgpu/src/widget/canvas/path.rs b/wgpu/src/widget/canvas/path.rs
index 15c2e853..e7ff47f3 100644
--- a/wgpu/src/widget/canvas/path.rs
+++ b/wgpu/src/widget/canvas/path.rs
@@ -3,6 +3,7 @@ pub mod arc;
mod builder;
+#[doc(no_inline)]
pub use arc::Arc;
pub use builder::Builder;
diff --git a/wgpu/src/widget/pane_grid.rs b/wgpu/src/widget/pane_grid.rs
index 7bc2f7c5..578e8960 100644
--- a/wgpu/src/widget/pane_grid.rs
+++ b/wgpu/src/widget/pane_grid.rs
@@ -1,6 +1,13 @@
//! Let your users split regions of your application and organize layout dynamically.
//!
//! [![Pane grid - Iced](https://thumbs.gfycat.com/MixedFlatJellyfish-small.gif)](https://gfycat.com/mixedflatjellyfish)
+//!
+//! # Example
+//! The [`pane_grid` example] showcases how to use a [`PaneGrid`] with resizing,
+//! drag and drop, and hotkey support.
+//!
+//! [`pane_grid` example]: https://github.com/hecrj/iced/tree/0.1/examples/pane_grid
+//! [`PaneGrid`]: type.PaneGrid.html
use crate::Renderer;
pub use iced_native::pane_grid::{