1 | using System;
|
---|
2 | using System.Text;
|
---|
3 |
|
---|
4 | namespace SharpVectors.Dom.Svg
|
---|
5 | {
|
---|
6 | /// <summary>
|
---|
7 | /// Summary description for SvgPathSegCurvetoCubicAbs.
|
---|
8 | /// </summary>
|
---|
9 | public sealed class SvgPathSegCurvetoQuadraticRel : SvgPathSegCurvetoQuadratic, ISvgPathSegCurvetoQuadraticRel
|
---|
10 | {
|
---|
11 | #region constructors
|
---|
12 |
|
---|
13 | public SvgPathSegCurvetoQuadraticRel(double x, double y, double x1, double y1)
|
---|
14 | : base(SvgPathSegType.CurveToQuadraticRel)
|
---|
15 | {
|
---|
16 | this.x = x;
|
---|
17 | this.y = y;
|
---|
18 | this.x1 = x1;
|
---|
19 | this.y1 = y1;
|
---|
20 | }
|
---|
21 |
|
---|
22 | #endregion
|
---|
23 |
|
---|
24 | #region SvgPathSegCurvetoQuadraticRel 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 x1;
|
---|
41 | public double X1
|
---|
42 | {
|
---|
43 | get { return x1; }
|
---|
44 | set { x1 = value; }
|
---|
45 | }
|
---|
46 |
|
---|
47 | private double y1;
|
---|
48 | public double Y1
|
---|
49 | {
|
---|
50 | get { return y1; }
|
---|
51 | set { y1 = value; }
|
---|
52 | }
|
---|
53 | #endregion
|
---|
54 |
|
---|
55 | #region Pubic Methods
|
---|
56 |
|
---|
57 | public override SvgPointF AbsXY
|
---|
58 | {
|
---|
59 | get
|
---|
60 | {
|
---|
61 | SvgPathSeg prevSeg = PreviousSeg;
|
---|
62 | SvgPointF prevPoint;
|
---|
63 | if (prevSeg == null) prevPoint = new SvgPointF(0, 0);
|
---|
64 | else prevPoint = prevSeg.AbsXY;
|
---|
65 |
|
---|
66 | return new SvgPointF(prevPoint.X + X, prevPoint.Y + Y);
|
---|
67 | }
|
---|
68 | }
|
---|
69 |
|
---|
70 | public override SvgPointF QuadraticX1Y1
|
---|
71 | {
|
---|
72 | get
|
---|
73 | {
|
---|
74 | SvgPathSeg prevSeg = PreviousSeg;
|
---|
75 | SvgPointF prevPoint;
|
---|
76 | if (prevSeg == null) prevPoint = new SvgPointF(0, 0);
|
---|
77 | else prevPoint = prevSeg.AbsXY;
|
---|
78 |
|
---|
79 | return new SvgPointF(prevPoint.X + X1, prevPoint.Y + Y1);
|
---|
80 | }
|
---|
81 | }
|
---|
82 |
|
---|
83 | public override SvgPointF CubicX1Y1
|
---|
84 | {
|
---|
85 | get
|
---|
86 | {
|
---|
87 | SvgPointF prevPoint = PreviousSeg.AbsXY;
|
---|
88 |
|
---|
89 | double x1 = prevPoint.X + X1 * 2 / 3;
|
---|
90 | double y1 = prevPoint.Y + Y1 * 2 / 3;
|
---|
91 |
|
---|
92 | return new SvgPointF(x1, y1);
|
---|
93 | }
|
---|
94 | }
|
---|
95 |
|
---|
96 | public override SvgPointF CubicX2Y2
|
---|
97 | {
|
---|
98 | get
|
---|
99 | {
|
---|
100 | SvgPointF prevPoint = PreviousSeg.AbsXY;
|
---|
101 |
|
---|
102 | double x2 = X1 + prevPoint.X + (X - X1) / 3;
|
---|
103 | double y2 = Y1 + prevPoint.Y + (Y - Y1) / 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(X1);
|
---|
116 | sb.Append(",");
|
---|
117 | sb.Append(Y1);
|
---|
118 | sb.Append(",");
|
---|
119 | sb.Append(X);
|
---|
120 | sb.Append(",");
|
---|
121 | sb.Append(Y);
|
---|
122 |
|
---|
123 | return sb.ToString();
|
---|
124 | }
|
---|
125 | }
|
---|
126 |
|
---|
127 | #endregion
|
---|
128 | }
|
---|
129 | }
|
---|