Ejemplo n.º 1
0
        internal override Pnt2d?Write(StringBuilder sb, Pnt2d?lastPnt, SvgConverter conv)
        {
            if (!(lastPnt.HasValue && conv.AreEqual(lastPnt.Value, Start)))
            {
                sb.AppendFormat("M{0},{1} ", conv.ToSvgLength(Start.X), conv.ToSvgLength(-Start.Y));
            }

            sb.AppendFormat("L{0},{1} ", conv.ToSvgLength(End.X), conv.ToSvgLength(-End.Y));
            return(End);
        }
Ejemplo n.º 2
0
        //--------------------------------------------------------------------------------------------------

        internal override void Write(XmlWriter writer, SvgConverter conv)
        {
            writer.WriteStartElement("circle");

            writer.WriteAttributeString("cx", conv.ToSvgLength(Center.X));
            writer.WriteAttributeString("cy", conv.ToSvgLength(-Center.Y));
            writer.WriteAttributeString("r", conv.ToSvgLength(Radius));

            base.Write(writer, conv);
            writer.WriteEndElement();
        }
Ejemplo n.º 3
0
        //--------------------------------------------------------------------------------------------------

        internal override void Write(XmlWriter writer, SvgConverter conv)
        {
            writer.WriteStartElement("line");

            writer.WriteAttributeString("x1", conv.ToSvgLength(Start.X));
            writer.WriteAttributeString("y1", conv.ToSvgLength(-Start.Y));
            writer.WriteAttributeString("x2", conv.ToSvgLength(End.X));
            writer.WriteAttributeString("y2", conv.ToSvgLength(-End.Y));

            base.Write(writer, conv);
            writer.WriteEndElement();
        }
Ejemplo n.º 4
0
        //--------------------------------------------------------------------------------------------------

        internal override void Write(XmlWriter writer, SvgConverter conv)
        {
            writer.WriteStartElement("line");

            writer.WriteAttributeString("x", conv.ToSvgLength(Start.X));
            writer.WriteAttributeString("y", conv.ToSvgLength(-Start.Y));
            writer.WriteAttributeString("width", conv.ToSvgLength(Width));
            writer.WriteAttributeString("height", conv.ToSvgLength(-Height));

            base.Write(writer, conv);
            writer.WriteEndElement();
        }
Ejemplo n.º 5
0
        //--------------------------------------------------------------------------------------------------

        internal override void Write(XmlWriter writer, SvgConverter conv)
        {
            writer.WriteStartElement("text");

            writer.WriteAttributeString("x", conv.ToSvgLength(Position.X));
            writer.WriteAttributeString("y", conv.ToSvgLength(-Position.Y));

            base.Write(writer, conv);

            writer.WriteValue(Text);

            writer.WriteEndElement();
        }
Ejemplo n.º 6
0
 internal override void Write(StringBuilder sb, SvgConverter conv)
 {
     if (_Center.HasValue)
     {
         sb.AppendFormat("rotate({0},{1},{2}) ",
                         conv.ToSvgValue(_Angle),
                         conv.ToSvgLength(_Center.Value.X),
                         conv.ToSvgLength(-_Center.Value.Y));
     }
     else
     {
         sb.AppendFormat("rotate({0}) ", conv.ToSvgValue(_Angle));
     }
 }
Ejemplo n.º 7
0
        //--------------------------------------------------------------------------------------------------

        public MemoryStream WriteToStream()
        {
            var conv = new SvgConverter()
            {
                DotsPerInch = DotsPerInch,
                Scale       = 25.4 / DotsPerInch
            };

            var xmlWriterSettings = new XmlWriterSettings
            {
                Encoding    = Encoding.UTF8,
                Indent      = true,
                IndentChars = "  ",
            };

            var stream = new MemoryStream();
            var writer = XmlWriter.Create(stream, xmlWriterSettings);

            writer.WriteStartDocument();
            writer.WriteDocType("svg", "-//W3C//DTD SVG 1.1//EN", "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd", null);

            writer.WriteStartElement("svg", XmlnsSvg);

            writer.WriteAttributeString("width", $"{conv.ToSvgValue(Width)}mm"); // Use AngleToSvg to get unscaled values
            writer.WriteAttributeString("height", $"{conv.ToSvgValue(Height)}mm");
            writer.WriteAttributeString("viewBox", $"0, 0, {conv.ToSvgLength(Width)}, {conv.ToSvgLength(Height)}");
            writer.WriteAttributeString("version", "1.1");

            writer.WriteAttributeString("xmlns", "xlink", null, "http://www.w3.org/1999/xlink");
            writer.WriteAttributeString("xmlns", "xml", null, "http://www.w3.org/XML/1998/namespace");
            writer.WriteAttributeString("xmlns", "sodipodi", null, XmlnsSodipodi);
            writer.WriteAttributeString("xmlns", "inkscape", null, XmlnsInkscape);

            writer.WriteStartElement("namedview", XmlnsSodipodi);
            writer.WriteAttributeString("document-units", XmlnsInkscape, "mm");
            writer.WriteEndElement();

            base.Write(writer, conv);

            writer.WriteEndElement();
            writer.Close();
            return(stream);
        }
Ejemplo n.º 8
0
        internal override Pnt2d?Write(StringBuilder sb, Pnt2d?lastPnt, SvgConverter conv)
        {
            if (!(lastPnt.HasValue && conv.AreEqual(lastPnt.Value, Start)))
            {
                sb.AppendFormat("M{0},{1} ", conv.ToSvgLength(Start.X), conv.ToSvgLength(-Start.Y));
            }

            sb.AppendFormat("A{0},{1} {2} {3} {4} {5},{6} ",
                            conv.ToSvgLength(RadiusX), conv.ToSvgLength(RadiusY),
                            conv.ToSvgValue(Angle),
                            (uint)Size, (uint)Sweep,
                            conv.ToSvgLength(End.X), conv.ToSvgLength(-End.Y));
            return(End);
        }
Ejemplo n.º 9
0
 internal override void Write(StringBuilder sb, SvgConverter conv)
 {
     sb.AppendFormat("translate({0},{1}) ", conv.ToSvgLength(_Tx), conv.ToSvgLength(-_Ty));
 }
Ejemplo n.º 10
0
 internal override Pnt2d?Write(StringBuilder sb, Pnt2d?lastPnt, SvgConverter conv)
 {
     sb.AppendFormat("M{0},{1} ", conv.ToSvgLength(End.X), conv.ToSvgLength(-End.Y));
     return(End);
 }