Skip to content

Commit e8853e7

Browse files
authored
Add files via upload
CLI mode curve drawing..bezier curve
1 parent d286fc9 commit e8853e7

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

curve_bezier.C

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#include<stdio.h>
2+
#include<conio.h>
3+
#include<graphics.h>
4+
#include<math.h>
5+
6+
7+
8+
void bsc(int x[4],int y[4])
9+
{
10+
11+
int gd=DETECT,gm;
12+
int i;
13+
14+
double t,xt,yt;
15+
initgraph(&gd,&gm,"c:\\turboc3\\bgi");
16+
for(t=0.0;t<1.0;t=t+0.00001)
17+
{
18+
xt=(pow(1-t,3)*x[0]+3*t*pow(1-t,2)*x[1]+3*pow(1-t,1)*pow(t,2)*x[2]+pow(t,3)*x[3]);
19+
yt=(pow(1-t,3)*y[0]+3*t*pow(1-t,2)*y[1]+3*pow(1-t,1)*pow(t,2)*y[2]+pow(t,3)*y[3]);
20+
21+
//printf("%lf %lf",xt,yt);
22+
putpixel(xt,yt,WHITE);
23+
}
24+
25+
for(i=0;i<4;i++)
26+
{
27+
putpixel(x[i],y[i],YELLOW);
28+
}
29+
30+
getch();
31+
32+
}
33+
void main(){
34+
int x[4],y[4],i;
35+
36+
printf("Enter 4 controll point :");
37+
for(i=0;i<4;i++){
38+
39+
scanf("%d%d",&x[i],&y[i]);
40+
41+
}
42+
43+
bsc(x,y);
44+
45+
46+
}

0 commit comments

Comments
 (0)