aboutsummaryrefslogtreecommitdiff
path: root/src/style.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/style.rs')
-rw-r--r--src/style.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/style.rs b/src/style.rs
new file mode 100644
index 0000000..028a06b
--- /dev/null
+++ b/src/style.rs
@@ -0,0 +1,33 @@
+/// The color type that is used by all the backend
+#[derive(Clone, Copy)]
+pub struct BackendColor {
+ pub alpha: f64,
+ pub rgb: (u8, u8, u8),
+}
+
+impl BackendColor {
+ #[inline(always)]
+ pub fn mix(&self, alpha: f64) -> Self {
+ Self {
+ alpha: self.alpha * alpha,
+ rgb: self.rgb,
+ }
+ }
+}
+
+/// The style data for the backend drawing API
+pub trait BackendStyle {
+ /// Get the color of current style
+ fn color(&self) -> BackendColor;
+
+ /// Get the stroke width of current style
+ fn stroke_width(&self) -> u32 {
+ 1
+ }
+}
+
+impl BackendStyle for BackendColor {
+ fn color(&self) -> BackendColor {
+ *self
+ }
+}