mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-17 07:18:04 +08:00
Implement basic circle stamping (#53)
This commit is contained in:
@@ -1,7 +1,27 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn it_works() {
|
||||
assert_eq!(2 + 2, 4);
|
||||
pub use kurbo::{Circle, Point};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum SvgElement {
|
||||
Circle(Circle),
|
||||
}
|
||||
|
||||
impl SvgElement {
|
||||
pub fn render(&self) -> String {
|
||||
match self {
|
||||
Self::Circle(c) => {
|
||||
format!(r#"<circle cx="{}" cy="{}" r="{}" style="fill: #fff;" />"#, c.center.x, c.center.y, c.radius)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq)]
|
||||
pub struct Document {
|
||||
pub svg: Vec<SvgElement>,
|
||||
}
|
||||
|
||||
impl Document {
|
||||
pub fn render(&self) -> String {
|
||||
self.svg.iter().map(|element| element.render()).collect::<Vec<_>>().join("\n")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user