public virtual void WriteSVG(SvgWriter w, int systemNumber, int staffNumber, List <CarryMsgs> carryMsgsPerChannel, bool graphicsOnly) { w.WriteAttributeString("score", "staffName", null, this.Staffname); CSSObjectClass stafflinesClass = CSSObjectClass.stafflines; CSSObjectClass stafflineClass = CSSObjectClass.staffline; w.SvgStartGroup(stafflinesClass.ToString()); double stafflineY = this.Metrics.StafflinesTop; for (int staffLineIndex = 0; staffLineIndex < NumberOfStafflines; staffLineIndex++) { w.SvgLine(stafflineClass, this.Metrics.StafflinesLeft, stafflineY, this.Metrics.StafflinesRight, stafflineY); if (staffLineIndex < (NumberOfStafflines - 1)) { stafflineY += Gap; } } w.SvgEndGroup(); for (var voiceIndex = 0; voiceIndex < Voices.Count; voiceIndex++) { Voices[voiceIndex].WriteSVG(w, voiceIndex, carryMsgsPerChannel, graphicsOnly); } foreach (var extender in Extenders) { extender.Metrics.WriteSVG(w); } }
public override void WriteSVG(SvgWriter w) { w.SvgStartGroup(CSSObjectClass.ToString()); w.SvgRect(CSSObjectClass.barNumberFrame, _left, _top, _right - _left, _bottom - _top); w.SvgText(CSSObjectClass.barNumberNumber, _number, _barNumberNumberMetrics.OriginX, _barNumberNumberMetrics.OriginY); w.SvgEndGroup(); }
/// <summary> /// Writes an SVG "use" element, overriding its x- and y-coordinates. /// </summary> /// <param name="cssClass">Currently either CSSClass.clef or CSSClass.flag</param> /// <param name="cssClass">Currently either CSSClass.clef or CSSClass.flag</param> /// <param name="y">This element's y-coordinate.</param> /// <param name="idOfObjectToUse">(Do not include the leading '#'. It will be inserted automatically.)</param> public void SvgUseXY(CSSObjectClass cssClass, string idOfObjectToUse, double x, double y) { _w.WriteStartElement("use"); _w.WriteAttributeString("class", cssClass.ToString()); _w.WriteAttributeString("href", "#" + idOfObjectToUse); _w.WriteAttributeString("x", M.DoubleToShortString(x)); _w.WriteAttributeString("y", M.DoubleToShortString(y)); _w.WriteEndElement(); }
public void SvgText(CSSObjectClass cssClass, string text, double x, double y) { _w.WriteStartElement("text"); _w.WriteAttributeString("class", cssClass.ToString()); _w.WriteAttributeString("x", M.DoubleToShortString(x)); _w.WriteAttributeString("y", M.DoubleToShortString(y)); _w.WriteString(text); _w.WriteEndElement(); // text }
public override void WriteSVG(SvgWriter w) { w.SvgStartGroup(CSSObjectClass.ToString()); foreach (Metrics metrics in MetricsList) { metrics.WriteSVG(w); } w.SvgEndGroup(); }
/// <summary> /// Writes an SVG "circle" element having a class that has a CSS definiton elsewhere. /// </summary> /// <param name="type">Not written if null or empty</param> /// <param name="cx"></param> /// <param name="cy"></param> /// <param name="r"></param> public void SvgCircle(CSSObjectClass cssClass, double cx, double cy, double r) { WriteStartElement("circle"); _w.WriteAttributeString("class", cssClass.ToString()); WriteAttributeString("cx", M.DoubleToShortString(cx)); WriteAttributeString("cy", M.DoubleToShortString(cy)); WriteAttributeString("r", M.DoubleToShortString(r)); WriteEndElement(); // circle }
/// <summary> /// Writes an SVG "rect" element having a class that has a CSS definiton elsewhere. /// </summary> /// <param name="type">must be a valid string</param> /// <param name="left"></param> /// <param name="top"></param> /// <param name="width"></param> /// <param name="height"></param> public void SvgRect(CSSObjectClass cssClass, double left, double top, double width, double height) { _w.WriteStartElement("rect"); _w.WriteAttributeString("class", cssClass.ToString()); _w.WriteAttributeString("x", M.DoubleToShortString(left)); _w.WriteAttributeString("y", M.DoubleToShortString(top)); _w.WriteAttributeString("width", M.DoubleToShortString(width)); _w.WriteAttributeString("height", M.DoubleToShortString(height)); _w.WriteEndElement(); // rect }
/// <summary> /// Writes an SVG "ellipse" element having a class that has a CSS definiton elsewhere. /// </summary> /// <param name="type">Not written if null or empty</param> /// <param name="cx"></param> /// <param name="cy"></param> /// <param name="rx"></param> /// <param name="ry"></param> public void SvgEllipse(CSSObjectClass cssClass, double cx, double cy, double rx, double ry) { WriteStartElement("ellipse"); WriteAttributeString("class", cssClass.ToString()); WriteAttributeString("cx", M.DoubleToShortString(cx)); WriteAttributeString("cy", M.DoubleToShortString(cy)); WriteAttributeString("rx", M.DoubleToShortString(rx)); WriteAttributeString("ry", M.DoubleToShortString(ry)); WriteEndElement(); // ellipse }
public override void WriteSVG(SvgWriter w) { CSSObjectClass ledgerlineClass = CSSObjectClass.ledgerline; w.WriteStartElement("g"); w.WriteAttributeString("class", CSSObjectClass.ToString()); foreach (double y in Ys) { w.SvgLine(ledgerlineClass, _left + _strokeWidth, y, _right - _strokeWidth, y); } w.WriteEndElement(); }
/// <summary> /// Writes an SVG "line" element /// </summary> /// <param name="styleName">the line's CSS style name</param> /// <param name="x1"></param> /// <param name="y1"></param> /// <param name="x2"></param> /// <param name="y2"></param> /// <param name="strokeDashArray"></param> public void SvgLine(CSSObjectClass cssClass, double x1, double y1, double x2, double y2, string strokeDashArray = null) { _w.WriteStartElement("line"); _w.WriteAttributeString("class", cssClass.ToString()); _w.WriteAttributeString("x1", M.DoubleToShortString(x1)); _w.WriteAttributeString("y1", M.DoubleToShortString(y1)); _w.WriteAttributeString("x2", M.DoubleToShortString(x2)); _w.WriteAttributeString("y2", M.DoubleToShortString(y2)); if (strokeDashArray != null) { _w.WriteAttributeString("stroke-dasharray", strokeDashArray); } _w.WriteEndElement(); //line }
public override void WriteSVG(SvgWriter w) { w.SvgStartGroup(CSSObjectClass.ToString()); w.SvgRect(CSSObjectClass.regionInfoFrame, _left, _top, _right - _left, _bottom - _top); for (int i = 0; i < _textMetrics.Count; ++i) { TextMetrics textMetrics = _textMetrics[i]; string textString = _textStrings[i]; w.SvgText(CSSObjectClass.regionInfoString, textString, textMetrics.OriginX, textMetrics.OriginY); } w.SvgEndGroup(); }
/// <summary> /// Writes an SVG "path" element having no global css style (such as a slurTemplate or tieTemplate) /// </summary> public void SvgPath(CSSObjectClass cssClass, string dString, string stroke, string strokeWidth, string fill) { _w.WriteStartElement("path"); _w.WriteAttributeString("class", cssClass.ToString()); _w.WriteAttributeString("d", dString); if (string.IsNullOrEmpty(stroke) == false) { _w.WriteAttributeString("stroke", stroke); } if (string.IsNullOrEmpty(strokeWidth) == false) { _w.WriteAttributeString("stroke-width", strokeWidth); } if (string.IsNullOrEmpty(fill) == false) { _w.WriteAttributeString("fill", fill); } _w.WriteEndElement(); //path }
// Currently used only by HeadMetrics (to write coloured noteheads). public void SvgText(CSSObjectClass cssObjectClass, CSSColorClass cssColorClass, string text, double x, double y) { string classesString = cssObjectClass.ToString(); if (cssColorClass != CSSColorClass.none && cssColorClass != CSSColorClass.black) { classesString = string.Concat(classesString, " ", cssColorClass.ToString()); } ; _w.WriteStartElement("text"); if (!String.IsNullOrEmpty(classesString)) { _w.WriteAttributeString("class", classesString); } _w.WriteAttributeString("x", M.DoubleToShortString(x)); _w.WriteAttributeString("y", M.DoubleToShortString(y)); _w.WriteString(text); _w.WriteEndElement(); // text }
/// <summary> /// A square bracket /// </summary> public void SvgCautionaryBracket(CSSObjectClass cssClass, bool isLeftBracket, double top, double right, double bottom, double left) { if (!isLeftBracket) { double temp = left; left = right; right = temp; } string leftStr = left.ToString("0.###", M.En_USNumberFormat); string topStr = top.ToString("0.###", M.En_USNumberFormat); string rightStr = right.ToString("0.###", M.En_USNumberFormat); string bottomStr = bottom.ToString("0.###", M.En_USNumberFormat); _w.WriteStartElement("path"); _w.WriteAttributeString("class", cssClass.ToString()); StringBuilder d = new StringBuilder(); d.Append("M " + rightStr + "," + topStr + " "); d.Append("L " + leftStr + "," + topStr + " " + leftStr + "," + bottomStr + " " + rightStr + "," + bottomStr); _w.WriteAttributeString("d", d.ToString()); _w.WriteEndElement(); // path }