Add box around notes
This commit is contained in:
parent
8cdb9591ab
commit
5aa7c6a0c3
3 changed files with 25 additions and 7 deletions
|
@ -27,7 +27,7 @@ namespace MusicBoxConverter
|
||||||
public void Output(string destinationFilename)
|
public void Output(string destinationFilename)
|
||||||
{
|
{
|
||||||
SvgWriter svg = new SvgWriter(destinationFilename);
|
SvgWriter svg = new SvgWriter(destinationFilename);
|
||||||
|
svg.WriteRectangle(offset, new Vector2(TrackLength(), 128).Multiply(scaleFactor));
|
||||||
|
|
||||||
foreach(Note note in AllNotes())
|
foreach(Note note in AllNotes())
|
||||||
{
|
{
|
||||||
|
@ -44,6 +44,11 @@ namespace MusicBoxConverter
|
||||||
svg.Complete();
|
svg.Complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int TrackLength()
|
||||||
|
{
|
||||||
|
return (int)AllNotes().Max((Note arg) => arg.Time);
|
||||||
|
}
|
||||||
|
|
||||||
public IEnumerable<Note> AllNotes()
|
public IEnumerable<Note> AllNotes()
|
||||||
{
|
{
|
||||||
foreach(TrackChunk chunk in midiFile.Chunks.OfType<TrackChunk>())
|
foreach(TrackChunk chunk in midiFile.Chunks.OfType<TrackChunk>())
|
||||||
|
@ -55,11 +60,5 @@ namespace MusicBoxConverter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int TrackLength()
|
|
||||||
{
|
|
||||||
//notesManager.Notes.OfType<TrackChunk>().Select((TrackChunk arg) => arg.Events.O;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,18 @@ namespace MusicBoxConverter
|
||||||
xml.WriteEndElement();
|
xml.WriteEndElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void WriteRectangle(Vector2 position, Vector2 size, string strokeStyle = "red", int strokeWidth = 3)
|
||||||
|
{
|
||||||
|
xml.WriteStartElement("rect");
|
||||||
|
xml.WriteAttributeString("x", position.X.ToString());
|
||||||
|
xml.WriteAttributeString("y", position.Y.ToString());
|
||||||
|
xml.WriteAttributeString("width", size.X.ToString());
|
||||||
|
xml.WriteAttributeString("height", size.Y.ToString());
|
||||||
|
xml.WriteAttributeString("fill", "transparent");
|
||||||
|
xml.WriteAttributeString("stroke", strokeStyle);
|
||||||
|
xml.WriteAttributeString("stroke-width", strokeWidth.ToString());
|
||||||
|
xml.WriteEndElement();
|
||||||
|
}
|
||||||
public void WriteCircle(Vector2 centre, int radius, string fillStyle = "blue")
|
public void WriteCircle(Vector2 centre, int radius, string fillStyle = "blue")
|
||||||
{
|
{
|
||||||
xml.WriteStartElement("circle");
|
xml.WriteStartElement("circle");
|
||||||
|
|
|
@ -63,6 +63,13 @@ namespace SBRL.Utilities
|
||||||
Y * b
|
Y * b
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
public Vector2 Multiply(Vector2 b)
|
||||||
|
{
|
||||||
|
return new Vector2(
|
||||||
|
X * b.X,
|
||||||
|
Y * b.Y
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue