11 private readonly
Path pathDef;
12 private readonly SKPath path;
13 private readonly
bool calcStart;
14 private readonly
bool calcEnd;
17 private float xPrev, yPrev;
19 private bool drawingSpline =
false;
21 private bool nonSpline =
false;
32 this.pathDef = PathDef;
34 this.calcStart = CalcStart;
35 this.calcEnd = CalcEnd;
41 public float X => this.x;
46 public float Y => this.y;
51 public float XPrev => this.xPrev;
56 public float YPrev => this.yPrev;
75 if (!this.angle.HasValue)
77 float dx = this.x - this.xPrev;
78 float dy = this.y - this.yPrev;
80 if (dx == 0 && dy == 0)
83 this.angle = (float)Math.Atan2(dy, dx);
86 return this.angle.Value;
95 public void Set0(
float X,
float Y)
100 this.nonSpline =
false;
109 public SKPoint
Add0(
float DeltaX,
float DeltaY)
111 SKPoint P = this.
Add(DeltaX, DeltaY);
113 this.nonSpline =
false;
125 this.
Set(this.x0, this.y0);
127 this.nonSpline =
false;
135 if (this.drawingSpline)
142 this.nonSpline =
false;
147 this.currentSpline =
null;
150 this.drawingSpline =
false;
161 public void Set(
float X,
float Y)
163 if (this.drawingSpline)
166 this.nonSpline =
true;
167 if (X != this.x || Y != this.y)
177 this.pathDef?.IncludePoint(X, Y);
185 public SKPoint
Add(
float DeltaX,
float DeltaY)
190 this.
Set(DeltaX, DeltaY);
192 return new SKPoint(DeltaX, DeltaY);
202 if (this.drawingSpline)
207 float Radians = this.
Angle;
208 float Dx = (float)(
Distance * Math.Cos(Radians));
209 float Dy = (float)(
Distance * Math.Sin(Radians));
211 return this.
Add(Dx, Dy);
214 return new SKPoint(this.x, this.y);
233 if (this.drawingSpline)
245 if (this.drawingSpline)
264 if (this.drawingSpline)
267 if (DeltaX == 0 && DeltaY == 0)
270 this.angle = (float)Math.Atan2(DeltaY, DeltaX);
279 if (this.drawingSpline)
290 if (this.drawingSpline)
292 this.drawingSpline =
false;
295 this.currentSpline =
null;
296 this.nonSpline =
false;
308 if (this.path is
null)
315 if (this.currentSpline is
null)
316 this.currentSpline =
new PathSpline(this.x, this.y);
318 this.currentSpline.
Add(X, Y);
319 this.drawingSpline =
true;
321 if (X != this.x || Y != this.y)
331 this.pathDef?.IncludePoint(X, Y);
334 return this.currentSpline;
Abstract base class for angle elements.
Abstract base class for distance elements.
Abstract base class for layout elements.
const float DegreesToRadians
Pi / 180