Last change
on this file since 13777 was
12762,
checked in by aballeit, 9 years ago
|
#2283 GUI updates, Tree-chart, MCTS Version 2 (prune leaves)
|
File size:
2.9 KB
|
Line | |
---|
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 SvgPathSegCurvetoQuadraticAbs : SvgPathSegCurvetoQuadratic, ISvgPathSegCurvetoQuadraticAbs
|
---|
10 | {
|
---|
11 | #region constructors
|
---|
12 |
|
---|
13 | public SvgPathSegCurvetoQuadraticAbs(double x, double y, double x1, double y1)
|
---|
14 | : base(SvgPathSegType.CurveToQuadraticAbs)
|
---|
15 | {
|
---|
16 | this.x = x;
|
---|
17 | this.y = y;
|
---|
18 | this.x1 = x1;
|
---|
19 | this.y1 = y1;
|
---|
20 | }
|
---|
21 |
|
---|
22 | #endregion
|
---|
23 |
|
---|
24 | #region ISvgPathSegCurvetoQuadraticAbs 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 |
|
---|
54 | #endregion
|
---|
55 |
|
---|
56 | #region Public Methods
|
---|
57 |
|
---|
58 | public override SvgPointF AbsXY
|
---|
59 | {
|
---|
60 | get
|
---|
61 | {
|
---|
62 | return new SvgPointF(X, Y);
|
---|
63 | }
|
---|
64 | }
|
---|
65 |
|
---|
66 | public override SvgPointF QuadraticX1Y1
|
---|
67 | {
|
---|
68 | get
|
---|
69 | {
|
---|
70 | return new SvgPointF(X1, Y1);
|
---|
71 | }
|
---|
72 | }
|
---|
73 |
|
---|
74 | /*
|
---|
75 | * Convert to cubic bezier using the algorithm from Math:Bezier:Convert in CPAN
|
---|
76 | * $p0x+($p1x-$p0x)*2/3
|
---|
77 | * $p0y+($p1y-$p0y)*2/3
|
---|
78 | * $p1x+($p2x-$p1x)/3
|
---|
79 | * $p1x+($p2x-$p1x)/3
|
---|
80 | * */
|
---|
81 |
|
---|
82 | public override SvgPointF CubicX1Y1
|
---|
83 | {
|
---|
84 | get
|
---|
85 | {
|
---|
86 | SvgPointF prevPoint = PreviousSeg.AbsXY;
|
---|
87 |
|
---|
88 | double x1 = prevPoint.X + (X1 - prevPoint.X) * 2 / 3;
|
---|
89 | double y1 = prevPoint.Y + (Y1 - prevPoint.Y) * 2 / 3;
|
---|
90 |
|
---|
91 | return new SvgPointF(x1, y1);
|
---|
92 | }
|
---|
93 | }
|
---|
94 |
|
---|
95 | public override SvgPointF CubicX2Y2
|
---|
96 | {
|
---|
97 | get
|
---|
98 | {
|
---|
99 | double x2 = X1 + (X - X1) / 3;
|
---|
100 | double y2 = Y1 + (Y - Y1) / 3;
|
---|
101 |
|
---|
102 | return new SvgPointF(x2, y2);
|
---|
103 | }
|
---|
104 | }
|
---|
105 |
|
---|
106 | public override string PathText
|
---|
107 | {
|
---|
108 | get
|
---|
109 | {
|
---|
110 | StringBuilder sb = new StringBuilder();
|
---|
111 | sb.Append(PathSegTypeAsLetter);
|
---|
112 | sb.Append(X1);
|
---|
113 | sb.Append(",");
|
---|
114 | sb.Append(Y1);
|
---|
115 | sb.Append(",");
|
---|
116 | sb.Append(X);
|
---|
117 | sb.Append(",");
|
---|
118 | sb.Append(Y);
|
---|
119 |
|
---|
120 | return sb.ToString();
|
---|
121 | }
|
---|
122 | }
|
---|
123 |
|
---|
124 | #endregion
|
---|
125 | }
|
---|
126 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.