From a6cf844c4b40e3720d9e63b8e46b41d94a226a0c Mon Sep 17 00:00:00 2001
From: Starbeamrainbowlabs <sbrl@starbeamrainbowlabs.com>
Date: Sat, 23 Feb 2019 00:15:12 +0000
Subject: [PATCH] Draw a code at the side to indicate orientation

---
 MusicBoxConverter/MusicBoxScoreGenerator.cs | 27 +++++++++++++++++--
 MusicBoxConverter/SvgWriter.cs              | 29 +++++++++++----------
 2 files changed, 40 insertions(+), 16 deletions(-)

diff --git a/MusicBoxConverter/MusicBoxScoreGenerator.cs b/MusicBoxConverter/MusicBoxScoreGenerator.cs
index 77f73c6..3254d3d 100644
--- a/MusicBoxConverter/MusicBoxScoreGenerator.cs
+++ b/MusicBoxConverter/MusicBoxScoreGenerator.cs
@@ -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(
diff --git a/MusicBoxConverter/SvgWriter.cs b/MusicBoxConverter/SvgWriter.cs
index f01dc18..acff76b 100644
--- a/MusicBoxConverter/SvgWriter.cs
+++ b/MusicBoxConverter/SvgWriter.cs
@@ -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}");
-			xml.WriteAttributeString("fill", "none");
-			xml.WriteAttributeString("stroke", strokeStyle);
-			xml.WriteAttributeString("stroke-width", strokeWidth.ToString());
+			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();
 		}
 	}
