|
|
|
@ -27,6 +27,10 @@ namespace MusicBoxConverter
@@ -27,6 +27,10 @@ namespace MusicBoxConverter
|
|
|
|
|
|
|
|
|
|
public string UnitSuffix { get; set; } = ""; |
|
|
|
|
|
|
|
|
|
public float FontSizeRegular { get; set; } = 3; |
|
|
|
|
|
|
|
|
|
private bool haveWrittenFontStyles = false; |
|
|
|
|
|
|
|
|
|
public SvgWriter(string outputFilename, string widthspec = "100%", string heightspec = "100%", Rectangle viewBox = null) |
|
|
|
|
{ |
|
|
|
|
xml = XmlWriter.Create( |
|
|
|
@ -57,6 +61,22 @@ namespace MusicBoxConverter
@@ -57,6 +61,22 @@ namespace MusicBoxConverter
|
|
|
|
|
xml.Close(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void WriteText(Vector2 pos, string text, string className) |
|
|
|
|
{ |
|
|
|
|
if (!haveWrittenFontStyles) |
|
|
|
|
{ |
|
|
|
|
xml.WriteElementString("style", $".regular {{ font: {FontSizeRegular}{UnitSuffix} sans-serif; }}"); |
|
|
|
|
haveWrittenFontStyles = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
xml.WriteStartElement("text"); |
|
|
|
|
xml.WriteAttributeString("x", $"{pos.X}{UnitSuffix}"); |
|
|
|
|
xml.WriteAttributeString("y", $"{pos.Y}{UnitSuffix}"); |
|
|
|
|
xml.WriteAttributeString("class", className); |
|
|
|
|
xml.WriteString(text); |
|
|
|
|
xml.WriteEndElement(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void WriteLine(Vector2 start, Vector2 end, string strokeStyle = "darkgreen", float strokeWidth = 3) |
|
|
|
|
{ |
|
|
|
|
xml.WriteStartElement("line"); |
|
|
|
|