Ejemplo n.º 1
0
        public string GetPath(SVGContext context)
        {
            PointDbl      p                  = new PointDbl(context.fxy(this.center));
            PointDbl      dbl4               = new PointDbl(context.fxy(this.cd1));
            PointDbl      dbl3               = new PointDbl(context.fxy(this.cd2));
            PointDbl      dbl2               = new PointDbl(this.context_fxy2(this.v1, context));
            PointDbl      dbl                = new PointDbl(this.context_fxy2(this.v2, context));
            SVGEllipseArc arc                = CGM2SVGMath.FindSVGArc(p, dbl4, dbl3, dbl2, dbl);
            string        dAttribute         = arc.dAttribute;
            string        transformAttribute = arc.transformAttribute;

            if ((arc.StartP.X == arc.EndP.X) & (arc.StartP.Y == arc.EndP.Y))
            {
                SVGEllipseArc arc2 = arc;
                arc2.EndP.Y++;
                dAttribute = arc.dAttribute;
            }
            switch (this.closingType)
            {
            case 0:
                return(dAttribute + string.Format(" L{0},{1} L{2},{3} Z", new object[] { arc.CenterP.X, arc.CenterP.Y, arc.StartP.X, arc.StartP.Y }));

            case 1:
                return(dAttribute + string.Format(" L{0},{1} Z", arc.StartP.X, arc.StartP.Y));
            }
            return(dAttribute);
        }
Ejemplo n.º 2
0
        public void UpdateSVG(XmlTextWriter doc, SVGContext context)
        {
            try
            {
                PointDbl dbl6 = new PointDbl(context.fxy(this.center));
                PointDbl p    = dbl6;
                dbl6 = new PointDbl(context.fxy(this.cd1));
                PointDbl dbl2 = dbl6;
                dbl6 = new PointDbl(context.fxy(this.cd2));
                PointDbl dbl3 = dbl6;
                dbl6 = new PointDbl(this.context_fxy2(this.v1, context));
                PointDbl dbl4 = dbl6;
                dbl6 = new PointDbl(this.context_fxy2(this.v2, context));
                PointDbl      dbl5               = dbl6;
                SVGEllipseArc arc                = CGM2SVGMath.FindSVGArc(p, dbl2, dbl3, dbl4, dbl5);
                string        dAttribute         = arc.dAttribute;
                string        transformAttribute = arc.transformAttribute;
                switch (this.closingType)
                {
                case 0:
                    dAttribute = dAttribute + string.Format(" L{0},{1} L{2},{3} Z", new object[] { arc.CenterP.X, arc.CenterP.Y, arc.StartP.X, arc.StartP.Y });
                    break;

                case 1:
                    dAttribute = dAttribute + string.Format(" L{0},{1} Z", arc.StartP.X, arc.StartP.Y);
                    break;
                }
                doc.WriteStartElement("path");
                doc.WriteAttributeString("d", dAttribute);
                if (!String.IsNullOrEmpty(transformAttribute)) //if (StringType.StrCmp(transformAttribute, "", false) != 0)
                {
                    doc.WriteAttributeString("transform", transformAttribute);
                }
                if (this.closingType >= 0)
                {
                    context.PrintEdgeArc(doc);
                    doc.WriteAttributeString("fill", context.fill);
                }
                else
                {
                    context.PrintLine(doc);
                    doc.WriteAttributeString("fill", "none");
                }
            }
            finally
            {
                if (context.isClip & !String.IsNullOrEmpty(context.CurrClipID)) //if (context.isClip & (StringType.StrCmp(context.CurrClipID, "", false) != 0))
                {
                    doc.WriteAttributeString("clip-path", "url(#" + context.CurrClipID + ")");
                }
                doc.WriteFullEndElement();
            }
        }
Ejemplo n.º 3
0
        public static SVGEllipseArc FindSVGArc(PointDbl p, PointDbl p1, PointDbl p2, PointDbl Δstart, PointDbl Δend)
        {
            SVGEllipseArc arc2 = new SVGEllipseArc();

            arc2.RadiusX        = Math2.Distance(p.X, p.Y, p2.X, p2.Y);
            arc2.RadiusY        = Math2.Distance(p.X, p.Y, p1.X, p1.Y);
            double[,] a         = FindEllipseTransformToHorizontal(p, p1, p2);
            double[,] numArray2 = SpecialInvertMatrix(a);
            PointDbl dbl3         = new PointDbl(Δstart.X + p.X, Δstart.Y + p.Y);
            PointDbl dbl2         = TransformPoint(numArray2, dbl3);
            double   introduced10 = Math2.Sqr(dbl2.X / arc2.RadiusX);
            double   num          = Math.Sqrt(introduced10 + Math2.Sqr(dbl2.Y / arc2.RadiusY));

            dbl2.X /= num;
            dbl2.Y /= num;
            dbl3    = new PointDbl(Δend.X + p.X, Δend.Y + p.Y);
            PointDbl dbl          = TransformPoint(numArray2, dbl3);
            double   introduced11 = Math2.Sqr(dbl.X / arc2.RadiusX);
            double   num2         = Math.Sqrt(introduced11 + Math2.Sqr(dbl.Y / arc2.RadiusY));

            dbl.X /= num2;
            dbl.Y /= num2;
            if (Math2.Is90DegIntersection(p1.X - p.X, p1.Y - p.Y, p2.X - p.X, p2.Y - p.Y))
            {
                arc2.AngleX    = Math.Atan2(a[1, 0], a[0, 0]);
                arc2.StartP    = TransformPoint(a, dbl2);
                arc2.EndP      = TransformPoint(a, dbl);
                arc2.CenterP   = p;
                arc2.SweepFlag = Math2.CompareAngles(p1.X - p.X, p1.Y - p.Y, p2.X - p.X, p2.Y - p.Y) < 0.0;
                arc2.LargeArc  = Math2.CompareAngles(dbl2.X, dbl2.Y, dbl.X, dbl.Y) < 0.0;
                return(arc2);
            }
            arc2.Transform = a;
            arc2.AngleX    = 0.0;
            arc2.StartP    = dbl2;
            arc2.EndP      = dbl;
            dbl3           = new PointDbl(0.0, 0.0);
            arc2.CenterP   = dbl3;
            arc2.SweepFlag = false;
            arc2.LargeArc  = Math2.CompareAngles(dbl2.X, dbl2.Y, dbl.X, dbl.Y) < 0.0;
            return(arc2);
        }