Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/SharpVectorModel/Paths/SvgPathSegCurvetoQuadraticSmoothRel.cs @ 12762

Last change on this file since 12762 was 12762, checked in by aballeit, 9 years ago

#2283 GUI updates, Tree-chart, MCTS Version 2 (prune leaves)

File size: 3.5 KB
Line 
1using System;
2using System.Text;
3
4namespace SharpVectors.Dom.Svg
5{
6    /// <summary>
7    /// The SvgPathSegCurvetoQuadraticSmoothRel interface corresponds to an "relative smooth quadratic curveto" (t) path data command.
8    /// </summary>
9    public sealed class SvgPathSegCurvetoQuadraticSmoothRel : SvgPathSegCurvetoQuadratic, ISvgPathSegCurvetoQuadraticSmoothRel
10    {
11        #region Constructors
12
13        public SvgPathSegCurvetoQuadraticSmoothRel(double x, double y)
14            : base(SvgPathSegType.CurveToQuadraticSmoothRel)
15        {
16            this.x = x;
17            this.y = y;
18        }
19
20        #endregion
21
22        #region SvgpathSegCurvetoQuadraticSmoothRel Members
23
24        private double x;
25        /// <summary>
26        /// The absolute X coordinate for the end point of this path segment.
27        /// </summary>
28        public double X
29        {
30            get { return x; }
31            set { x = value; }
32        }
33
34        private double y;
35        /// <summary>
36        /// The absolute Y coordinate for the end point of this path segment.
37        /// </summary>
38        public double Y
39        {
40            get { return y; }
41            set { y = value; }
42        }
43
44        #endregion
45
46        #region Public Methods
47
48        public override SvgPointF QuadraticX1Y1
49        {
50            get
51            {
52                SvgPathSeg prevSeg = PreviousSeg;
53                if (prevSeg == null || !(prevSeg is SvgPathSegCurvetoQuadratic))
54                {
55                    return prevSeg.AbsXY;
56                }
57                else
58                {
59                    SvgPointF prevXY   = prevSeg.AbsXY;
60                    SvgPointF prevX1Y1 = ((SvgPathSegCurvetoQuadratic)prevSeg).QuadraticX1Y1;
61
62                    return new SvgPointF(2 * prevXY.X - prevX1Y1.X, 2 * prevXY.Y - prevX1Y1.Y);
63                }
64            }
65        }
66
67        public override SvgPointF AbsXY
68        {
69            get
70            {
71                SvgPathSeg prevSeg = PreviousSeg;
72                SvgPointF prevPoint;
73                if (prevSeg == null)
74                    prevPoint = new SvgPointF(0, 0);
75                else
76                    prevPoint = prevSeg.AbsXY;
77
78                return new SvgPointF(prevPoint.X + X, prevPoint.Y + Y);
79            }
80        }
81
82        public override SvgPointF CubicX1Y1
83        {
84            get
85            {
86                SvgPointF prevPoint = PreviousSeg.AbsXY;
87                SvgPointF x1y1 = QuadraticX1Y1;
88
89                double x1 = prevPoint.X + (x1y1.X - prevPoint.X) * 2 / 3;
90                double y1 = prevPoint.Y + (x1y1.Y - prevPoint.Y) * 2 / 3;
91
92                return new SvgPointF(x1, y1);
93            }
94        }
95
96        public override SvgPointF CubicX2Y2
97        {
98            get
99            {
100                SvgPointF xy = AbsXY;
101                SvgPointF x1y1 = QuadraticX1Y1;
102                double x2 = x1y1.X + (xy.X - x1y1.X) / 3;
103                double y2 = x1y1.Y + (xy.Y - x1y1.Y) / 3;
104
105                return new SvgPointF(x2, y2);
106            }
107        }
108
109        public override string PathText
110        {
111            get
112            {
113                StringBuilder sb = new StringBuilder();
114                sb.Append(PathSegTypeAsLetter);
115                sb.Append(X);
116                sb.Append(",");
117                sb.Append(Y);
118
119                return sb.ToString();
120            }
121        }
122
123        #endregion
124    }
125}
Note: See TracBrowser for help on using the repository browser.