private void Circul int int int int int col row int a_square b_square

 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
private void Circul(int x, int y, int a, int b)
{
int col = 0, row = 0;
int a_square, b_square, two_a_square, two_b_square, four_a_square, four_b_square, d;
Graphics g = Graphics.FromHwnd(this.Handle);
Pen Brush = new Pen(new SolidBrush(Color.Blue), 2f);
b_square = b * b;
a_square = a * a;
row = b;
col = 0;
two_a_square = a_square << 1;
four_a_square = a_square << 2;
four_b_square = b_square << 2;
two_b_square = b_square << 1;
d = two_a_square * ((row - 1) * (row)) + a_square + two_b_square * (1 - a_square);
while (a_square * (row) > b_square * (col))
{
g.DrawRectangle(Brush, col + x, row + y, 1, 1);
g.DrawRectangle(Brush, col + x, y - row, 1, 1);
g.DrawRectangle(Brush, x - col, row + y, 1, 1);
g.DrawRectangle(Brush, x - col, y - row, 1, 1);
if (d >= 0)
{
row--;
d -= four_a_square * (row);
}
d += two_b_square * (3 + (col << 1));
col++;
}
d = two_b_square * (col + 1) * col + two_a_square * (row * (row - 2) + 1) + (1 - two_a_square) * b_square;
while (((row) + 1) > 0)
{
g.DrawRectangle(Brush, col + x, row + y, 1, 1);
g.DrawRectangle(Brush, col + x, y - row, 1, 1);
g.DrawRectangle(Brush, x - col, row + y, 1, 1);
g.DrawRectangle(Brush, x - col, y - row, 1, 1);
if (d <= 0)
{
col++;
d += four_b_square * col;
}
row--;
d += two_a_square * (3 - (row << 1));
}
}