Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.2k
Add a movable canvas with matricies#175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
4d638c64ce2f7e8450cdde8145f3436fd2afa8189e3b9dd7b47ee67f854715db737e27df1a95e70c791700aa790ba1d4f46b664f989b6263d10f74a8991094ecd3f34dd8b048ce66e3577e089c904abee30a11779898821137682f6a250f50cfa296f4ef8fcb015239b56a64aa1bbc9cb715fd425e5aae6be462f19a164d0b10a60663415bdb6cc5063e009dFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,37 +1,24 @@ | ||
| use kurbo::Shape; | ||
| use super::style; | ||
| use super::LayerData; | ||
| use std::fmt::Write; | ||
| #[derive(Debug, Clone, Copy, PartialEq, Default)] | ||
| pub struct Ellipse { | ||
| shape: kurbo::Ellipse, | ||
| style: style::PathStyle, | ||
| } | ||
| pub struct Ellipse {} | ||
| impl Ellipse { | ||
| pub fn new(center: impl Into<kurbo::Point>, radii: impl Into<kurbo::Vec2>, rotation: f64, style: style::PathStyle) -> Ellipse { | ||
| Ellipse { | ||
| shape: kurbo::Ellipse::new(center, radii, rotation), | ||
| style, | ||
| } | ||
| pub fn new() -> Ellipse { | ||
| Ellipse {} | ||
| } | ||
| } | ||
| impl LayerData for Ellipse { | ||
| fn render(&mut self, svg: &mut String) { | ||
| let kurbo::Vec2 { x: rx, y: ry } = self.shape.radii(); | ||
| let kurbo::Point { x: cx, y: cy } = self.shape.center(); | ||
| let _ = write!( | ||
| svg, | ||
| r#"<ellipse cx="0" cy="0" rx="{}" ry="{}" transform="translate({} {}) rotate({})"{} />"#, | ||
| rx, | ||
| ry, | ||
| cx, | ||
| cy, | ||
| self.shape.rotation().to_degrees(), | ||
| self.style.render(), | ||
| ); | ||
| fn to_kurbo_path(&mut self, transform: glam::DAffine2, _style: style::PathStyle) -> kurbo::BezPath { | ||
| kurbo::Ellipse::from_affine(kurbo::Affine::new(transform.to_cols_array())).to_path(0.1) | ||
| } | ||
| fn render(&mut self, svg: &mut String, transform: glam::DAffine2, style: style::PathStyle) { | ||
| let _ = write!(svg, r#"<path d="{}" {} />"#, self.to_kurbo_path(transform, style).to_svg(), style.render()); | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.