diff --git a/MusicBoxConverter/MusicBoxScoreGenerator.cs b/MusicBoxConverter/MusicBoxScoreGenerator.cs index a44a840..7f6991a 100644 --- a/MusicBoxConverter/MusicBoxScoreGenerator.cs +++ b/MusicBoxConverter/MusicBoxScoreGenerator.cs @@ -19,7 +19,7 @@ namespace MusicBoxConverter private int trackLength; public int TrackLength { get { - if(trackLength == null) + if(trackLength == 0) trackLength = (int)AllNotes().Max((Note arg) => arg.Time); return trackLength; } @@ -34,13 +34,17 @@ namespace MusicBoxConverter public void Output(string destinationFilename) { - SvgWriter svg = new SvgWriter(destinationFilename); - svg.WriteRectangle(offset, new Vector2(TrackLength, 128).Multiply(scaleFactor)); - for(int i = 0; i < 255; i += 5) + Vector2 area = new Vector2(TrackLength, 128).Multiply(scaleFactor); + Vector2 size = area.Add(offset.Multiply(2)); + + SvgWriter svg = new SvgWriter(destinationFilename, size.X.ToString(), size.Y.ToString()); + Console.WriteLine(0b1111111); + for(int i = 0; i < 127; i += 5) { - Vector2 start = offset.Add(new Vector2(0, i)); - svg.WriteLine(start, start.Add(new Vector2(TrackLength, 0))); + Vector2 start = offset.Add(new Vector2(0, i * scaleFactor.Y)); + svg.WriteLine(start, start.Add(new Vector2(TrackLength * scaleFactor.X, 0))); } + svg.WriteRectangle(offset, area); foreach(Note note in AllNotes()) { diff --git a/MusicBoxConverter/SvgWriter.cs b/MusicBoxConverter/SvgWriter.cs index 5323fef..f6a4423 100644 --- a/MusicBoxConverter/SvgWriter.cs +++ b/MusicBoxConverter/SvgWriter.cs @@ -17,6 +17,7 @@ namespace MusicBoxConverter ); xml.WriteStartDocument(); + xml.WriteDocType("svg", "-//W3C//DTD SVG 1.1//EN", "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd", null); xml.WriteStartElement("svg", "http://www.w3.org/2000/svg"); xml.WriteAttributeString("version", "1.1"); xml.WriteAttributeString("width", widthspec); @@ -32,7 +33,7 @@ namespace MusicBoxConverter public void WriteLine(Vector2 start, Vector2 end, string strokeStyle = "darkgreen", int strokeWidth = 3) { - WritePath($"M {start.X} {start.Y} L {end.X} {end.Y}", strokeStyle, strokeWidth); + WritePath($"M{start.X} {start.Y} L {end.X} {end.Y}", strokeStyle, strokeWidth); } public void WritePath(string pathData, string strokeStyle = "green", int strokeWidth = 3) @@ -41,6 +42,7 @@ namespace MusicBoxConverter xml.WriteAttributeString("d", pathData); xml.WriteAttributeString("stroke", strokeStyle); xml.WriteAttributeString("stroke-width", strokeWidth.ToString()); + xml.WriteAttributeString("fill", "transparent"); xml.WriteEndElement(); } diff --git a/MusicBoxConverter/Utilities/Vector2.cs b/MusicBoxConverter/Utilities/Vector2.cs index 7dfcd01..71d926d 100644 --- a/MusicBoxConverter/Utilities/Vector2.cs +++ b/MusicBoxConverter/Utilities/Vector2.cs @@ -39,14 +39,14 @@ namespace SBRL.Utilities { return new Vector2( X + b.X, - Y + b.X + Y + b.Y ); } public Vector2 Subtract(Vector2 b) { return new Vector2( X - b.X, - Y - b.X + Y - b.Y ); } public Vector2 Divide(int b)