CPColorFloat sampleColor(int x, int y, int dx, int dy) {
			LinkedList<CPColorFloat> samples = new LinkedList<CPColorFloat>();

			CPLayer layerToSample = sampleAllLayers ? fusion : getActiveLayer();

			samples.addLast(new CPColorFloat(layerToSample.getPixel(x, y) & 0xffffff));

			for (float r = 0.25f; r < 1.001f; r += .25f) {
				samples.addLast(new CPColorFloat(layerToSample.getPixel((int) (x + r * dx), y) & 0xffffff));
				samples.addLast(new CPColorFloat(layerToSample.getPixel((int) (x - r * dx), y) & 0xffffff));
				samples.addLast(new CPColorFloat(layerToSample.getPixel(x, (int) (y + r * dy)) & 0xffffff));
				samples.addLast(new CPColorFloat(layerToSample.getPixel(x, (int) (y - r * dy)) & 0xffffff));

				samples.addLast(new CPColorFloat(layerToSample.getPixel((int) (x + r * .7f * dx), (int) (y + r * .7f
						* dy)) & 0xffffff));
				samples.addLast(new CPColorFloat(layerToSample.getPixel((int) (x + r * .7f * dx), (int) (y - r * .7f
						* dy)) & 0xffffff));
				samples.addLast(new CPColorFloat(layerToSample.getPixel((int) (x - r * .7f * dx), (int) (y + r * .7f
						* dy)) & 0xffffff));
				samples.addLast(new CPColorFloat(layerToSample.getPixel((int) (x - r * .7f * dx), (int) (y - r * .7f
						* dy)) & 0xffffff));
			}

			CPColorFloat average = new CPColorFloat(0, 0, 0);
			for (CPColorFloat sample : samples) {
				average.r += sample.r;
				average.g += sample.g;
				average.b += sample.b;
			}
			average.r /= samples.size();
			average.g /= samples.size();
			average.b /= samples.size();

			return average;
		}