mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-23 17:18:11 +08:00
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:
committed by
Keavon Chambers
parent
2849b99b59
commit
46c9ef02ca
@@ -0,0 +1,30 @@
|
||||
use super::style;
|
||||
use super::LayerData;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub struct Line {
|
||||
shape: kurbo::Line,
|
||||
style: style::PathStyle,
|
||||
}
|
||||
|
||||
impl Line {
|
||||
pub fn new(p0: impl Into<kurbo::Point>, p1: impl Into<kurbo::Point>, style: style::PathStyle) -> Line {
|
||||
Line {
|
||||
shape: kurbo::Line::new(p0, p1),
|
||||
style,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl LayerData for Line {
|
||||
fn render(&self) -> String {
|
||||
format!(
|
||||
r#"<line x1="{}" y1="{}" x2="{}" y2="{}" {} />"#,
|
||||
self.shape.p0.x,
|
||||
self.shape.p0.y,
|
||||
self.shape.p1.x,
|
||||
self.shape.p1.y,
|
||||
self.style.render(),
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user