summaryrefslogtreecommitdiffstats
path: root/graphics/src/gradient.rs
diff options
context:
space:
mode:
authorLibravatar shan <shankern@protonmail.com>2022-09-29 10:52:58 -0700
committerLibravatar shan <shankern@protonmail.com>2022-09-29 11:15:35 -0700
commit40f45d7b7e35dd4937abe6b5ce16b6256b4f1eeb (patch)
tree38ffc5dd6bae5da4da3b93664dfe27e024dfa261 /graphics/src/gradient.rs
parent97f385e093711c269df315b28f76e66e0220e22a (diff)
downloadiced-40f45d7b7e35dd4937abe6b5ce16b6256b4f1eeb.tar.gz
iced-40f45d7b7e35dd4937abe6b5ce16b6256b4f1eeb.tar.bz2
iced-40f45d7b7e35dd4937abe6b5ce16b6256b4f1eeb.zip
Adds linear gradient support to 2D meshes in the canvas widget.
Diffstat (limited to 'graphics/src/gradient.rs')
-rw-r--r--graphics/src/gradient.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/graphics/src/gradient.rs b/graphics/src/gradient.rs
new file mode 100644
index 00000000..4d1eff62
--- /dev/null
+++ b/graphics/src/gradient.rs
@@ -0,0 +1,23 @@
+//! For creating a Gradient.
+
+use iced_native::Color;
+use crate::widget::canvas::gradient::Linear;
+
+#[derive(Debug, Clone, PartialEq)]
+/// A fill which transitions colors progressively along a direction, either linearly, radially,
+/// or conically.
+pub enum Gradient {
+ /// A linear gradient interpolates colors along a direction from its [`start`] to its [`end`]
+ /// point.
+ Linear(Linear),
+}
+
+
+#[derive(Debug, Clone, Copy, PartialEq)]
+/// A point along the gradient vector where the specified [`color`] is unmixed.
+pub struct ColorStop {
+ /// Offset along the gradient vector.
+ pub offset: f32,
+ /// The color of the gradient at the specified [`offset`].
+ pub color: Color,
+} \ No newline at end of file