Converts MIDI files into music box scores that are ready to print.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.4 KiB

using System;
using System.IO;
using System.Xml;
using SBRL.Utilities;
namespace MusicBoxConverter
{
public class SvgWriter
{
public XmlWriter xml;
public SvgWriter(string outputFilename, string widthspec = "100%", string heightspec = "100%")
{
xml = XmlWriter.Create(
outputFilename,
new XmlWriterSettings() { Indent = true }
);
xml.WriteStartDocument();
xml.WriteStartElement("svg", "http://www.w3.org/2000/svg");
xml.WriteAttributeString("version", "1.1");
xml.WriteAttributeString("width", widthspec);
xml.WriteAttributeString("height", heightspec);
}
public void Complete()
{
xml.WriteEndElement();
xml.WriteEndDocument();
xml.Close();
}
public void WritePath(string pathData, string strokeStyle = "green", int strokeWidth = 3)
{
xml.WriteStartElement("path");
xml.WriteAttributeString("d", pathData);
xml.WriteAttributeString("stroke", strokeStyle);
xml.WriteAttributeString("stroke-width", strokeWidth.ToString());
xml.WriteEndElement();
}
public void WriteCircle(Vector2 centre, int radius, string fillStyle = "blue")
{
xml.WriteStartElement("circle");
xml.WriteAttributeString("cx", centre.X.ToString());
xml.WriteAttributeString("cy", centre.Y.ToString());
xml.WriteAttributeString("r", radius.ToString());
xml.WriteAttributeString("fill", fillStyle);
xml.WriteEndElement();
}
}
}