From 7cef8c49d5f432aa83200dbd92c569b54b217036 Mon Sep 17 00:00:00 2001 From: Joshua Simmons Date: Sun, 11 Jun 2023 09:58:06 +0200 Subject: [PATCH] narcissus-core: Add extra svg helpers --- libs/narcissus-core/src/svg.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/libs/narcissus-core/src/svg.rs b/libs/narcissus-core/src/svg.rs index 25b2af0..43ad35a 100644 --- a/libs/narcissus-core/src/svg.rs +++ b/libs/narcissus-core/src/svg.rs @@ -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, -- 2.49.0