std.svg.elements

SVG-Grundformen: Rechteck (rect), Kreis (circle), Ellipse (ellipse), Linie (line), Polyline und Polygon. Alle Funktionen akzeptieren einen CSS-Style-String für Füllfarbe, Rahmen und weitere Attribute.

std.svg · std.svg.style · std.svg.path


Verwendung

import std.svg.elements;

// Rechteck (x, y, Breite, Höhe)
SvgRect(svg, 10.0, 10.0, 200.0, 100.0, "fill:lightblue;stroke:steelblue;stroke-width:2");

// Rechteck mit abgerundeten Ecken (rx, ry)
SvgRectRounded(svg, 10.0, 10.0, 200.0, 100.0, 10.0, 10.0, "fill:lightblue");

// Kreis (cx, cy, r)
SvgCircle(svg, 300.0, 200.0, 80.0, "fill:coral;stroke:darkred;stroke-width:1.5");

// Ellipse (cx, cy, rx, ry)
SvgEllipse(svg, 400.0, 300.0, 120.0, 60.0, "fill:none;stroke:green;stroke-width:2");

// Linie (x1, y1, x2, y2)
SvgLine(svg, 50.0, 50.0, 350.0, 250.0, "stroke:black;stroke-width:1");

// Polyline (Punkte als "x1,y1 x2,y2 ...")
SvgPolyline(svg, "10,80 50,20 90,80 130,20", "fill:none;stroke:purple;stroke-width:2");

// Polygon (geschlossen)
SvgPolygon(svg, "150,0 75,130 225,130", "fill:gold;stroke:orange;stroke-width:1");


Funktionen

Signatur Sichtbarkeit Beschreibung
SvgRect(svg: Svg, x: f64, y: f64, w: f64, h: f64, style: pchar): void pub Zeichnet Rechteck
SvgRectRounded(svg: Svg, x: f64, y: f64, w: f64, h: f64, rx: f64, ry: f64, style: pchar): void pub Zeichnet Rechteck mit abgerundeten Ecken
SvgCircle(svg: Svg, cx: f64, cy: f64, r: f64, style: pchar): void pub Zeichnet Kreis
SvgEllipse(svg: Svg, cx: f64, cy: f64, rx: f64, ry: f64, style: pchar): void pub Zeichnet Ellipse
SvgLine(svg: Svg, x1: f64, y1: f64, x2: f64, y2: f64, style: pchar): void pub Zeichnet Linie
SvgPolyline(svg: Svg, points: pchar, style: pchar): void pub Zeichnet Polyline (offener Linienzug)
SvgPolygon(svg: Svg, points: pchar, style: pchar): void pub Zeichnet Polygon (geschlossener Linienzug)

Letzte Aktualisierung: 2026-05-23