public void bezie double tau sx sy double Graphics Graphics FromHwnd t

 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
public void bezie()
{
double t, tau, sx, sy;
double a;
Graphics g = Graphics.FromHwnd(this.Handle);
for (t = 0.0; t < 0.5; t += 0.01)
{
tau = 1.0;
sx = x[0];
sy = y[0];
a = 1.0;
for (int i=1;i<n;i++)
{
tau = tau * (1 - t);
a = a * (n - i) *(1-t)/ i / t;
sx = sx + a * x[i];
sy = sy + a * y[i];
}
sx = sx * tau;
sy = sy * tau;
g.DrawRectangle (blackBrush, (int)(sx),(int) (sy), 1, 1);
}
for (t = 0.5; t < 1.0; t += 0.01)
{ tau = 1.0;
sx = x[0];
sy = y[0];
a = 1.0;
for (int i = n-2; i >=0; i--)
{
tau = tau * t;
a = a * (1-t) * (i+1)/ t / (n-i-1);
sx = sx + a * x[i];
sy = sy + a * y[i];
}
sx = sx * tau;
sy = sy * tau;
g.DrawRectangle(blackBrush, (int)sx, (int)sy, 1, 1);
}
}