예제 #1
0
 /** Draw the number in the square at x,y, using white circles */
 public void drawNumber(int num, double x, double y) {
   double xOff = x - DIAM / 2; // offset by radius of spots
   double yOff = y - DIAM / 2; // offset by radius of spots
   double left = xOff + WIDTH * 0.25;
   double centr = xOff + WIDTH * 0.5;
   double right = xOff + WIDTH * 0.75;
   double top = yOff + WIDTH * 0.25;
   double mid = yOff + WIDTH * 0.5;
   double bot = yOff + WIDTH * 0.75;
   UI.setColor(Color.white);
   if (num % 2 == 1) { // 1, 3, 5
     UI.fillOval(centr, mid, DIAM, DIAM);
   }
   if (num > 1) { // 2, 3, 4, 5, 6
     UI.fillOval(left, top, DIAM, DIAM);
     UI.fillOval(right, bot, DIAM, DIAM);
   }
   if (num > 3) { // 4, 5, 6
     UI.fillOval(left, bot, DIAM, DIAM);
     UI.fillOval(right, top, DIAM, DIAM);
   }
   if (num == 6) {
     UI.fillOval(left, mid, DIAM, DIAM);
     UI.fillOval(right, mid, DIAM, DIAM);
   }
 }
예제 #2
0
 /** Draws the domino at the position x, y */
 public void draw(double x, double y) {
   UI.setLineWidth(1);
   UI.setColor(Color.black);
   UI.fillRect(x, y, WIDTH, HEIGHT);
   UI.setColor(Color.red.darker());
   UI.drawRect(x + 1, y + 1, WIDTH - 3, HEIGHT - 3);
   UI.setLineWidth(2);
   UI.setColor(Color.gray);
   UI.drawLine(x + 2, y + WIDTH, x + WIDTH - 3, y + WIDTH);
   UI.setLineWidth(1);
   if (!flipped) {
     this.drawNumber(this.first, x, y);
     this.drawNumber(this.secnd, x, y + WIDTH);
   } else {
     this.drawNumber(this.secnd, x, y);
     this.drawNumber(this.first, x, y + WIDTH);
   }
 }