
import java.awt.*;
import java.awt.image.*;

public class Screen extends Canvas
{
private Image offImage;       // buffer for double buffering
private Graphics offGraphics; // buffer for double buffering

public int width;
public int height;

public Color COLOR;
public v3x1  point;
public v3x1  prev;
public Color prevc;
    
private int cx;
private int cy;
    
public Screen(int w, int h)
    {
	width = w;
	height = h;
	cx = (int)(width/2);
	cy = (int)(height/2);
	
	setSize(width, height);
    }

public void update(Graphics g)
    {
	paint(g);
    }
    
public void paint(Graphics g)
    {
	if((offGraphics == null))
	    {
		offImage = createImage(width, height);
		offGraphics = offImage.getGraphics();
		offGraphics.setColor(Color.black);
		offGraphics.fillRect(0, 0, width, height);
	    }

	if(point != null)
	    {
		if(prev != null)
		    {
			offGraphics.setColor(prevc);
			offGraphics.drawLine(cx + (int)(prev.x), cy + (int)(prev.y),
					     cx + (int)(point.x), cy + (int)(point.y));
		    }
		prev = new v3x1(point);
		prevc= new Color(COLOR.getRGB());
	    }
	g.drawImage(offImage, 0, 0, this);
    }
}

