Search This Blog

C Program to Draw Malayalam Letter 'Tha' (ത) Using Bezier Curves

This is a c program to draw malayalam letter ത using Bezier Curves. The program draws the letter
drawing bezier curves in c program
ത using bezier curves
ത using four different Bezier curves. For understandability, individual curves are shown in different colors. The control points for each curve are set in the program and a function bezier() is called wth different set of control points four times.


#include <stdio.h>
#include <graphics.h>
#include <math.h>

 int cx1[4]={200,100,200,250};
 int cy1[4]={200,150,75,100};

 int cx2[4]={250,300,300,250};
 int cy2[4]={100,130,200,200};

 int cx3[4]={250,200,200,250};
 int cy3[4]={200,200,130,100};

 int cx4[4]={250,300,400,300};
 int cy4[4]={100,75,150,200};

void bezier (int x[], int y[])
{
int i;
double t,xt,yt;

for (t = 0.0; t < 1.0; t += 0.0005)
{
xt = pow(1-t,3)*x[0]+3*t*pow(1-t,2)*x[1]+3*pow(t,2)*(1-t)*x[2]+pow(t,3)*x[3];
yt = pow(1-t,3)*y[0]+3*t*pow(1-t,2)*y[1]+3*pow(t,2)*(1-t)*y[2]+pow(t,3)*y[3];
putpixel (xt, yt,getcolor());
}

for (i=0; i<4; i++)
 putpixel (x[i], y[i], WHITE);
}

void main()
{
int gd = DETECT, gm;
initgraph (&gd, &gm, "..\\bgi");
setcolor(BLUE);
bezier (cx1,cy1);
setcolor(RED);
bezier (cx2,cy2);
setcolor(GREEN);
bezier (cx3,cy3);
setcolor(YELLOW);
bezier (cx4,cy4);
getch();
closegraph();
}

No comments: