Correct display of initial grid

This commit is contained in:
Starbeamrainbowlabs 2017-12-02 16:44:12 +00:00
parent ff1fb90351
commit b80c5bba6c
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
3 changed files with 15 additions and 9 deletions

View file

@ -19,7 +19,7 @@ namespace MusicBoxConverter
private int trackLength; private int trackLength;
public int TrackLength { public int TrackLength {
get { get {
if(trackLength == null) if(trackLength == 0)
trackLength = (int)AllNotes().Max((Note arg) => arg.Time); trackLength = (int)AllNotes().Max((Note arg) => arg.Time);
return trackLength; return trackLength;
} }
@ -34,13 +34,17 @@ namespace MusicBoxConverter
public void Output(string destinationFilename) public void Output(string destinationFilename)
{ {
SvgWriter svg = new SvgWriter(destinationFilename); Vector2 area = new Vector2(TrackLength, 128).Multiply(scaleFactor);
svg.WriteRectangle(offset, new Vector2(TrackLength, 128).Multiply(scaleFactor)); Vector2 size = area.Add(offset.Multiply(2));
for(int i = 0; i < 255; i += 5)
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)); Vector2 start = offset.Add(new Vector2(0, i * scaleFactor.Y));
svg.WriteLine(start, start.Add(new Vector2(TrackLength, 0))); svg.WriteLine(start, start.Add(new Vector2(TrackLength * scaleFactor.X, 0)));
} }
svg.WriteRectangle(offset, area);
foreach(Note note in AllNotes()) foreach(Note note in AllNotes())
{ {

View file

@ -17,6 +17,7 @@ namespace MusicBoxConverter
); );
xml.WriteStartDocument(); 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.WriteStartElement("svg", "http://www.w3.org/2000/svg");
xml.WriteAttributeString("version", "1.1"); xml.WriteAttributeString("version", "1.1");
xml.WriteAttributeString("width", widthspec); xml.WriteAttributeString("width", widthspec);
@ -32,7 +33,7 @@ namespace MusicBoxConverter
public void WriteLine(Vector2 start, Vector2 end, string strokeStyle = "darkgreen", int strokeWidth = 3) 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) public void WritePath(string pathData, string strokeStyle = "green", int strokeWidth = 3)
@ -41,6 +42,7 @@ namespace MusicBoxConverter
xml.WriteAttributeString("d", pathData); xml.WriteAttributeString("d", pathData);
xml.WriteAttributeString("stroke", strokeStyle); xml.WriteAttributeString("stroke", strokeStyle);
xml.WriteAttributeString("stroke-width", strokeWidth.ToString()); xml.WriteAttributeString("stroke-width", strokeWidth.ToString());
xml.WriteAttributeString("fill", "transparent");
xml.WriteEndElement(); xml.WriteEndElement();
} }

View file

@ -39,14 +39,14 @@ namespace SBRL.Utilities
{ {
return new Vector2( return new Vector2(
X + b.X, X + b.X,
Y + b.X Y + b.Y
); );
} }
public Vector2 Subtract(Vector2 b) public Vector2 Subtract(Vector2 b)
{ {
return new Vector2( return new Vector2(
X - b.X, X - b.X,
Y - b.X Y - b.Y
); );
} }
public Vector2 Divide(int b) public Vector2 Divide(int b)