import java.applet.Applet; import java.awt.event.*; import java.awt.*; public class TorusColors { public static Color getColor(int v1,int v2,int trans,int mode) { if(mode==1) return(TorusColors.getColorX(v1,v2,trans)); if(mode==2) return(TorusColors.getColorY(v1,v2,trans)); return(TorusColors.getColorXY(v1,v2,trans)); } //this first routine is for illustrating the book public static Color getColorPrint(int v1,int v2) { Color COL=Color.white; if((v1==-1)&&(v2==-1)) COL=new Color(100,100,100); if((v1== 0)&&(v2==-1)) COL=new Color(140,140,140); if((v1==-1)&&(v2== 0)) COL=new Color(180,180,180); if((v1== 1)&&(v2==-1)) COL=new Color(220,220,220); return(COL); } public static Color getColorXY(int v1,int v2,int trans) { Color COL=Color.black; if((v1== 1)&&(v2== 1)) COL=new Color(255,80,0,trans); if((v1==-1)&&(v2==-1)) COL=new Color(190,0,0,trans); if((v1==-1)&&(v2== 1)) COL=new Color(160,0,140,trans); if((v1== 1)&&(v2==-1)) COL=new Color(255,50,255,trans); if((v1== 0)&&(v2== 1)) COL=new Color(0,200,0,trans); if((v1== 0)&&(v2==-1)) COL=new Color(0,100,0,trans); if((v1==-1)&&(v2== 0)) COL=new Color(50,100,255,trans); if((v1== 1)&&(v2== 0)) COL=new Color(0,0,220,trans); if((v1== 0)&&(v2== 0)) COL=new Color(140,140,140,trans); return(COL); } public static Color getColorX(int v1,int v2,int trans) { Color COL=Color.black; if((v1== 1)&&(v2== 1)) COL=new Color(255,50,0,trans); if((v1==-1)&&(v2==-1)) COL=new Color(30,50,250,trans); if((v1==-1)&&(v2== 1)) COL=new Color(30,50,250,trans); if((v1== 1)&&(v2==-1)) COL=new Color(255,50,0,trans); if((v1== 0)&&(v2== 1)) COL=new Color(140,140,140,trans); if((v1== 0)&&(v2==-1)) COL=new Color(140,140,140,trans); if((v1==-1)&&(v2== 0)) COL=new Color(30,50,250,trans); if((v1== 1)&&(v2== 0)) COL=new Color(255,50,0,trans); if((v1== 0)&&(v2== 0)) COL=new Color(140,140,140,trans); return(COL); } public static Color getColorY(int v1,int v2,int trans) { Color COL=Color.black; if((v1== 1)&&(v2== 1)) COL=new Color(255,50,0,trans); if((v1==-1)&&(v2==-1)) COL=new Color(30,50,250,trans); if((v1==-1)&&(v2== 1)) COL=new Color(255,50,0,trans); if((v1== 1)&&(v2==-1)) COL=new Color(30,50,250,trans); if((v1== 0)&&(v2== 1)) COL=new Color(255,50,0,trans); if((v1== 0)&&(v2==-1)) COL=new Color(30,50,250,trans); if((v1==-1)&&(v2== 0)) COL=new Color(140,140,140,trans); if((v1== 1)&&(v2== 0)) COL=new Color(140,140,140,trans); if((v1== 0)&&(v2== 0)) COL=new Color(140,140,140,trans); return(COL); } }