Refactor bezier-rs' to_svg functionality (#758)

* Change Bezier to_svg to include handles and endpoints

* Move params into brackets of format macro, remove unused comment

* Use write macro instead of format

* Fix path for watched directory

* Refactor functions to remove ToSVGOptions
This commit is contained in:
Hannah Li
2022-09-01 23:13:39 -04:00
committed by GitHub
parent 131f24300a
commit 0a1665b87d
9 changed files with 388 additions and 347 deletions
@@ -5,6 +5,12 @@ pub const SVG_CLOSE_TAG: &str = "</svg>";
// Stylistic constants
pub const BLACK: &str = "black";
// Default attributes
pub const CURVE_ATTRIBUTES: &str = "stroke=\"black\" stroke-width=\"2\" fill=\"none\"";
pub const HANDLE_LINE_ATTRIBUTES: &str = "stroke=\"gray\" stroke-width=\"1\" fill=\"none\"";
pub const ANCHOR_ATTRIBUTES: &str = "r=\"4\" stroke=\"black\" stroke-width=\"2\" fill=\"white\"";
pub const HANDLE_ATTRIBUTES: &str = "r=\"3\" stroke=\"gray\" stroke-width=\"1.5\" fill=\"white\"";
/// Helper function to create an SVG text entitty.
pub fn draw_text(text: String, x_pos: f64, y_pos: f64, fill: &str) -> String {
format!(r#"<text x="{x_pos}" y="{y_pos}" fill="{fill}">{text}</text>"#)