-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcurven.C
105 lines (76 loc) · 1.59 KB
/
curven.C
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
#include <stdio.h>
#include<graphics.h>
#include<conio.h>
#include<dos.h>
#include<math.h>
union REGS in,out;
void initmouse(){
in.x.ax=1;
int86(0x33,&in,&out);
}
int x,y,a[2],x1,y1,x2,y2;
double xt,yt;
void location(){
a[0]=0;
a[1]=0;
while(!kbhit()) {
in.x.ax=3;
int86(0x33,&in,&out);
if(out.x.bx==1){
x=out.x.cx;
y=out.x.dx;
break;
}
}
while(!kbhit()){
in.x.ax=3;
int86(0x33,&in,&out);
if(out.x.bx==1){
a[0]=out.x.cx;
a[1]=out.x.dx;
cleardevice();
line(x,y,a[0],a[1]); }
if(out.x.bx==2){
break;
}
} // return a;
}
void blend(){
double t;
while(!kbhit()){
in.x.ax=3;
int86(0x33,&in,&out);
if(out.x.bx==2){
x1=out.x.cx;
y1=out.x.dx;
cleardevice();
for( t=0.0;t<1.0;t=t+0.001){
xt=(pow(1-t,3)*x+3*t*pow(1-t,2)*x2+3*pow(1-t,1)*pow(t,2)*x1+pow(t,3)*a[0]);
yt=(pow(1-t,3)*y+3*t*pow(1-t,2)*y2+3*pow(1-t,1)*pow(t,2)*y1+pow(t,3)*a[1]);
putpixel(xt,yt,WHITE);
}
}
if(out.x.bx==1){
x2=out.x.cx;
y2=out.x.dx;
cleardevice();
for( t=0.0;t<1.0;t=t+0.001){
xt=(pow(1-t,3)*x+3*t*pow(1-t,2)*x2+3*pow(1-t,1)*pow(t,2)*x1+pow(t,3)*a[0]);
yt=(pow(1-t,3)*y+3*t*pow(1-t,2)*y2+3*pow(1-t,1)*pow(t,2)*y1+pow(t,3)*a[1]);
putpixel(xt,yt,WHITE);
}
}
}
}
void main(){
int gd=DETECT,gm;
a[1]=0;
a[0]=0;
initgraph(&gd,&gm,"c:\\turboc3\\bgi");
// line(10,10,50,100);
initmouse();
location();
// printf("%d , %d",a[0],a[1]);
blend();
getch();
}