
import java.awt.*;
import java.io.*;

public class QuadBezierSegment
  implements Drawable
{
  public String name;
  public Dot p[];
  public Color color;

  public QuadBezierSegment( String name,
                          Dot p0, Dot p1, Dot p2, Color color )
  {
    this.name = name;
    p = new Dot[3];
    p[0] = p0;
    p[1] = p1;
    p[2] = p2;
    this.color = color;
  }

  public void paint( Graphics g )
  {
    if( color != null )
      g.setColor( color );
    int i, n;
    double t, t_;
    double step;
    double a, b, c, d;
    int x, y, lastx, lasty, x0, y0, x1, y1, x2, y2;
    x0 = p[0].getX(); y0 = p[0].getY();
    x1 = p[1].getX(); y1 = p[1].getY();
    x2 = p[2].getX(); y2 = p[2].getY();
    lastx = x0; lasty = y0;
    n = 20;
    step = 1.0 / n;
    for( i = 1; i <= n; i++ )
    {
      t = i * step;
      t_ = 1.0 - t;
      a = t_ * t_;
      b = 2 * t_ * t;
      c = t * t;
      x = (int) ( a * x0 + b * x1 + c * x2 );
      y = (int) ( a * y0 + b * y1 + c * y2 );
      g.drawLine( lastx, lasty, x, y );
      lastx = x; lasty = y;
    }
  }

  public int getX()
  {
    return 0;
  }
  public int getY()
  {
    return 0;
  }
}
