How do I create SVG?

Oct 8, 2015 at 8:56 AM
I have been searching for days for some documentation or samples for creating a new SVG Document. What I want to do is generate some polygons in and SVG Doc and save it but have not found any samples for this. Anyone had any experience with this?

Thanks
Oct 22, 2015 at 10:08 PM
This should get you started.
var oSvgDocument = new SvgDocument();

var oSvgPolygon_Square = new SvgPolygon
{
    Stroke = new SvgColourServer(Color.Blue),
    StrokeWidth = 40.0F,
    StrokeOpacity = 0.50F,
    StrokeLineJoin = SvgStrokeLineJoin.Bevel,

    Fill = new SvgColourServer(Color.Red),
    FillOpacity = 0.50F,
    FillRule = SvgFillRule.EvenOdd,

    Points = new SvgPointCollection(),
};

oSvgPolygon_Square.Points.AddRange(new[]
{
    new SvgUnit(300F), new SvgUnit(300F),
    new SvgUnit(300F), new SvgUnit(600F),
    new SvgUnit(600F), new SvgUnit(600F),
    new SvgUnit(600F), new SvgUnit(300F),
});

var oSvgPolygon_Triangle = new SvgPolygon
{
    Stroke = new SvgColourServer(Color.Green),
    StrokeWidth = 20.0F,
    StrokeOpacity = 0.50F,
    StrokeLineJoin = SvgStrokeLineJoin.Round,

    Fill = new SvgColourServer(Color.Yellow),
    FillOpacity = 0.50F,
    FillRule = SvgFillRule.EvenOdd,

    Points = new SvgPointCollection(),
};

oSvgPolygon_Triangle.Points.AddRange(new[]
{
    new SvgUnit(150F), new SvgUnit(300F),
    new SvgUnit(750F), new SvgUnit(450F),
    new SvgUnit(150F), new SvgUnit(600F),
});

oSvgDocument.Children.Add(oSvgPolygon_Square);
oSvgDocument.Children.Add(oSvgPolygon_Triangle);

oSvgDocument.Write("Shapes.svg");