public override void DrawLine(Point startPoint, Point endPoint, Pen pen, Model.MusicalSymbol owner) { var element = new XElement("line", new XAttribute("x1", startPoint.X.ToStringInvariant()), new XAttribute("y1", startPoint.Y.ToStringInvariant()), new XAttribute("x2", endPoint.X.ToStringInvariant()), new XAttribute("y2", endPoint.Y.ToStringInvariant()), new XAttribute("style", pen.ToCss())); Canvas.Add(element); }
public override void DrawLine(Point startPoint, Point endPoint, Pen pen, Model.MusicalSymbol owner) { if (!EnsureProperPage(owner)) { return; } if (Settings.RenderingMode != ScoreRenderingModes.Panorama && !TypedSettings.IgnorePageMargins) { startPoint = startPoint.Translate(CurrentScore.DefaultPageSettings); endPoint = endPoint.Translate(CurrentScore.DefaultPageSettings); } var element = new XElement("line", new XAttribute("x1", startPoint.X.ToStringInvariant()), new XAttribute("y1", startPoint.Y.ToStringInvariant()), new XAttribute("x2", endPoint.X.ToStringInvariant()), new XAttribute("y2", endPoint.Y.ToStringInvariant()), new XAttribute("style", pen.ToCss()), new XAttribute("id", BuildElementId(owner))); var playbackAttributes = BuildPlaybackAttributes(owner); foreach (var playbackAttr in playbackAttributes) { element.Add(new XAttribute(playbackAttr.Key, playbackAttr.Value)); } if (startPoint.Y < ClippedAreaY) { ClippedAreaY = startPoint.Y; } if (endPoint.Y < ClippedAreaY) { ClippedAreaY = endPoint.Y; } if (startPoint.X > ActualWidth) { ActualWidth = startPoint.X; } if (endPoint.X > ActualWidth) { ActualWidth = endPoint.X; } if (startPoint.Y > ActualHeight) { ActualHeight = startPoint.Y; } if (endPoint.Y > ActualHeight) { ActualHeight = endPoint.Y; } Canvas.Add(element); }
public override void DrawCharacterInBounds(char character, MusicFontStyles fontStyle, Point location, Size size, Color color, Model.MusicalSymbol owner) { if (!EnsureProperPage(owner)) { return; } if (Settings.RenderingMode != ScoreRenderingModes.Panorama && !TypedSettings.IgnorePageMargins) { location = location.Translate(CurrentScore.DefaultPageSettings); } var element = GetTextElement(character.ToString(), fontStyle, new Point(0, 0), color, owner); var svg = new XElement("svg", new XAttribute("x", location.X.ToStringInvariant()), new XAttribute("y", location.Y.ToStringInvariant()), new XAttribute("width", size.Width.ToStringInvariant()), new XAttribute("height", size.Height.ToStringInvariant()), new XAttribute("viewBox", $"0 0 {size.Width.ToStringInvariant()} {size.Height.ToStringInvariant()}")); svg.Add(element); //element.SetAttributeValue(XName.Get("viewBox"), $"0 0 {size.Width.ToStringInvariant()} {size.Height.ToStringInvariant()}"); if (location.Y < ClippedAreaY) { ClippedAreaY = location.Y; } if (location.X > ActualWidth) { ActualWidth = location.X; } if (location.Y > ActualHeight) { ActualHeight = location.Y; } Canvas.Add(svg); }
public override void DrawArc(Rectangle rect, double startAngle, double sweepAngle, Pen pen, Model.MusicalSymbol owner) { var element = new XElement("path", new XAttribute("d", string.Format("M{0},{1} A{2},{3} {4} {5},{6} {7},{8}", rect.X.ToStringInvariant(), rect.Y.ToStringInvariant(), rect.Height.ToStringInvariant(), rect.Width.ToStringInvariant(), (sweepAngle / 2).ToStringInvariant(), 0, 1, (rect.X + rect.Width).ToStringInvariant(), rect.Y.ToStringInvariant())), new XAttribute("style", pen.ToCss())); Canvas.Add(element); }
public override void DrawBezier(Point p1, Point p2, Point p3, Point p4, Pen pen, Model.MusicalSymbol owner) { var element = new XElement("path", new XAttribute("d", string.Format("M{0},{1} C{2},{3} {4},{5} {6},{7}", p1.X.ToStringInvariant(), p1.Y.ToStringInvariant(), p2.X.ToStringInvariant(), p2.Y.ToStringInvariant(), p3.X.ToStringInvariant(), p3.Y.ToStringInvariant(), p4.X.ToStringInvariant(), p4.Y.ToStringInvariant())), new XAttribute("style", pen.ToCss())); Canvas.Add(element); }
public override void DrawArc(Rectangle rect, double startAngle, double sweepAngle, Pen pen, Model.MusicalSymbol owner) { if (!EnsureProperPage(owner)) { return; } if (Settings.RenderingMode != ScoreRenderingModes.Panorama && !TypedSettings.IgnorePageMargins) { rect = rect.Translate(CurrentScore.DefaultPageSettings); } var element = new XElement("path", new XAttribute("d", string.Format("M{0} {1} A{2} {3} {4} {5} {6} {7} {8}", rect.X.ToStringInvariant(), rect.Y.ToStringInvariant(), (rect.X + rect.Width).ToStringInvariant(), rect.Y.ToStringInvariant(), startAngle.ToStringInvariant(), sweepAngle > 180 ? 1 : 0, sweepAngle < 180 ? 0 : 1, (rect.X + rect.Width).ToStringInvariant(), (rect.Y).ToStringInvariant())), new XAttribute("style", pen.ToCss()), new XAttribute("id", BuildElementId(owner))); var playbackAttributes = BuildPlaybackAttributes(owner); foreach (var playbackAttr in playbackAttributes) { element.Add(new XAttribute(playbackAttr.Key, playbackAttr.Value)); } if (rect.Y < ClippedAreaY) { ClippedAreaY = rect.Y; } if (rect.X + rect.Width > ActualWidth) { ActualWidth = rect.X + rect.Width; } if (rect.Y + rect.Height > ActualHeight) { ActualHeight = rect.Y + rect.Height; } Canvas.Add(element); }
public override void DrawBezier(Point p1, Point p2, Point p3, Point p4, Pen pen, Model.MusicalSymbol owner) { if (!EnsureProperPage(owner)) { return; } if (Settings.RenderingMode != ScoreRenderingModes.Panorama && !TypedSettings.IgnorePageMargins) { p1 = p1.Translate(CurrentScore.DefaultPageSettings); p2 = p2.Translate(CurrentScore.DefaultPageSettings); p3 = p3.Translate(CurrentScore.DefaultPageSettings); p4 = p4.Translate(CurrentScore.DefaultPageSettings); } var element = new XElement("path", new XAttribute("d", string.Format("M{0} {1} C{2} {3}, {4} {5}, {6} {7}", p1.X.ToStringInvariant(), p1.Y.ToStringInvariant(), p2.X.ToStringInvariant(), p2.Y.ToStringInvariant(), p3.X.ToStringInvariant(), p3.Y.ToStringInvariant(), p4.X.ToStringInvariant(), p4.Y.ToStringInvariant())), new XAttribute("style", pen.ToCss()), new XAttribute("id", BuildElementId(owner))); var playbackAttributes = BuildPlaybackAttributes(owner); foreach (var playbackAttr in playbackAttributes) { element.Add(new XAttribute(playbackAttr.Key, playbackAttr.Value)); } if (p1.Y < ClippedAreaY) { ClippedAreaY = p1.Y; } if (p2.Y < ClippedAreaY) { ClippedAreaY = p2.Y; } if (p3.Y < ClippedAreaY) { ClippedAreaY = p3.Y; } if (p4.Y < ClippedAreaY) { ClippedAreaY = p4.Y; } if (p4.X > ActualWidth) { ActualWidth = p4.X; } if (p1.Y > ActualHeight) { ActualHeight = p1.Y; } Canvas.Add(element); }
public override void DrawString(string text, MusicFontStyles fontStyle, Point location, Color color, Model.MusicalSymbol owner) { if (!TypedSettings.Fonts.ContainsKey(fontStyle)) { return; //Nie ma takiego fontu zdefiniowanego. Nie rysuj. } if (!EnsureProperPage(owner)) { return; } if (Settings.RenderingMode != ScoreRenderingModes.Panorama && !TypedSettings.IgnorePageMargins) { location = location.Translate(CurrentScore.DefaultPageSettings); } location = TranslateTextLocation(location, fontStyle); var element = GetTextElement(text, fontStyle, location, color, owner); if (location.Y - 15 < ClippedAreaY) { ClippedAreaY = location.Y - 15; } if (location.X > ActualWidth) { ActualWidth = location.X; } if (location.Y > ActualHeight) { ActualHeight = location.Y; } Canvas.Add(element); }
private XElement GetTextElement(string text, MusicFontStyles fontStyle, Point location, Color color, Model.MusicalSymbol owner) { var element = new XElement("text", new XAttribute("x", location.X.ToStringInvariant()), new XAttribute("y", location.Y.ToStringInvariant()), new XAttribute("style", string.Format("font-color:{0}; font-size:{1}pt; font-family: {2};", color.ToCss(), TypedSettings.Fonts[fontStyle].Size.ToStringInvariant(), TypedSettings.Fonts[fontStyle].Name)), new XAttribute("id", BuildElementId(owner))); element.Value = TypedSettings.Fonts[fontStyle].Name == "Polihymnia" ? string.Format("{0}{1}", text, EmptyCharacterWithWidth) : text; var playbackAttributes = BuildPlaybackAttributes(owner); foreach (var playbackAttr in playbackAttributes) { element.Add(new XAttribute(playbackAttr.Key, playbackAttr.Value)); } return(element); }
public override void DrawString(string text, MusicFontStyles fontStyle, Point location, Color color, Model.MusicalSymbol owner) { if (!TypedSettings.Fonts.ContainsKey(fontStyle)) { return; //Nie ma takiego fontu zdefiniowanego. Nie rysuj. } location = TranslateTextLocation(location, fontStyle); var element = new XElement("text", new XAttribute("x", location.X.ToStringInvariant()), new XAttribute("y", location.Y.ToStringInvariant()), new XAttribute("style", string.Format("font-color:{0}; font-size:{1}pt; font-family: {2};", color.ToCss(), TypedSettings.Fonts[fontStyle].Size.ToStringInvariant(), TypedSettings.Fonts[fontStyle].Name))); element.Value = TypedSettings.Fonts[fontStyle].Name == "Polihymnia" ? string.Format("{0}{1}", text, EmptyCharacterWithWidth) : text; Canvas.Add(element); }
public override void DrawBezier(Primitives.Point p1, Primitives.Point p2, Primitives.Point p3, Primitives.Point p4, Primitives.Pen pen, Model.MusicalSymbol owner) { }
/// <summary> /// Ads arc to HTML canvas /// </summary> /// <param name="rect"></param> /// <param name="startAngle"></param> /// <param name="sweepAngle"></param> /// <param name="pen"></param> /// <param name="owner"></param> public override void DrawArc(Primitives.Rectangle rect, double startAngle, double sweepAngle, Primitives.Pen pen, Model.MusicalSymbol owner) { Canvas.AppendLine("context.beginPath();"); Canvas.AppendLine(string.Format("context.arc({0},{1},{2},{3},{4});", rect.X.ToStringInvariant(), rect.Y.ToStringInvariant(), rect.Height.ToStringInvariant(), UsefulMath.GradToRadians(startAngle).ToStringInvariant(), UsefulMath.GradToRadians(sweepAngle).ToStringInvariant())); Canvas.AppendLine("context.stroke();"); if (rect.X + rect.Width > ActualWidth) { ActualWidth = rect.X + rect.Width; } if (rect.Y + rect.Height > ActualHeight) { ActualHeight = rect.Y + rect.Height; } }
/// <summary> /// Adds a bezier curve to HTML canvas /// </summary> /// <param name="p1"></param> /// <param name="p2"></param> /// <param name="p3"></param> /// <param name="p4"></param> /// <param name="pen"></param> /// <param name="owner"></param> public override void DrawBezier(Primitives.Point p1, Primitives.Point p2, Primitives.Point p3, Primitives.Point p4, Primitives.Pen pen, Model.MusicalSymbol owner) { Canvas.AppendLine("context.beginPath();"); Canvas.AppendLine(string.Format("context.moveTo({0}, {1});", p1.X.ToStringInvariant(), p1.Y.ToStringInvariant())); Canvas.AppendLine(string.Format("context.bezierCurveTo({0},{1},{2},{3},{4},{5});", p2.X.ToStringInvariant(), p2.Y.ToStringInvariant(), p3.X.ToStringInvariant(), p3.Y.ToStringInvariant(), p4.X.ToStringInvariant(), p4.Y.ToStringInvariant())); Canvas.AppendLine("context.stroke();"); if (p4.X > ActualWidth) { ActualWidth = p4.X; } if (p1.Y > ActualHeight) { ActualHeight = p1.Y; } }
public override void DrawCharacterInBounds(char character, MusicFontStyles fontStyle, Point location, Size size, Color color, Model.MusicalSymbol owner) { }
/// <summary> /// Adds a string to HTML canvas /// </summary> /// <param name="text"></param> /// <param name="fontStyle"></param> /// <param name="location"></param> /// <param name="color"></param> /// <param name="owner"></param> public override void DrawString(string text, MusicFontStyles fontStyle, Primitives.Point location, Primitives.Color color, Model.MusicalSymbol owner) { if (!TypedSettings.Fonts.ContainsKey(fontStyle)) { return; //Nie ma takiego fontu zdefiniowanego. Nie rysuj. } location = TranslateTextLocation(location, fontStyle); Canvas.AppendLine(string.Format("context.font = '{0}pt {1}';", TypedSettings.Fonts[fontStyle].Size.ToStringInvariant(), TypedSettings.Fonts[fontStyle].Name)); Canvas.AppendLine(string.Format("context.fillText('{0}', {1}, {2});", text, location.X.ToStringInvariant(), location.Y.ToStringInvariant())); if (location.X > ActualWidth) { ActualWidth = location.X; } if (location.Y > ActualHeight) { ActualHeight = location.Y; } }
/// <summary> /// Adds a line to HTML canvas /// </summary> /// <param name="startPoint"></param> /// <param name="endPoint"></param> /// <param name="pen"></param> /// <param name="owner"></param> public override void DrawLine(Primitives.Point startPoint, Primitives.Point endPoint, Primitives.Pen pen, Model.MusicalSymbol owner) { Canvas.AppendLine("context.beginPath();"); Canvas.AppendLine(string.Format("context.moveTo({0}, {1});", startPoint.X.ToStringInvariant(), startPoint.Y.ToStringInvariant())); Canvas.AppendLine(string.Format("context.lineTo({0}, {1});", endPoint.X.ToStringInvariant(), endPoint.Y.ToStringInvariant())); Canvas.AppendLine("context.stroke();"); if (startPoint.X > ActualWidth) { ActualWidth = startPoint.X; } if (endPoint.X > ActualWidth) { ActualWidth = endPoint.X; } if (startPoint.Y > ActualHeight) { ActualHeight = startPoint.Y; } if (endPoint.Y > ActualHeight) { ActualHeight = endPoint.Y; } }
public override void DrawString(string text, MusicFontStyles fontStyle, Primitives.Point location, Primitives.Color color, Model.MusicalSymbol owner) { using (var paint = GetPaint(color, fontStyle)) { Canvas.DrawText(text, (float)location.X, (float)location.Y, paint); } }
public override void DrawLine(Primitives.Point startPoint, Primitives.Point endPoint, Primitives.Pen pen, Model.MusicalSymbol owner) { using (var paint = GetPaint(pen)) { Canvas.DrawLine((float)startPoint.X, (float)startPoint.Y, (float)endPoint.X, (float)endPoint.Y, paint); } }
public override void DrawStringInBounds(string text, MusicFontStyles fontStyle, Point location, Size size, Color color, Model.MusicalSymbol owner) { }
public override void DrawArc(Primitives.Rectangle rect, double startAngle, double sweepAngle, Primitives.Pen pen, Model.MusicalSymbol owner) { }