package bezier;
import java.awt.*;

public class BCanvas extends Canvas{
  public Image     offs = null;
 
  Dimension size;

  public BCanvas(int width, int height){
      super();
      size = new Dimension(width,height);
      setSize(width, height);
  }

  public Dimension size(){
    return size;
  }

  public void makeOffScreen(){
      offs  = this.createImage(size().width, size().height);
      Graphics offsg = getOffScreenGraphics();
      offsg.setColor(this.getBackground());
      offsg.fillRect(0,0,size().width, size().height);
  }

  public void clearOffScreen(){
      Graphics offsg = getOffScreenGraphics();
      offsg.setColor(this.getBackground());
      offsg.fillRect(0,0,size().width, size().height);
  }

  public Graphics getOffScreenGraphics(){
      return offs.getGraphics();
  }

  public void paint(Graphics g){
      if(offs != null){
          g.drawImage(offs, 0, 0, this);
      }
  }

  public void repaint(Graphics g){
      g.drawImage(offs, 0, 0, this);
  }
}
