Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/SharpVectorModel/Paths/SvgPathSegCurvetoQuadraticSmoothAbs.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.2 KB
Line 
1using System;
2using System.Text;
3
4namespace SharpVectors.Dom.Svg
5{
6    /// <summary>
7    /// The SvgPathSegCurvetoQuadraticSmoothAbs interface corresponds to an "absolute smooth quadratic curveto" (T) path data command.
8    /// </summary>
9    public sealed class SvgPathSegCurvetoQuadraticSmoothAbs : SvgPathSegCurvetoQuadratic, ISvgPathSegCurvetoQuadraticSmoothAbs
10    {
11        #region constructors
12
13        public SvgPathSegCurvetoQuadraticSmoothAbs(double x, double y)
14            : base(SvgPathSegType.CurveToQuadraticSmoothAbs)
15        {
16            this.x = x;
17            this.y = y;
18        }
19
20        #endregion
21
22        #region SvgPathSegCurvetoQuadraticSmoothAbs 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                return new SvgPointF(X, Y);
72            }
73        }
74
75        public override SvgPointF CubicX1Y1
76        {
77            get
78            {
79                SvgPointF prevPoint = PreviousSeg.AbsXY;
80                SvgPointF x1y1 = QuadraticX1Y1;
81
82                double x1 = prevPoint.X + (x1y1.X - prevPoint.X) * 2 / 3;
83                double y1 = prevPoint.Y + (x1y1.Y - prevPoint.Y) * 2 / 3;
84
85                return new SvgPointF(x1, y1);
86            }
87        }
88
89        public override SvgPointF CubicX2Y2
90        {
91            get
92            {
93                SvgPointF x1y1 = QuadraticX1Y1;
94                double x2 = x1y1.X + (X - x1y1.X) / 3;
95                double y2 = x1y1.Y + (Y - x1y1.Y) / 3;
96
97                return new SvgPointF(x2, y2);
98            }
99        }
100
101        public override string PathText
102        {
103            get
104            {
105                StringBuilder sb = new StringBuilder();
106                sb.Append(PathSegTypeAsLetter);
107                sb.Append(X);
108                sb.Append(",");
109                sb.Append(Y);
110
111                return sb.ToString();
112            }
113        }
114
115        #endregion
116    }
117}
Note: See TracBrowser for help on using the repository browser.