/
Primitivos.cs
816 lines (720 loc) · 23.2 KB
/
Primitivos.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
/*
* Código del paquete
* https://bitbucket.org/C3/2d-xna-primitives/src/95c26ebe054db4409fd7056b20057671b581dc43/Primitives2D.cs?fileviewer=file-view-default
*/
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace Moggle
{
/// <summary>
/// Provee métidos de dibujo primitivos
/// </summary>
public static class Primitivos
{
/// <summary>
/// Dibuja una línea
/// </summary>
/// <param name="sb">Batch</param>
/// <param name="start">Inicio de la línea</param>
/// <param name="end">Final de la línea</param>
/// <param name="color">Color.</param>
/// <param name="text">Textura</param>
public static void DrawLine (SpriteBatch sb,
Vector2 start,
Vector2 end,
Color color,
Texture2D text)
{
var edge = end - start;
// calculate angle to rotate line
var angle = (float)Math.Atan2 (edge.Y, edge.X);
sb.Draw (text,
start,
new Rectangle (
(int)start.X,
(int)start.Y,
(int)edge.Length (),
1),
color,
angle,
Vector2.Zero,
1.0f,
SpriteEffects.None,
0);
}
/// <summary>
/// Dibuja un rectángulo en un SpriteBatch
/// </summary>
public static void DrawRectangle (SpriteBatch bat,
Rectangle rect,
Color color,
Texture2D textura)
{
var tl = new Vector2 (rect.Left, rect.Top);
var tr = new Vector2 (rect.Right, rect.Top);
var bl = new Vector2 (rect.Left, rect.Bottom);
var br = new Vector2 (rect.Right, rect.Bottom);
DrawLine (bat, tl, tr, color, textura);
DrawLine (bat, tr, br, color, textura);
DrawLine (bat, br, bl, color, textura);
DrawLine (bat, bl, tl, color, textura);
}
#region Private Members
static readonly Dictionary<string, List<Vector2>> circleCache = new Dictionary<string, List<Vector2>> ();
//private static readonly Dictionary<String, List<Vector2>> arcCache = new Dictionary<string, List<Vector2>>();
static Texture2D pixel;
#endregion
#region Private Methods
static void CreateThePixel (GraphicsResource spriteBatch)
{
pixel = new Texture2D (
spriteBatch.GraphicsDevice,
1,
1,
false,
SurfaceFormat.Color);
pixel.SetData (new [] { Color.White });
}
/// <summary>
/// Draws a list of connecting points
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// /// <param name="position">Where to position the points</param>
/// <param name="points">The points to connect with lines</param>
/// <param name="color">The color to use</param>
/// <param name="thickness">The thickness of the lines</param>
static void DrawPoints (SpriteBatch spriteBatch,
Vector2 position,
IList<Vector2> points,
Color color,
float thickness)
{
if (points.Count < 2)
return;
for (int i = 1; i < points.Count; i++)
{
DrawLine (
spriteBatch,
points [i - 1] + position,
points [i] + position,
color,
thickness);
}
}
/// <summary>
/// Creates a list of vectors that represents a circle
/// </summary>
/// <param name="radius">The radius of the circle</param>
/// <param name="sides">The number of sides to generate</param>
/// <returns>A list of vectors that, if connected, will create a circle</returns>
static List<Vector2> CreateCircle (double radius, int sides)
{
// Look for a cached version of this circle
string circleKey = radius + "x" + sides;
if (circleCache.ContainsKey (circleKey))
{
return circleCache [circleKey];
}
var vectors = new List<Vector2> ();
const double max = 2.0 * Math.PI;
double step = max / sides;
for (double theta = 0.0; theta < max; theta += step)
{
vectors.Add (new Vector2 (
(float)(radius * Math.Cos (theta)),
(float)(radius * Math.Sin (theta))));
}
// then add the first vector again so it's a complete loop
vectors.Add (new Vector2 (
(float)(radius * Math.Cos (0)),
(float)(radius * Math.Sin (0))));
// Cache this circle so that it can be quickly drawn next time
circleCache.Add (circleKey, vectors);
return vectors;
}
/// <summary>
/// Creates a list of vectors that represents an arc
/// </summary>
/// <param name="radius">The radius of the arc</param>
/// <param name="sides">The number of sides to generate in the circle that this will cut out from</param>
/// <param name="startingAngle">The starting angle of arc, 0 being to the east, increasing as you go clockwise</param>
/// <param name="radians">The radians to draw, clockwise from the starting angle</param>
/// <returns>A list of vectors that, if connected, will create an arc</returns>
static List<Vector2> CreateArc (float radius,
int sides,
float startingAngle,
float radians)
{
var points = new List<Vector2> ();
points.AddRange (CreateCircle (radius, sides));
points.RemoveAt (points.Count - 1); // remove the last point because it's a duplicate of the first
// The circle starts at (radius, 0)
double curAngle = 0.0;
double anglePerSide = MathHelper.TwoPi / sides;
// "Rotate" to the starting point
while ((curAngle + (anglePerSide / 2.0)) < startingAngle)
{
curAngle += anglePerSide;
// move the first point to the end
points.Add (points [0]);
points.RemoveAt (0);
}
// Add the first point, just in case we make a full circle
points.Add (points [0]);
// Now remove the points at the end of the circle to create the arc
var sidesInArc = (int)((radians / anglePerSide) + 0.5);
points.RemoveRange (sidesInArc + 1, points.Count - sidesInArc - 1);
return points;
}
#endregion
#region FillRectangle
/// <summary>
/// Draws a filled rectangle
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="rect">The rectangle to draw</param>
/// <param name="color">The color to draw the rectangle in</param>
public static void FillRectangle (this SpriteBatch spriteBatch,
Rectangle rect,
Color color)
{
if (pixel == null)
{
CreateThePixel (spriteBatch);
}
// Simply use the function already there
spriteBatch.Draw (pixel, rect, color);
}
/// <summary>
/// Draws a filled rectangle
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="rect">The rectangle to draw</param>
/// <param name="color">The color to draw the rectangle in</param>
/// <param name="angle">The angle in radians to draw the rectangle at</param>
public static void FillRectangle (this SpriteBatch spriteBatch,
Rectangle rect,
Color color,
float angle)
{
if (pixel == null)
{
CreateThePixel (spriteBatch);
}
spriteBatch.Draw (
pixel,
rect,
null,
color,
angle,
Vector2.Zero,
SpriteEffects.None,
0);
}
/// <summary>
/// Draws a filled rectangle
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="location">Where to draw</param>
/// <param name="size">The size of the rectangle</param>
/// <param name="color">The color to draw the rectangle in</param>
public static void FillRectangle (this SpriteBatch spriteBatch,
Vector2 location,
Vector2 size,
Color color)
{
FillRectangle (spriteBatch, location, size, color, 0.0f);
}
/// <summary>
/// Draws a filled rectangle
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="location">Where to draw</param>
/// <param name="size">The size of the rectangle</param>
/// <param name="angle">The angle in radians to draw the rectangle at</param>
/// <param name="color">The color to draw the rectangle in</param>
public static void FillRectangle (this SpriteBatch spriteBatch,
Vector2 location,
Vector2 size,
Color color,
float angle)
{
if (pixel == null)
{
CreateThePixel (spriteBatch);
}
// stretch the pixel between the two vectors
spriteBatch.Draw (pixel,
location,
null,
color,
angle,
Vector2.Zero,
size,
SpriteEffects.None,
0);
}
/// <summary>
/// Draws a filled rectangle
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="x">The X coord of the left side</param>
/// <param name="y">The Y coord of the upper side</param>
/// <param name="w">Width</param>
/// <param name="h">Height</param>
/// <param name="color">The color to draw the rectangle in</param>
public static void FillRectangle (this SpriteBatch spriteBatch,
float x,
float y,
float w,
float h,
Color color)
{
FillRectangle (
spriteBatch,
new Vector2 (x, y),
new Vector2 (w, h),
color,
0.0f);
}
/// <summary>
/// Draws a filled rectangle
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="x">The X coord of the left side</param>
/// <param name="y">The Y coord of the upper side</param>
/// <param name="w">Width</param>
/// <param name="h">Height</param>
/// <param name="color">The color to draw the rectangle in</param>
/// <param name="angle">The angle of the rectangle in radians</param>
public static void FillRectangle (this SpriteBatch spriteBatch,
float x,
float y,
float w,
float h,
Color color,
float angle)
{
FillRectangle (
spriteBatch,
new Vector2 (x, y),
new Vector2 (w, h),
color,
angle);
}
#endregion
#region DrawRectangle
/// <summary>
/// Draws a rectangle with the thickness provided
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="rect">The rectangle to draw</param>
/// <param name="color">The color to draw the rectangle in</param>
public static void DrawRectangle (this SpriteBatch spriteBatch,
Rectangle rect,
Color color)
{
DrawRectangle (spriteBatch, rect, color, 1.0f);
}
/// <summary>
/// Draws a rectangle with the thickness provided
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="rect">The rectangle to draw</param>
/// <param name="color">The color to draw the rectangle in</param>
/// <param name="thickness">The thickness of the lines</param>
public static void DrawRectangle (this SpriteBatch spriteBatch,
Rectangle rect,
Color color,
float thickness)
{
// TODO: Handle rotations
// TODO: Figure out the pattern for the offsets required and then handle it in the line instead of here
DrawLine (
spriteBatch,
new Vector2 (rect.X, rect.Y),
new Vector2 (
rect.Right,
rect.Y),
color,
thickness); // top
DrawLine (
spriteBatch,
new Vector2 (rect.X + 1f, rect.Y),
new Vector2 (
rect.X + 1f,
rect.Bottom + thickness),
color,
thickness); // left
DrawLine (
spriteBatch,
new Vector2 (rect.X, rect.Bottom),
new Vector2 (
rect.Right,
rect.Bottom),
color,
thickness); // bottom
DrawLine (
spriteBatch,
new Vector2 (rect.Right + 1f, rect.Y),
new Vector2 (
rect.Right + 1f,
rect.Bottom + thickness),
color,
thickness); // right
}
/// <summary>
/// Draws a rectangle with the thickness provided
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="location">Where to draw</param>
/// <param name="size">The size of the rectangle</param>
/// <param name="color">The color to draw the rectangle in</param>
public static void DrawRectangle (this SpriteBatch spriteBatch,
Vector2 location,
Vector2 size,
Color color)
{
DrawRectangle (
spriteBatch,
new Rectangle (
(int)location.X,
(int)location.Y,
(int)size.X,
(int)size.Y),
color,
1.0f);
}
/// <summary>
/// Draws a rectangle with the thickness provided
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="location">Where to draw</param>
/// <param name="size">The size of the rectangle</param>
/// <param name="color">The color to draw the rectangle in</param>
/// <param name="thickness">The thickness of the line</param>
public static void DrawRectangle (this SpriteBatch spriteBatch,
Vector2 location,
Vector2 size,
Color color,
float thickness)
{
DrawRectangle (
spriteBatch,
new Rectangle (
(int)location.X,
(int)location.Y,
(int)size.X,
(int)size.Y),
color,
thickness);
}
#endregion
#region DrawLine
/// <summary>
/// Draws a line from point1 to point2 with an offset
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="x1">The X coord of the first point</param>
/// <param name="y1">The Y coord of the first point</param>
/// <param name="x2">The X coord of the second point</param>
/// <param name="y2">The Y coord of the second point</param>
/// <param name="color">The color to use</param>
public static void DrawLine (this SpriteBatch spriteBatch,
float x1,
float y1,
float x2,
float y2,
Color color)
{
DrawLine (
spriteBatch,
new Vector2 (x1, y1),
new Vector2 (x2, y2),
color,
1.0f);
}
/// <summary>
/// Draws a line from point1 to point2 with an offset
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="x1">The X coord of the first point</param>
/// <param name="y1">The Y coord of the first point</param>
/// <param name="x2">The X coord of the second point</param>
/// <param name="y2">The Y coord of the second point</param>
/// <param name="color">The color to use</param>
/// <param name="thickness">The thickness of the line</param>
public static void DrawLine (this SpriteBatch spriteBatch,
float x1,
float y1,
float x2,
float y2,
Color color,
float thickness)
{
DrawLine (
spriteBatch,
new Vector2 (x1, y1),
new Vector2 (x2, y2),
color,
thickness);
}
/// <summary>
/// Draws a line from point1 to point2 with an offset
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="point1">The first point</param>
/// <param name="point2">The second point</param>
/// <param name="color">The color to use</param>
public static void DrawLine (this SpriteBatch spriteBatch,
Vector2 point1,
Vector2 point2,
Color color)
{
DrawLine (spriteBatch, point1, point2, color, 1.0f);
}
/// <summary>
/// Draws a line from point1 to point2 with an offset
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="point1">The first point</param>
/// <param name="point2">The second point</param>
/// <param name="color">The color to use</param>
/// <param name="thickness">The thickness of the line</param>
public static void DrawLine (this SpriteBatch spriteBatch,
Vector2 point1,
Vector2 point2,
Color color,
float thickness)
{
// calculate the distance between the two vectors
var distance = Vector2.Distance (point1, point2);
// calculate the angle between the two vectors
var angle = (float)Math.Atan2 (point2.Y - point1.Y, point2.X - point1.X);
DrawLine (spriteBatch, point1, distance, angle, color, thickness);
}
/// <summary>
/// Draws a line from point1 to point2 with an offset
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="point">The starting point</param>
/// <param name="length">The length of the line</param>
/// <param name="angle">The angle of this line from the starting point in radians</param>
/// <param name="color">The color to use</param>
public static void DrawLine (this SpriteBatch spriteBatch,
Vector2 point,
float length,
float angle,
Color color)
{
DrawLine (spriteBatch, point, length, angle, color, 1.0f);
}
/// <summary>
/// Draws a line from point1 to point2 with an offset
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="point">The starting point</param>
/// <param name="length">The length of the line</param>
/// <param name="angle">The angle of this line from the starting point</param>
/// <param name="color">The color to use</param>
/// <param name="thickness">The thickness of the line</param>
public static void DrawLine (this SpriteBatch spriteBatch,
Vector2 point,
float length,
float angle,
Color color,
float thickness)
{
if (pixel == null)
{
CreateThePixel (spriteBatch);
}
// stretch the pixel between the two vectors
spriteBatch.Draw (pixel,
point,
null,
color,
angle,
Vector2.Zero,
new Vector2 (length, thickness),
SpriteEffects.None,
0);
}
#endregion
#region PutPixel
/// <summary>
/// Puts a pixel
/// </summary>
/// <param name="spriteBatch">Sprite batch.</param>
/// <param name="x">The x coordinate.</param>
/// <param name="y">The y coordinate.</param>
/// <param name="color">Color.</param>
public static void PutPixel (this SpriteBatch spriteBatch,
float x,
float y,
Color color)
{
PutPixel (spriteBatch, new Vector2 (x, y), color);
}
/// <summary>
/// Puts a pixel.
/// </summary>
/// <param name="spriteBatch">Sprite batch.</param>
/// <param name="position">Position.</param>
/// <param name="color">Color.</param>
public static void PutPixel (this SpriteBatch spriteBatch,
Vector2 position,
Color color)
{
if (pixel == null)
CreateThePixel (spriteBatch);
spriteBatch.Draw (pixel, position, color);
}
#endregion
#region DrawCircle
/// <summary>
/// Draw a circle
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="center">The center of the circle</param>
/// <param name="radius">The radius of the circle</param>
/// <param name="sides">The number of sides to generate</param>
/// <param name="color">The color of the circle</param>
public static void DrawCircle (this SpriteBatch spriteBatch,
Vector2 center,
float radius,
int sides,
Color color)
{
DrawPoints (spriteBatch, center, CreateCircle (radius, sides), color, 1.0f);
}
/// <summary>
/// Draw a circle
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="center">The center of the circle</param>
/// <param name="radius">The radius of the circle</param>
/// <param name="sides">The number of sides to generate</param>
/// <param name="color">The color of the circle</param>
/// <param name="thickness">The thickness of the lines used</param>
public static void DrawCircle (this SpriteBatch spriteBatch,
Vector2 center,
float radius,
int sides,
Color color,
float thickness)
{
DrawPoints (
spriteBatch,
center,
CreateCircle (radius, sides),
color,
thickness);
}
/// <summary>
/// Draw a circle
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="x">The center X of the circle</param>
/// <param name="y">The center Y of the circle</param>
/// <param name="radius">The radius of the circle</param>
/// <param name="sides">The number of sides to generate</param>
/// <param name="color">The color of the circle</param>
public static void DrawCircle (this SpriteBatch spriteBatch,
float x,
float y,
float radius,
int sides,
Color color)
{
DrawPoints (
spriteBatch,
new Vector2 (x, y),
CreateCircle (radius, sides),
color,
1.0f);
}
/// <summary>
/// Draw a circle
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="x">The center X of the circle</param>
/// <param name="y">The center Y of the circle</param>
/// <param name="radius">The radius of the circle</param>
/// <param name="sides">The number of sides to generate</param>
/// <param name="color">The color of the circle</param>
/// <param name="thickness">The thickness of the lines used</param>
public static void DrawCircle (this SpriteBatch spriteBatch,
float x,
float y,
float radius,
int sides,
Color color,
float thickness)
{
DrawPoints (
spriteBatch,
new Vector2 (x, y),
CreateCircle (radius, sides),
color,
thickness);
}
#endregion
#region DrawArc
/// <summary>
/// Draw a arc
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="center">The center of the arc</param>
/// <param name="radius">The radius of the arc</param>
/// <param name="sides">The number of sides to generate</param>
/// <param name="startingAngle">The starting angle of arc, 0 being to the east, increasing as you go clockwise</param>
/// <param name="radians">The number of radians to draw, clockwise from the starting angle</param>
/// <param name="color">The color of the arc</param>
public static void DrawArc (this SpriteBatch spriteBatch,
Vector2 center,
float radius,
int sides,
float startingAngle,
float radians,
Color color)
{
DrawArc (
spriteBatch,
center,
radius,
sides,
startingAngle,
radians,
color,
1.0f);
}
/// <summary>
/// Draw a arc
/// </summary>
/// <param name="spriteBatch">The destination drawing surface</param>
/// <param name="center">The center of the arc</param>
/// <param name="radius">The radius of the arc</param>
/// <param name="sides">The number of sides to generate</param>
/// <param name="startingAngle">The starting angle of arc, 0 being to the east, increasing as you go clockwise</param>
/// <param name="radians">The number of radians to draw, clockwise from the starting angle</param>
/// <param name="color">The color of the arc</param>
/// <param name="thickness">The thickness of the arc</param>
public static void DrawArc (this SpriteBatch spriteBatch,
Vector2 center,
float radius,
int sides,
float startingAngle,
float radians,
Color color,
float thickness)
{
var arc = CreateArc (radius, sides, startingAngle, radians);
//List<Vector2> arc = CreateArc2(radius, sides, startingAngle, degrees);
DrawPoints (spriteBatch, center, arc, color, thickness);
}
#endregion
}
}