Expand description
This crate is a lib to generate SVG strings from geo-types.
Below is an example of a geometry collection rendered to SVG.

§Features
- GeometryCollection and all variants of Geometry are supported
- the viewport size is automatically computed to contain all shapes
- style and formatting options are available
§Example
The following will show how to convert a line to a SVG string.
The to_svg method is provided by the ToSvg trait which is implemented for all geo-types.
use geo_types::{Coord, Line, Point};
use geo_svg::{Color, ToSvg};
let point = Point::new(10.0, 28.1);
let line = Line::new(
Coord { x: 114.19, y: 22.26 },
Coord { x: 15.93, y: -15.76 },
);
let svg = point
.to_svg()
.with_radius(2.0)
.and(line.to_svg().with_stroke_width(2.5))
.with_fill_color(Color::Named("red"))
.with_stroke_color(Color::Rgb(200, 0, 100))
.with_fill_opacity(0.7);
println!("{}", svg);§Result
<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid meet" viewBox="7 -18.26 109.69 49.36"><circle cx="10" cy="28.1" r="2" fill="red" fill-opacity="0.7" stroke="rgb(200,0,100)"/><path d="M 114.19 22.26 L 15.93 -15.76" fill="red" fill-opacity="0.7" stroke="rgb(200,0,100)" stroke-width="2.5"/></svg>Structs§
- Style
- Svg
- Text
- Simple Text element for SVGs. This comes in handy if you want to enumerate some sort of geometry for any purposes
- ViewBox
Enums§
- Color
- LineCap
- LineCap is used to define the shape to be used at the end of strokes.
- Line
Join - LineJoin is used to define the shape to be used at the corners of strokes.
- Unit
- Represents a quantity in absolute CSS units.
Traits§
- Combine
ToSVG - This trait let’s you combine multiple things that can be converted to a SVG into one big compound SVG
- ToSvg
- ToSvg
Str