/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/ /* Jim Morey - morey@math.ubc.ca - Jan 28,1996 */ /*----------------------------------------------------------------------*/ import java.io.*; import java.applet.*; import java.awt.*; import java.net.*; import java.lang.*; import Board; import Omatrix; /*----------------------------------------------------------------------*/ public class Rotator extends Canvas implements Runnable { public Color background; int W,H,delay,oldx,oldy,stone=Vertex.PTR_BLACK; double angle,angle0; boolean keep_going,spin=true,choose=false; Thread kicker; Vertex pointing=null; Board board; Omatrix tmp,tmp2,tmp3,M0; Image im,imback,gif; Graphics offscreen,offback; Applet applet; /* - - - - - - - - - - - - - - - - - - - - - - */ Rotator(Applet applet_,Board board_,int width,int height,Image gif_) { board = board_; gif = gif_; applet=applet_; W = width; H = height; M0 = new Omatrix(); tmp = new Omatrix(); tmp2 = new Omatrix(); tmp3 = new Omatrix(); angle0 = 0; delay = 100; setupImages(); } /* - - - - - - - - - - - - - - - - - - - - - - */ void setupImages(){ resize(W,H); board.setScale(W,H); board.CalcScrPts((double)W/2,(double)H/2,0); im = applet.createImage(W,H); imback = applet.createImage(W,H); offback = imback.getGraphics(); offscreen = im.getGraphics(); background = Color.green; setBackground(background); createBack(gif); } /* - - - - - - - - - - - - - - - - - - - - - - */ public void paint(Graphics g) { update(g); } public void update(Graphics g) { if (W!=size().width || H!=size().height) { W=size().width; H=size().height; setupImages(); } offscreen.drawImage(imback, 0, 0, null); board.Draw(offscreen,(int)(W/2),(int)(H/2),0,!choose); g.drawImage(im, 0, 0, null); } /* - - - - - - - - - - - - - - - - - - - - - - */ void createBack(Image gif){ if (gif==null){ offback.setColor(background); offback.fillRect(0, 0, W, H); }else{ int gifx= gif.getWidth(null); int gify= gif.getHeight(null); for(int i=0;i