Add colors in Rust (#78)

* 🎨 Add colors in Rust

* 🌿 Use an option for the properties and #[repr(C)]

*  Remove WASM dependency on document.

* 😎 Wrap Fill and stroke in a style struct.

* 📦 Use crate::Color

* Merge Add transactions for temporary modifications to the document

* Run cargo fmt

* Color without a 'U'
This commit is contained in:
0HyperCube
2021-04-21 22:25:06 +01:00
committed by Keavon Chambers
parent 2849b99b59
commit 46c9ef02ca
26 changed files with 689 additions and 407 deletions

View File

@@ -0,0 +1,30 @@
use super::style;
use super::LayerData;
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Rect {
shape: kurbo::Rect,
style: style::PathStyle,
}
impl Rect {
pub fn new(p0: impl Into<kurbo::Point>, p1: impl Into<kurbo::Point>, style: style::PathStyle) -> Rect {
Rect {
shape: kurbo::Rect::from_points(p0, p1),
style,
}
}
}
impl LayerData for Rect {
fn render(&self) -> String {
format!(
r#"<rect x="{}" y="{}" width="{}" height="{}" {} />"#,
self.shape.min_x(),
self.shape.min_y(),
self.shape.width(),
self.shape.height(),
self.style.render(),
)
}
}