From: Joshua Simmons Date: Sun, 11 Jun 2023 07:58:06 +0000 (+0200) Subject: narcissus-core: Add extra svg helpers X-Git-Url: https://git.nega.tv//gitweb.cgi?a=commitdiff_plain;h=7cef8c49d5f432aa83200dbd92c569b54b217036;p=josh%2Fnarcissus narcissus-core: Add extra svg helpers --- 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,