mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
* 🎨 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'
26 lines
562 B
Rust
26 lines
562 B
Rust
use crate::shape_points;
|
|
|
|
use super::style;
|
|
use super::LayerData;
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
|
pub struct Shape {
|
|
shape: shape_points::ShapePoints,
|
|
style: style::PathStyle,
|
|
}
|
|
|
|
impl Shape {
|
|
pub fn new(center: impl Into<kurbo::Point>, extent: impl Into<kurbo::Vec2>, sides: u8, style: style::PathStyle) -> Shape {
|
|
Shape {
|
|
shape: shape_points::ShapePoints::new(center, extent, sides),
|
|
style,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl LayerData for Shape {
|
|
fn render(&self) -> String {
|
|
format!(r#"<polygon points="{}" {} />"#, self.shape, self.style.render(),)
|
|
}
|
|
}
|