Port AddPolygon -> WritePolygon from the FloatingIslands, but we should consider creating a NuGet package.
This commit is contained in:
parent
c48a5d01ce
commit
bd774bc67c
2 changed files with 20 additions and 2 deletions
|
@ -69,8 +69,9 @@ namespace MusicBoxConverter
|
||||||
SvgWriter svg = new SvgWriter(
|
SvgWriter svg = new SvgWriter(
|
||||||
destinationFilename,
|
destinationFilename,
|
||||||
$"{size.X}mm", $"{size.Y}mm"
|
$"{size.X}mm", $"{size.Y}mm"
|
||||||
);
|
) {
|
||||||
svg.UnitSuffix = "mm";
|
UnitSuffix = "mm"
|
||||||
|
};
|
||||||
|
|
||||||
// Draw the note lines
|
// Draw the note lines
|
||||||
for(float i = 0; i < area.Y; i += ScaleFactor.Y) {
|
for(float i = 0; i < area.Y; i += ScaleFactor.Y) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using SBRL.Utilities;
|
using SBRL.Utilities;
|
||||||
|
|
||||||
|
@ -17,6 +18,9 @@ namespace MusicBoxConverter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// TODO: Replace this with the (much) better version from the FloatingIslands
|
||||||
|
/// </summary>
|
||||||
public class SvgWriter
|
public class SvgWriter
|
||||||
{
|
{
|
||||||
public XmlWriter xml;
|
public XmlWriter xml;
|
||||||
|
@ -106,5 +110,18 @@ namespace MusicBoxConverter
|
||||||
xml.WriteAttributeString("fill", fillStyle);
|
xml.WriteAttributeString("fill", fillStyle);
|
||||||
xml.WriteEndElement();
|
xml.WriteEndElement();
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a solid n-sided polygon to the image.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fillStyle">The colour to fill the polygon with.</param>
|
||||||
|
/// <param name="points">The co-ordinates that make up the polygon.</param>
|
||||||
|
public void WritePolygon(string fillStyle, params Vector2[] points)
|
||||||
|
{
|
||||||
|
xml.WriteStartElement("polygon");
|
||||||
|
xml.WriteAttributeString("fill", fillStyle);
|
||||||
|
string pointsSpec = string.Join(" ", points.Select((Vector2 point) => $"{point.X},{point.Y}"));
|
||||||
|
xml.WriteAttributeString("points", pointsSpec);
|
||||||
|
xml.WriteEndElement();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue