]> git.nega.tv - josh/narcissus/commitdiff
narcissus-core: Add extra svg helpers
authorJoshua Simmons <josh@nega.tv>
Sun, 11 Jun 2023 07:58:06 +0000 (09:58 +0200)
committerJoshua Simmons <josh@nega.tv>
Sun, 9 Jul 2023 22:08:31 +0000 (00:08 +0200)
libs/narcissus-core/src/svg.rs

index 25b2af0c588e0053e9772904ea13acb6fbdc3a15..43ad35ae3614fb45dc8e429478842a83f6dd1821 100644 (file)
@@ -36,6 +36,10 @@ pub const fn stroke(color: Color, width: f32, alpha: f32) -> Stroke {
     Stroke::Color(color, width, alpha)
 }
 
+pub const fn style(fill: Fill, stroke: Stroke) -> Style {
+    Style { fill, stroke }
+}
+
 pub fn svg_begin(w: f32, h: f32) -> SvgBegin {
     SvgBegin { w, h }
 }
@@ -44,6 +48,19 @@ pub fn svg_end() -> SvgEnd {
     SvgEnd
 }
 
+pub fn text<'a, T>(x: f32, y: f32, size: f32, style: Style, text: &'a T) -> Text<'a, T>
+where
+    T: fmt::Display,
+{
+    Text {
+        x,
+        y,
+        size,
+        style,
+        text,
+    }
+}
+
 pub fn rect(x: f32, y: f32, w: f32, h: f32) -> Rect<'static> {
     Rect {
         x,