public float turbulence2(float x, float y, float freq) { float t = 0.0f; for (float f = 1.0f; f <= freq; f *= 2) t += evaluate(f*x, f*y) / f; return t; }
protected int[] filterPixels( int width, int height, int[] inPixels, Rectangle transformedSpace ) { // float[] minmax = Noise.findRange(this, null); // min = minmax[0]; // max = minmax[1]; int index = 0; int[] outPixels = new int[width * height]; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { outPixels[index++] = getPixel(x, y, inPixels, width, height); } } return outPixels; }
float fy = y-iy; float d = checkCube(fx, fy, ix, iy, results); if (d > fy) d = checkCube(fx, fy+1, ix, iy-1, results); if (d > 1-fy) d = checkCube(fx, fy-1, ix, iy+1, results); if (d > fx) { checkCube(fx+1, fy, ix-1, iy, results); if (d > fy) d = checkCube(fx+1, fy+1, ix-1, iy-1, results); if (d > 1-fy) d = checkCube(fx+1, fy-1, ix-1, iy+1, results); d = checkCube(fx-1, fy, ix+1, iy, results); if (d > fy) d = checkCube(fx-1, fy+1, ix+1, iy-1, results); if (d > 1-fy) d = checkCube(fx-1, fy-1, ix+1, iy+1, results);
@Override public BufferedImage doTransform(BufferedImage src, BufferedImage dest) { if (filter == null) { filter = new CellularFilter(NAME); f3 += bw; filter.setScale(scale.getValueAsFloat()); filter.setStretch(stretch.getValueAsPercentage()); filter.setAngle((float) (angle.getValueInRadians() + (Math.PI / 2))); filter.setF1(f1); filter.setF2(f2); filter.setF3(f3); filter.setGridType(gridType.getValue()); filter.setRandomness(gridRandomness.getValueAsPercentage()); filter.setColormap(gradient.getValue()); dest = filter.filter(src, dest); return dest;
nx += 1000; ny += 1000; // Reduce artifacts around 0,0 float f = turbulence == 1.0f ? evaluate(nx, ny) : turbulence2(nx, ny, turbulence);
@Override protected int[] filterPixels(int width, int height, int[] inPixels, Rectangle transformedSpace) { // float[] minmax = Noise.findRange(this, null); // min = minmax[0]; // max = minmax[1]; pt = createProgressTracker(height); int[] outPixels = new int[width * height]; Future<?>[] futures = new Future[height]; for (int y = 0; y < height; y++) { int finalY = y; Runnable calculateLineTask = () -> { int index = width * finalY; for (int x = 0; x < width; x++) { outPixels[index++] = getPixel(x, finalY, inPixels, width, height); } }; futures[y] = ThreadPool.submit(calculateLineTask); } ThreadPool.waitToFinish(futures, pt); finishProgressTracker(); return outPixels; }
nx += 1000; ny += 1000; // Reduce artifacts around 0,0 float f = turbulence == 1.0f ? evaluate(nx, ny) : turbulence2(nx, ny, turbulence);
public float turbulence2(float x, float y, float freq) { float t = 0.0f; for (float f = 1.0f; f <= freq; f *= 2) { t += evaluate(f * x, f * y) / f; } return t; }