Search in sources :

Example 96 with Layer

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);
        }
    }
}
Also used : XForm(org.jwildfire.create.tina.base.XForm) Layer(org.jwildfire.create.tina.base.Layer) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Example 97 with Layer

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);
    }
}
Also used : Layer(org.jwildfire.create.tina.base.Layer)

Example 98 with 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);
    }
}
Also used : Layer(org.jwildfire.create.tina.base.Layer)

Example 99 with Layer

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();
    }
}
Also used : MutationType(org.jwildfire.create.tina.mutagen.MutationType) SimpleImage(org.jwildfire.image.SimpleImage) Dimension(java.awt.Dimension) Layer(org.jwildfire.create.tina.base.Layer) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Example 100 with Layer

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);
}
Also used : Layer(org.jwildfire.create.tina.base.Layer) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Aggregations

Layer (org.jwildfire.create.tina.base.Layer)105 XForm (org.jwildfire.create.tina.base.XForm)73 Flame (org.jwildfire.create.tina.base.Flame)63 VariationFunc (org.jwildfire.create.tina.variation.VariationFunc)31 XYZPoint (org.jwildfire.create.tina.base.XYZPoint)16 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)13 RGBPalette (org.jwildfire.create.tina.palette.RGBPalette)9 ArrayList (java.util.ArrayList)8 FlameWriter (org.jwildfire.create.tina.io.FlameWriter)5 RandomGradientMutation (org.jwildfire.create.tina.mutagen.RandomGradientMutation)4 Linear3DFunc (org.jwildfire.create.tina.variation.Linear3DFunc)4 DefaultTableModel (javax.swing.table.DefaultTableModel)2 Test (org.junit.Test)2 QualityProfile (org.jwildfire.base.QualityProfile)2 ResolutionProfile (org.jwildfire.base.ResolutionProfile)2 XMLAttributes (org.jwildfire.base.Tools.XMLAttributes)2 HeadlessBatchRendererController (org.jwildfire.create.tina.batch.HeadlessBatchRendererController)2 Job (org.jwildfire.create.tina.batch.Job)2 JobRenderThread (org.jwildfire.create.tina.batch.JobRenderThread)2 JobRenderThreadController (org.jwildfire.create.tina.batch.JobRenderThreadController)2