Draw a code at the side to indicate orientation

This commit is contained in:
Starbeamrainbowlabs 2019-02-23 00:15:12 +00:00
parent bd774bc67c
commit a6cf844c4b
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
2 changed files with 40 additions and 16 deletions

View File

@ -73,8 +73,30 @@ namespace MusicBoxConverter
UnitSuffix = "mm"
};
// Draw a marker at the beginning of the score
svg.WriteRectangle(
new Vector2(Offset.X / 2, Offset.Y),
new Vector2(Offset.X / 2, area.Y),
"rgba(255, 128, 0, 0.5)", -1,
true
);
svg.WriteCircle(
new Vector2((Offset.X * 3) / 4, Offset.Y * 1.25f),
HoleSize,
"#ff0077"
);
svg.WriteCircle(
new Vector2((Offset.X * 3) / 4, Offset.Y + area.Y - Offset.Y * 0.25f),
HoleSize * 2,
"#0077ff"
);
// Draw the note lines
for(float i = 0; i < area.Y; i += ScaleFactor.Y) {
for (float i = 0; i < area.Y; i += ScaleFactor.Y) {
Vector2 start = Offset.Add(new Vector2(0, i));
svg.WriteLine(start, start.Add(new Vector2(area.X, 0)), "darkgreen", 0.75f);
}
@ -82,7 +104,8 @@ namespace MusicBoxConverter
// Draw a red box around everything
svg.WriteRectangle(Offset, area, "red", 0.75f);
foreach(Note note in AllNotes())
foreach (Note note in AllNotes())
{
if(Debug) {
Console.WriteLine(

View File

@ -89,16 +89,20 @@ namespace MusicBoxConverter
xml.WriteEndElement();
}*/
public void WriteRectangle(Vector2 position, Vector2 size, string strokeStyle = "red", float strokeWidth = 3)
public void WriteRectangle(Vector2 position, Vector2 size, string strokeStyle = "red", float strokeWidth = 3, bool fillInstead = false)
{
xml.WriteStartElement("rect");
xml.WriteAttributeString("x", $"{position.X}{UnitSuffix}");
xml.WriteAttributeString("y", $"{position.Y}{UnitSuffix}");
xml.WriteAttributeString("width", $"{size.X}{UnitSuffix}");
xml.WriteAttributeString("height", $"{size.Y}{UnitSuffix}");
if (!fillInstead) {
xml.WriteAttributeString("fill", "none");
xml.WriteAttributeString("stroke", strokeStyle);
xml.WriteAttributeString("stroke-width", strokeWidth.ToString());
}
else
xml.WriteAttributeString("fill", strokeStyle);
xml.WriteEndElement();
}
public void WriteCircle(Vector2 centre, float radius, string fillStyle = "blue")
@ -110,17 +114,14 @@ namespace MusicBoxConverter
xml.WriteAttributeString("fill", fillStyle);
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)
public void WriteText(Vector2 position, string text, float size = 12)
{
xml.WriteStartElement("polygon");
xml.WriteAttributeString("fill", fillStyle);
string pointsSpec = string.Join(" ", points.Select((Vector2 point) => $"{point.X},{point.Y}"));
xml.WriteAttributeString("points", pointsSpec);
xml.WriteStartElement("text");
xml.WriteAttributeString("x", $"{position.X}{UnitSuffix}");
xml.WriteAttributeString("y", $"{position.Y}{UnitSuffix}");
xml.WriteAttributeString("style", $"font-size: {size}{UnitSuffix}");
xml.WriteValue(text);
xml.WriteEndElement();
}
}