package rpn.graphics;

import java.awt.*;
import real.Formats;

public class RealCanvas extends Canvas {
	int w, h;
	RealGraphics gfx;
	Image img;

	/** The variables w and h determine the canvas size in pixels. */

	public RealCanvas(int w, int h) {
		this.w = w;
		this.h = h;
		resize(w, h);
	}
	
	public Rectangle getBounds() {
		return(bounds());
	}
	
	/** Reverses the normal ordering of paint() and 
		update() for flicker-free performance. */
	public void paint(Graphics g) {
		update(g);
	}

	/** Usually overridden. */
	public void update(Graphics g) {
		if (gfx == null) {
			img = createImage(w, h);
			Graphics G = img.getGraphics();
			gfx = new RealGraphics(G, w, h);
		}
		gfx.setColor(Color.black);
		gfx.clear();
		draw();
		g.drawImage(img, 0, 0, null);
	}
	
	public void draw() {
		PlotPath p = new PlotPath(gfx);
		p.moveto(0, 0);
		try {
			p.lineto(100, 100);
			p.stroke(Color.black);
		} catch (NoCurrentPointException e) { ; }
	
	}
}
