[Commit] RRClient RRBoardPanel.java,1.8,1.9 RRImages.java,1.6,1.7

Bart Massey commit at keithp.com
Sun Jun 8 21:11:09 PDT 2003


Committed by: bart

Update of /local/src/CVS/RRClient
In directory home.keithp.com:/tmp/cvs-serv32496

Modified Files:
	RRBoardPanel.java RRImages.java 
Log Message:
Did background highlighting on goal target, in dumbest
possible way.  Should have just gimped more bits.  Oh well.



Index: RRBoardPanel.java
===================================================================
RCS file: /local/src/CVS/RRClient/RRBoardPanel.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- RRBoardPanel.java	9 Jun 2003 01:54:44 -0000	1.8
+++ RRBoardPanel.java	9 Jun 2003 03:11:07 -0000	1.9
@@ -101,7 +101,13 @@
             for (int col = 0; col < dim; col++) {
 		int xdcol = floor(col * dcol);
 		int ydrow = floor(row * drow);
-		g.drawImage(blank_img, xdcol, ydrow, idcol, idrow, this);
+		Image blank = blank_img;
+		RRSquare s = ctl.board.getSquare(row, col);
+		if (s.isPrimaryTarget()) {
+		    int target = s.getTarget();
+		    blank = ctl.images.getColoredBlankImage(target / 4);
+		}
+		g.drawImage(blank, xdcol, ydrow, idcol, idrow, this);
 	    }
 	}
         /* draw targets */

Index: RRImages.java
===================================================================
RCS file: /local/src/CVS/RRClient/RRImages.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- RRImages.java	9 Jun 2003 00:11:40 -0000	1.6
+++ RRImages.java	9 Jun 2003 03:11:07 -0000	1.7
@@ -14,21 +14,50 @@
 import java.awt.image.*;
 
 class DimFilter extends RGBImageFilter {
-    public DimFilter() {
+    double fraction;
+
+    public DimFilter(double fraction) {
 	// The filter's operation does not depend on the
 	// pixel's location, so IndexColorModels can be
 	// filtered directly.
+	this.fraction = fraction;
 	canFilterIndexColorModel = true;
     }
 
     public int filterRGB(int x, int y, int rgb) {
 	int color = rgb & 0x00ffffff;
 	int alpha = (rgb >> 24) & 0xff;
-	alpha = alpha / 4;
+	alpha = (int)Math.floor(alpha * fraction);
 	return (alpha << 24) | color;
     }
 }
 
+class RecolorFilter extends RGBImageFilter {
+    double[] fraction = new double[3];
+
+    public RecolorFilter(double red, double green, double blue) {
+	// The filter's operation does not depend on the
+	// pixel's location, so IndexColorModels can be
+	// filtered directly.
+	canFilterIndexColorModel = true;
+	fraction[0] = red;
+	fraction[1] = green;
+	fraction[2] = blue;
+    }
+
+    public int filterRGB(int x, int y, int rgb) {
+	for (int i = 0; i < 3; i++) {
+	    int color = (rgb >>> ((2 - i) * 8)) & 0xff;
+	    color = (int)Math.floor(color * fraction[i]);
+	    if (color > 0xff)
+		color = 0xff;
+	    rgb &= ~(0xff << ((2 - i) * 8));
+	    rgb |= color << ((2 - i) * 8);
+	}
+	return rgb;
+    }
+}
+
 public class RRImages {
     public static final int CIRCLE = 0;
     public static final int SQUARE = 1;
@@ -39,6 +68,7 @@
     Image[] target_images = new Image[17];
     Image[] dim_target_images = new Image[17];
     Image[] robot_images = new Image[4];
+    Image[] colored_blank_images = new Image[5];
 
     RRTkProxy tkproxy;
 
@@ -63,7 +93,7 @@
                            shapenames[i % 4] + ".png");
         target_images[16] = tkproxy.getImage("images/target-whirlpool.png");
 	/* make dimmed versions of the target symbols */
-	ImageFilter dim_filter = new DimFilter();
+	ImageFilter dim_filter = new DimFilter(0.15);
 	for (int i = 0; i < 17; i++) {
 	    ImageProducer img = target_images[i].getSource();
 	    FilteredImageSource src =
@@ -74,6 +104,23 @@
         for (int i = 0; i < 4; i++)
             robot_images[i] = tkproxy.getImage("images/robot-" +
                                          colornames[colors[i]] + ".png");
+	/* make the special floor overlays */
+	double big = 1.7;
+	double med = 1.5;
+	double small = 0.7;
+	double[][] fa = {
+	    {big,small,small},
+	    {med,med,small},
+	    {small,big,small},
+	    {small,small,big},
+	    {small,small,small}};
+	ImageProducer s = blank_image.getSource();
+	for (int i = 0; i < 5; i++) {
+	    double[] fai = fa[i];
+	    RecolorFilter f = new RecolorFilter(fai[0], fai[1], fai[2]);
+	    FilteredImageSource src = new FilteredImageSource(s, f);
+	    colored_blank_images[i] = tkproxy.createImage(src);
+	}
     }
 
     public RRImages(Toolkit tk) {
@@ -96,5 +143,9 @@
 
     public Image getRobotImage(int index) {
         return robot_images[index];
+    }
+
+    public Image getColoredBlankImage(int index) {
+	return colored_blank_images[index];
     }
 }




More information about the Commit mailing list