You are on page 1of 1

#include<iostream.

h>
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
void beizer(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4)
{
float tx,ty;
float t;
for(t=0.0;t<=1.0;t+=0.0001)
{
tx=(1-t)*(1-t)*(1-t)*x1+3*t*(1-t)*(1-t)*x2+3*t*t*(1-t)*x3+t*t*t*x4;
ty=(1-t)*(1-t)*(1-t)*y1+3*t*(1-t)*(1-t)*y2+3*t*t*(1-t)*y3+t*t*t*y4;
putpixel(tx+100,ty+100,WHITE);
} ;
}
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy;
int radius = 100;
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "bgi");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
//int x[4],y[4];
beizer(120,75,100,75,80,70,60,75);
beizer(120,30,120,60,120,90,120,120);
beizer(60,75,40,90,60,100,60,75);
beizer(250,75,230,75,210,70,190,75);
beizer(250,30,250,60,250,90,250,120);
beizer(190,75,170,90,190,100,190,75);
beizer(190,75,190,60,190,50,190,30);
beizer(350,75,330,75,310,70,290,75);
beizer(350,30,350,60,350,90,350,120);
beizer(290,75,270,90,290,100,290,75);
beizer(50,30,200,30,300,30,400,30);
getch();
closegraph();
}

You might also like