1 | using System;
|
---|
2 | using System.Text;
|
---|
3 |
|
---|
4 | namespace SharpVectors.Dom.Svg
|
---|
5 | {
|
---|
6 | /// <summary>
|
---|
7 | /// Summary description for SvgPathSegCurvetoCubicSmoothAbs.
|
---|
8 | /// </summary>
|
---|
9 | public sealed class SvgPathSegCurvetoCubicSmoothRel : SvgPathSegCurvetoCubic, ISvgPathSegCurvetoCubicSmoothRel
|
---|
10 | {
|
---|
11 | #region constructors
|
---|
12 |
|
---|
13 | public SvgPathSegCurvetoCubicSmoothRel(double x, double y, double x2, double y2)
|
---|
14 | : base(SvgPathSegType.CurveToCubicSmoothRel)
|
---|
15 | {
|
---|
16 | this.x = x;
|
---|
17 | this.y = y;
|
---|
18 | this.x2 = x2;
|
---|
19 | this.y2 = y2;
|
---|
20 | }
|
---|
21 |
|
---|
22 | #endregion
|
---|
23 |
|
---|
24 | #region ISvgPathSegCurvetoCubicSmoothRel Members
|
---|
25 |
|
---|
26 | private double x;
|
---|
27 | public double X
|
---|
28 | {
|
---|
29 | get { return x; }
|
---|
30 | set { x = value; }
|
---|
31 | }
|
---|
32 |
|
---|
33 | private double y;
|
---|
34 | public double Y
|
---|
35 | {
|
---|
36 | get { return y; }
|
---|
37 | set { y = value; }
|
---|
38 | }
|
---|
39 |
|
---|
40 | private double x2;
|
---|
41 | public double X2
|
---|
42 | {
|
---|
43 | get { return x2; }
|
---|
44 | set { x2 = value; }
|
---|
45 | }
|
---|
46 |
|
---|
47 | private double y2;
|
---|
48 | public double Y2
|
---|
49 | {
|
---|
50 | get { return y2; }
|
---|
51 | set { y2 = value; }
|
---|
52 | }
|
---|
53 |
|
---|
54 | #endregion
|
---|
55 |
|
---|
56 | #region Public Methods
|
---|
57 |
|
---|
58 | public override SvgPointF AbsXY
|
---|
59 | {
|
---|
60 | get
|
---|
61 | {
|
---|
62 | SvgPathSeg prevSeg = PreviousSeg;
|
---|
63 | SvgPointF prevPoint;
|
---|
64 | if (prevSeg == null) prevPoint = new SvgPointF(0, 0);
|
---|
65 | else prevPoint = prevSeg.AbsXY;
|
---|
66 | return new SvgPointF(prevPoint.X + X, prevPoint.Y + Y);
|
---|
67 | }
|
---|
68 | }
|
---|
69 |
|
---|
70 | public override SvgPointF CubicX1Y1
|
---|
71 | {
|
---|
72 | get
|
---|
73 | {
|
---|
74 | SvgPathSeg prevSeg = PreviousSeg;
|
---|
75 | if (prevSeg == null || !(prevSeg is SvgPathSegCurvetoCubic))
|
---|
76 | {
|
---|
77 | return prevSeg.AbsXY;
|
---|
78 | }
|
---|
79 | else
|
---|
80 | {
|
---|
81 | SvgPointF prevXY = prevSeg.AbsXY;
|
---|
82 | SvgPointF prevX2Y2 = ((SvgPathSegCurvetoCubic)prevSeg).CubicX2Y2;
|
---|
83 |
|
---|
84 | return new SvgPointF(2 * prevXY.X - prevX2Y2.X, 2 * prevXY.Y - prevX2Y2.Y);
|
---|
85 | }
|
---|
86 | }
|
---|
87 | }
|
---|
88 |
|
---|
89 | public override SvgPointF CubicX2Y2
|
---|
90 | {
|
---|
91 | get
|
---|
92 | {
|
---|
93 | SvgPathSeg prevSeg = PreviousSeg;
|
---|
94 | SvgPointF prevPoint;
|
---|
95 | if (prevSeg == null) prevPoint = new SvgPointF(0, 0);
|
---|
96 | else prevPoint = prevSeg.AbsXY;
|
---|
97 | return new SvgPointF(prevPoint.X + X2, prevPoint.Y + 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(X2);
|
---|
108 | sb.Append(",");
|
---|
109 | sb.Append(Y2);
|
---|
110 | sb.Append(",");
|
---|
111 | sb.Append(X);
|
---|
112 | sb.Append(",");
|
---|
113 | sb.Append(Y);
|
---|
114 |
|
---|
115 | return sb.ToString();
|
---|
116 | }
|
---|
117 | }
|
---|
118 |
|
---|
119 | #endregion
|
---|
120 | }
|
---|
121 | }
|
---|