import java.awt.*;
public class interp extends java.applet.Applet {
 int step = 0;
 int shape1[] = {10,10, 150,10, 150,160, 10,160  };	
 int shape2[] = {50,10, 80,140, 20,140,  50,10   };
 int shape[]  = {0,0,   0,0,    0,0,     0,0     };
 Color col[] = {Color.black, Color.white, Color.blue,
		Color.green, Color.yellow, Color.pink,
		Color.magenta, Color.red};


	public void paint(Graphics g){
	  Polygon p = new Polygon();

	   for(int i=0;i<shape.length; i+=2){
		p.addPoint(shape[i],shape[i+1]);
	   }
	   g.setColor(col[step]);
	   g.fillPolygon(p);
	}
	
	public boolean mouseDown(Event e, int x, int y){
		interp();
		return true;
	}		

  	public void interp(){
	 int max_steps = col.length-1;

		// increment step
		if(step<max_steps) step++;
		else step = 0;
		

	       // calculate indeces of "in between" shape
	       for(int i=0;i<shape.length;i++){
		shape[i]=
		 (step*shape1[i]+(max_steps-step)*shape2[i])/
			max_steps;	
		 // interpolating from shape1 to shape2 
		 // ie. if step=0, use only x,y from shape2
		 // but if step=max_steps, use x,y from shape1
	       }
		repaint();
	}
}
