Draw a code at the side to indicate orientation
This commit is contained in:
parent
bd774bc67c
commit
a6cf844c4b
2 changed files with 40 additions and 16 deletions
|
@ -73,8 +73,30 @@ namespace MusicBoxConverter
|
||||||
UnitSuffix = "mm"
|
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
|
// 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));
|
Vector2 start = Offset.Add(new Vector2(0, i));
|
||||||
svg.WriteLine(start, start.Add(new Vector2(area.X, 0)), "darkgreen", 0.75f);
|
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
|
// Draw a red box around everything
|
||||||
svg.WriteRectangle(Offset, area, "red", 0.75f);
|
svg.WriteRectangle(Offset, area, "red", 0.75f);
|
||||||
|
|
||||||
foreach(Note note in AllNotes())
|
|
||||||
|
foreach (Note note in AllNotes())
|
||||||
{
|
{
|
||||||
if(Debug) {
|
if(Debug) {
|
||||||
Console.WriteLine(
|
Console.WriteLine(
|
||||||
|
|
|
@ -89,16 +89,20 @@ namespace MusicBoxConverter
|
||||||
xml.WriteEndElement();
|
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.WriteStartElement("rect");
|
||||||
xml.WriteAttributeString("x", $"{position.X}{UnitSuffix}");
|
xml.WriteAttributeString("x", $"{position.X}{UnitSuffix}");
|
||||||
xml.WriteAttributeString("y", $"{position.Y}{UnitSuffix}");
|
xml.WriteAttributeString("y", $"{position.Y}{UnitSuffix}");
|
||||||
xml.WriteAttributeString("width", $"{size.X}{UnitSuffix}");
|
xml.WriteAttributeString("width", $"{size.X}{UnitSuffix}");
|
||||||
xml.WriteAttributeString("height", $"{size.Y}{UnitSuffix}");
|
xml.WriteAttributeString("height", $"{size.Y}{UnitSuffix}");
|
||||||
xml.WriteAttributeString("fill", "none");
|
if (!fillInstead) {
|
||||||
xml.WriteAttributeString("stroke", strokeStyle);
|
xml.WriteAttributeString("fill", "none");
|
||||||
xml.WriteAttributeString("stroke-width", strokeWidth.ToString());
|
xml.WriteAttributeString("stroke", strokeStyle);
|
||||||
|
xml.WriteAttributeString("stroke-width", strokeWidth.ToString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
xml.WriteAttributeString("fill", strokeStyle);
|
||||||
xml.WriteEndElement();
|
xml.WriteEndElement();
|
||||||
}
|
}
|
||||||
public void WriteCircle(Vector2 centre, float radius, string fillStyle = "blue")
|
public void WriteCircle(Vector2 centre, float radius, string fillStyle = "blue")
|
||||||
|
@ -110,17 +114,14 @@ namespace MusicBoxConverter
|
||||||
xml.WriteAttributeString("fill", fillStyle);
|
xml.WriteAttributeString("fill", fillStyle);
|
||||||
xml.WriteEndElement();
|
xml.WriteEndElement();
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// Adds a solid n-sided polygon to the image.
|
public void WriteText(Vector2 position, string text, float size = 12)
|
||||||
/// </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)
|
|
||||||
{
|
{
|
||||||
xml.WriteStartElement("polygon");
|
xml.WriteStartElement("text");
|
||||||
xml.WriteAttributeString("fill", fillStyle);
|
xml.WriteAttributeString("x", $"{position.X}{UnitSuffix}");
|
||||||
string pointsSpec = string.Join(" ", points.Select((Vector2 point) => $"{point.X},{point.Y}"));
|
xml.WriteAttributeString("y", $"{position.Y}{UnitSuffix}");
|
||||||
xml.WriteAttributeString("points", pointsSpec);
|
xml.WriteAttributeString("style", $"font-size: {size}{UnitSuffix}");
|
||||||
|
xml.WriteValue(text);
|
||||||
xml.WriteEndElement();
|
xml.WriteEndElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue