Search This Blog

C Program to Draw Malayalam Letter 'Dha' (ധ) Using Bezier Curves

This is a c program to draw Malayalam letter ധ using Bezier Curves. The program draws the letter
bezier curves with control points
ധ 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 with different set of control points twice.


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

 int x0[4]={52,54,126,153};
 int y0[4]={30,128,145,50};

 int x1[4]={153,170,250,253};
 int y1[4]={50,147,123,30};

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], YELLOW);
}
 
void main()
{
int gd = DETECT, gm;
initgraph (&gd, &gm, "..\\bgi");
setcolor(RED);
bezier(x0,y0);
setcolor(GREEN);
bezier(x1,y1);
getch();
closegraph();
}

No comments: