use of org.jwildfire.create.tina.base.Layer in project JWildfire by thargor6.
the class TinaController method xFormModLocalGammaRandomizeAllBtn_Clicked.
public void xFormModLocalGammaRandomizeAllBtn_Clicked(boolean pWholeFractal) {
if (pWholeFractal) {
Flame flame = getCurrFlame();
if (flame != null) {
saveUndoPoint();
for (Layer layer : flame.getLayers()) {
for (XForm xForm : layer.getXForms()) {
xForm.randomizeModColorEffects();
}
}
refreshXFormUI(getCurrXForm(XFormType.BOTH));
refreshFlameImage(true, false, 1, true, false);
}
} else {
XForm xForm = getCurrXForm(XFormType.NORMAL);
if (xForm != null) {
saveUndoPoint();
xForm.randomizeModColorEffects();
refreshXFormUI(xForm);
refreshFlameImage(true, false, 1, true, false);
}
}
}
use of org.jwildfire.create.tina.base.Layer in project JWildfire by thargor6.
the class TinaController method setCurrFlame.
private void setCurrFlame(Flame pFlame, boolean pAddToThumbnails) {
if (_currFlame == null || !_currFlame.equals(pFlame)) {
_currRandomizeFlame = pFlame.makeCopy();
}
setLastGradient(null);
if (_currFlame != null) {
for (Layer layer : _currFlame.getLayers()) {
deRegisterFromEditor(_currFlame, layer);
}
}
importFlame(pFlame, pAddToThumbnails);
for (Layer layer : _currFlame.getLayers()) {
registerToEditor(_currFlame, layer);
}
}
use of org.jwildfire.create.tina.base.Layer in project JWildfire by thargor6.
the class TinaController method paletteReverseBtn_clicked.
public void paletteReverseBtn_clicked() {
Layer layer = getCurrLayer();
if (layer != null) {
saveUndoPoint();
layer.getPalette().reverseColors();
refreshPaletteUI(layer.getPalette());
transformationChanged(true);
}
}
use of org.jwildfire.create.tina.base.Layer in project JWildfire by thargor6.
the class TinaController method randomizeBtn_clicked.
public void randomizeBtn_clicked() {
if (getCurrRandomizeFlame() != null) {
saveUndoPoint();
if (!getCurrRandomizeFlame().isRenderable()) {
_currRandomizeFlame = getCurrFlame().makeCopy();
}
final int MAX_ITER = 10;
final double MIN_RENDER_COVERAGE = 0.42;
final double MIN_DIFF_COVERAGE = 0.28;
final double INVALID_COVERAGE = -1.0;
Dimension probeSize = new Dimension(80, 60);
SimpleImage baseFlameImg = renderRandomizedFlame(getCurrRandomizeFlame().makeCopy(), probeSize);
SimpleImage simplifiedBaseFlameImg = RandomFlameGeneratorSampler.createSimplifiedRefImage(baseFlameImg);
int iter = 0;
double bestCoverage = INVALID_COVERAGE;
Flame bestMutation = null;
while (true) {
Flame currMutation = getCurrRandomizeFlame().makeCopy();
List<MutationType> mutationTypes = createRandomMutationTypes();
for (MutationType mutationType : mutationTypes) {
int layerIdx = data.layersTable.getSelectedRow();
Layer layer = currMutation.getLayers().get(layerIdx);
mutationType.createMutationInstance().execute(layer);
}
SimpleImage renderedImg = renderRandomizedFlame(currMutation.makeCopy(), probeSize);
double coverage = renderedImg != null ? RandomFlameGeneratorSampler.calculateCoverage(renderedImg, 0, 0, 0, true) : INVALID_COVERAGE;
if (coverage > MIN_RENDER_COVERAGE) {
coverage = RandomFlameGeneratorSampler.calculateDiffCoverage(renderedImg, simplifiedBaseFlameImg);
}
if (coverage > MIN_DIFF_COVERAGE) {
bestMutation = currMutation;
break;
} else if (coverage > bestCoverage) {
bestCoverage = coverage;
bestMutation = currMutation;
}
// Don't count invalid mutations
if (renderedImg != null) {
iter++;
}
if (iter >= MAX_ITER) {
break;
}
}
if (bestMutation != null) {
getCurrFlame().assign(bestMutation);
}
refreshUI();
}
}
use of org.jwildfire.create.tina.base.Layer in project JWildfire by thargor6.
the class TinaController method duplicateLayerBtn_clicked.
public void duplicateLayerBtn_clicked() {
Flame flame = getCurrFlame();
Layer layer = getCurrLayer();
Layer duplicate = layer.makeCopy();
saveUndoPoint();
flame.getLayers().add(duplicate);
gridRefreshing = true;
try {
refreshLayersTable();
} finally {
gridRefreshing = false;
}
int row = getCurrFlame().getLayers().size() - 1;
data.layersTable.getSelectionModel().setSelectionInterval(row, row);
}
Aggregations