@Override
	public void draw() {
		BufferedImage layer = canvas.getLayers()[canvas.getLayerSelected()];
		// Graphics2D g = (Graphics2D) layer.getGraphics();

		// get the color of the pixel you clicked
		int clickedColor = layer.getRGB(x, y);

		Queue<Point> points = new LinkedList<Point>();
		points.add(new Point(x, y));

		while (!points.isEmpty()) {
			Point p = points.remove();
			int x = (int) p.getX();
			int y = (int) p.getY();
			if (canvas.contains(p)) {// point is on the screen
				if (layer.getRGB(x, y) == clickedColor) {// color
															// matches
					layer.setRGB(x, y, canvas.getColor().getRGB());
					points.add(new Point(x + 1, y));
					points.add(new Point(x - 1, y));
					points.add(new Point(x, y + 1));
					points.add(new Point(x, y - 1));
				}
			}
		}

		canvas.incrementCounter();
		canvas.repaint();

	}