hi how do i fill in a 2d object made by bezier curves into a specific colour, tried the glLineWidth but i get jerky edges around it(see pic below) how do i get rid of these jerky lines or is their a much simplier way to to this? my teacher adviced us to fill the object with colour by just drawing loads of bezier curves that goes inside the object. the pic below will explain more
the code fo the beziee cuves is below
////////the pond//////////////////////////////////////////////////
void DrawBezier(float firstx1,float firsty1,float lastx2,float lasty2,float conx1, float cony1,float conx2,float cony2)
{
Ax =lastx2 -firstx1-3*conx2+3*conx1;
Bx = 3*firstx1 -6*conx1 +3*conx2;
Cx=-3*firstx1+3*conx1;
Dx=firstx1;
Ay =lasty2 -firsty1-3*cony2+3*cony1;
By = 3*firsty1 -6*cony1 +3*cony2;
Cy=-3*firsty1+3*cony1;
Dy=firsty1;
// now draw the curve
for (t=0.0;t<=1.0 ; t=t+0.05)
{
x1=Ax*t*t*t +Bx*t*t + Cx*t + Dx;
k =Ay*t*t*t +By*t*t + Cy*t + Dy;
p=t+0.05;
x2=Ax*p*p*p +Bx*p*p + Cx*p + Dx;
y2=Ay*p*p*p +By*p*p + Cy*p + Dy;
glLineWidth(7.0);
glBegin(GL_LINES);
glColor3f(0.0,0.0,0.5);
glVertex2f(x1,k);
glVertex2f(x2,y2);
glEnd();
}
}
//////////////////////////////////////////////////////////////////////////////////
these are my co ordinates that goes on the display function
DrawBezier(300.0,320.0,370.0,450.0,270.0,380.0,315.0,410.0);
DrawBezier(370.0,450.0,480.0,400.0,440.0,485.0,490.0,478.0);
DrawBezier(480.0,400.0,428.0,300.0,520.0,395.0,510.0,325.0);
DrawBezier(428.0,300.0,300.0,320.0,380.0,300.0,330.0,310.0);
DrawBezier(310.0,350.0,400.0,425.0,325.0,380.0,360.0,410.0);
DrawBezier(400.0,425.0,455.0,393.0,430.0,445.0,460.0,430.0);
DrawBezier(455.0,393.0,400.0,330.0,490.0,375.0,475.0,350.0);