-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPolarCircle.cs
71 lines (64 loc) · 2.48 KB
/
PolarCircle.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
namespace Graphics_Assignments
{
public class PolarCircle
{
public float xc, yc, xcOriginal, ycOriginal, sAngle, eAngle;
public int r;
public PolarCircle(int xcent, int ycent, int radius, int startAngle, int endAngle)
{
xc = xcent;
yc = ycent;
xcOriginal = xcent;
ycOriginal = ycent;
r = radius;
sAngle = startAngle;
eAngle = endAngle;
}
public void drawCircle(Graphics g, float gap, Brush b)
{
float angle = this.sAngle;
while (angle < this.eAngle) // smaller value to draw arcs
{
float thRadian = (float)(angle * Math.PI / 180);
float x = (float)(r * Math.Cos(thRadian)) + xc;
float y = (float)(r * Math.Sin(thRadian)) + yc;
g.FillEllipse(b, x, y, 5, 5);
angle += gap; // for dashed circle
}
//g.FillEllipse(Brushes.Red, xc, yc, 5, 5); // To show the mid-point
}
public void drawCustomCircle(Graphics g, float gap, Brush b, int tomX, int tomY)
{
float angle = this.sAngle;
int i = 0;
while (angle < this.eAngle) // smaller value to draw arcs
{
float thRadian = (float)(angle * Math.PI / 180);
float x = (float)(r * Math.Cos(thRadian)) + xc;
float y = (float)(r * Math.Sin(thRadian)) + yc;
//g.FillEllipse(b, x, y, 5, 5);
if(i == 0 || (angle + gap) >= this.eAngle)
g.DrawLine(Pens.Yellow, tomX + 175, tomY + 50, x, y);
else
g.DrawLine(Pens.Red, tomX + 175, tomY + 50, x, y);
angle += gap; // for dashed circle
i++;
}
g.FillEllipse(Brushes.Red, xc, yc, 5, 5); // To show the mid-point
//g.DrawLine(Pens.Yellow, tomX + 175, tomY + 50, x, y);
}
public PointF getNextPoint(float angle)
{
float thRadian = (float)(angle * Math.PI / 180);
float x = (float)(r * Math.Cos(thRadian)) + xc;
float y = (float)(r * Math.Sin(thRadian)) + yc;
return new PointF(x, y);
}
}
}