| 36 | } |
| 37 | |
| 38 | public static boolean PaintFill(Color[][] screen, int x, int y, Color ocolor, Color ncolor) { |
| 39 | if (x < 0 || x >= screen[0].length || y < 0 || y >= screen.length) { |
| 40 | return false; |
| 41 | } |
| 42 | if (screen[y][x] == ocolor) { |
| 43 | screen[y][x] = ncolor; |
| 44 | PaintFill(screen, x - 1, y, ocolor, ncolor); // left |
| 45 | PaintFill(screen, x + 1, y, ocolor, ncolor); // right |
| 46 | PaintFill(screen, x, y - 1, ocolor, ncolor); // top |
| 47 | PaintFill(screen, x, y + 1, ocolor, ncolor); // bottom |
| 48 | } |
| 49 | return true; |
| 50 | } |
| 51 | |
| 52 | public static boolean PaintFill(Color[][] screen, int x, int y, Color ncolor) { |
| 53 | if (screen[y][x] == ncolor) return false; |