/** * Draw a ball at screen coordinate (x, y) with a ball index `id' (0, 0) represents the top-left * corner `x', `y', `radius' are given in pixels the ball index (gray code) `id' can be 0 to 15 */ void paint(Graphics gc, int x, int y, int id, double radius) { if (balls == null) makeBalls(); Image img = balls[id]; // id = [0..15] int size = (int) (radius * 2 + .5); gc.drawImage(img, x - size / 2, y - size / 2, size, size, null); // System.out.println("" + x + " " + y + " " + id + " " + radius); }
void setRGB(double r, double g, double b) { Rl = (int) (256 * r - 1e-6); Gl = (int) (256 * g - 1e-6); Bl = (int) (256 * b - 1e-6); makeBalls(); }
/** Set color */ void setRGB(int r, int g, int b) { Rl = r; Gl = g; Bl = b; makeBalls(); }