Table of Contents

Class SvgPathException

Namespace
Egami.Drawing
Assembly
Egami.Drawing.dll

Thrown by ParseSvg(ReadOnlySpan<char>, FillRule, bool) when SVG path data breaks the grammar.

public sealed class SvgPathException : EgamiException, ISerializable
Inheritance
SvgPathException
Implements
Inherited Members

Examples

// An icon from SVG path data, drawn four times larger, and written back as compact relative data.
Path heart = Path.ParseSvg("M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09" +
                           "C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z");
string d = heart.Transform(Matrix3x2.CreateScale(4)).ToSvg(new SvgPathFormat { Relative = true, Compact = true });

// Untrusted data: TryParseSvg says whether it is valid; lenient keeps what comes before an error, as browsers draw it.
bool valid = Path.TryParseSvg("M0 0 L10 10 L20", out Path? strict);
Path drawn = Path.ParseSvg("M0 0 L10 10 L20", lenient: true);
try
{
    Path.ParseSvg("M0 0 X");
}
catch (SvgPathException e)
{
    Console.WriteLine($"{e.Problem} at character {e.Position}");
}

Constructors

SvgPathException(int, string)

Initializes a new instance of the SvgPathException class.

public SvgPathException(int position, string problem)

Parameters

position int

The index of the character where the data first breaks the grammar.

problem string

What is wrong, as a sentence.

Properties

Position

Gets the index of the character where the data first breaks the grammar.

public int Position { get; }

Property Value

int

Problem

Gets what is wrong, as a sentence.

public string Problem { get; }

Property Value

string