graph-drawing

Graphing a parabola


I have to draw filled parabola now I'm just drawing parabola using:

double dt = 0.0001;
for(double x = -50; x < 50; x+= dt){ // drawing parabola from -50 to 50
    double y = x*x;
    pic.drawPoint(x, y, cr, cg, cb); // x point, y point , R G B
}

What should I change here in order to make it fill the inside of parabola ?


Solution

  • Solved I just added another loop

    double dt = 0.0001;
    for(double x = -50; x < 50; x+= dt){ // drawing parabola from -50 to 50
       double y = x*x;
       for(double yy = y; yy < maxY; yy+=dt){ 
           pic.drawPoint(x, yy, cr, cg, cb); // x point, y point , R G B
      }  
    }