return (double) coverage / (double) maxCoverage;
}
public RandomFlameGeneratorSample createSample() {
RenderInfo info = new RenderInfo(imageWidth, imageHeight, RenderMode.PREVIEW);
Flame bestFlame = null;
int bgRed = prefs.getTinaRandomBatchBGColorRed();
int bgGreen = prefs.getTinaRandomBatchBGColorGreen();
int bgBlue = prefs.getTinaRandomBatchBGColorBlue();
RandomFlameGeneratorState randGenState = randGen.initState(prefs, randGradientGen);
double bestCoverage = 0.0;
for (int j = 0; j < quality.getMaxSamples(); j++) {
// create flame
Flame flame;
try {
flame = randGen.createFlame(prefs, randGenState);
randSymmGen.addSymmetry(flame);
}
catch (Exception ex) {
flame = new Flame();
ex.printStackTrace();
}
flame.setWidth(imageWidth);
flame.setHeight(imageHeight);
flame.setPixelsPerUnit(10);
flame.setSpatialFilterRadius(0.0);
for (Layer layer : flame.getLayers()) {
RGBPalette palette = randGradientGen.generatePalette(paletteSize, fadePaletteColors);
layer.setPalette(palette);
}
flame = randGen.postProcessFlame(randGenState, flame);
// render it
flame.setSampleDensity(25);
RenderedFlame renderedFlame;
flame.setAntialiasAmount(0.0);
try {
FlameRenderer renderer = new FlameRenderer(flame, prefs, false, true);
renderedFlame = renderer.renderFlame(info);
}
finally {
flame.setAntialiasAmount(prefs.getTinaDefaultAntialiasingAmount());
}
if (j == quality.getMaxSamples() - 1) {
renderedFlame = new FlameRenderer(bestFlame, prefs, false, true).renderFlame(info);
return new RandomFlameGeneratorSample(bestFlame, renderedFlame.getImage());
}