Search in sources :

Example 16 with Flame

use of org.jwildfire.create.tina.base.Flame in project JWildfire by thargor6.

the class OutlinesRandomFlameGenerator method prepareFlame.

@Override
public Flame prepareFlame(RandomFlameGeneratorState pState) {
    Flame flame = new Flame();
    Layer layer = flame.getFirstLayer();
    flame.setCentreX(0.1 - Math.random() * 0.2);
    flame.setCentreY(0.1 - Math.random() * 0.2);
    flame.setCamZoom(1.05 + Math.random() * 0.15);
    flame.setCamRoll(0);
    flame.setCamPitch(0);
    flame.setCamYaw(0);
    flame.setCamPerspective(0);
    flame.setPixelsPerUnit(200);
    layer.getFinalXForms().clear();
    layer.getXForms().clear();
    // create transform 1
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(26.32600695);
        xForm.setColor(0.74488914);
        xForm.setColorSymmetry(0);
        xForm.setMaterial(0);
        xForm.setMaterialSpeed(0);
        // a
        xForm.setCoeff00(1);
        // b
        xForm.setCoeff10(0);
        // e
        xForm.setCoeff20(1.25325706);
        // c
        xForm.setCoeff01(0);
        // d
        xForm.setCoeff11(1);
        // f
        xForm.setCoeff21(-0.93791588);
        xForm.setPostCoeff00(1);
        xForm.setPostCoeff10(0);
        xForm.setPostCoeff01(0);
        xForm.setPostCoeff11(1);
        xForm.setPostCoeff20(0);
        xForm.setPostCoeff21(0);
        // variation 1
        xForm.addVariation(1, VariationFuncList.getVariationFuncInstance("spherical3D", true));
        // set default edit plane
        flame.setEditPlane(EditPlane.XY);
    // random affine transforms (uncomment to play around)
    // XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, false);
    // XFormTransformService.rotate(xForm, 360.0*Math.random(), false);
    // XFormTransformService.localTranslate(xForm, 1.0-2.0*Math.random(), 1.0-2.0*Math.random(), false);
    // random affine post transforms (uncomment to play around)
    // XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, true);
    // XFormTransformService.rotate(xForm, 360.0*Math.random(), true);
    // XFormTransformService.localTranslate(xForm, 1.0-2.0*Math.random(), 1.0-2.0*Math.random(), true);
    }
    // create transform 2
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(224.48613855);
        xForm.setColor(0.90312262);
        xForm.setColorSymmetry(0.95);
        xForm.setMaterial(0);
        xForm.setMaterialSpeed(0);
        // a
        xForm.setCoeff00(1.07039553);
        // b
        xForm.setCoeff10(0.4803511);
        // e
        xForm.setCoeff20(-0.2742276);
        // c
        xForm.setCoeff01(-0.4803511);
        // d
        xForm.setCoeff11(1.07039553);
        // f
        xForm.setCoeff21(-0.04097021);
        xForm.setPostCoeff00(1);
        xForm.setPostCoeff10(0);
        xForm.setPostCoeff01(0);
        xForm.setPostCoeff11(1);
        xForm.setPostCoeff20(0);
        xForm.setPostCoeff21(0);
        // variation 1
        if (Math.random() > 0.1) {
            VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("loonie2", true);
            varFunc.setParameter("sides", 3 + (int) (Math.random() * 6));
            varFunc.setParameter("star", 0.1 + Math.random() * 0.3);
            varFunc.setParameter("circle", 0.1 + Math.random() * 0.3);
            xForm.addVariation(1, varFunc);
        } else {
            VariationFunc varFunc = VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname(), true);
            xForm.addVariation(1, varFunc);
        }
        // set default edit plane
        flame.setEditPlane(EditPlane.XY);
        // random affine transforms (uncomment to play around)
        // XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, false);
        // XFormTransformService.rotate(xForm, 360.0*Math.random(), false);
        // XFormTransformService.localTranslate(xForm, 1.0-2.0*Math.random(), 1.0-2.0*Math.random(), false);
        // random affine post transforms (uncomment to play around)
        // XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, true);
        XFormTransformService.rotate(xForm, 360.0 * Math.random(), true);
    // XFormTransformService.localTranslate(xForm, 1.0-2.0*Math.random(), 1.0-2.0*Math.random(), true);
    }
    // create transform 3
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(146.3720822);
        xForm.setColor(0.6312262);
        xForm.setColorSymmetry(0.12);
        xForm.setMaterial(0);
        xForm.setMaterialSpeed(0);
        // a
        xForm.setCoeff00(0.9031166);
        // b
        xForm.setCoeff10(0.38124873);
        // e
        xForm.setCoeff20(0.37716179);
        // c
        xForm.setCoeff01(-0.38124873);
        // d
        xForm.setCoeff11(0.9031166);
        // f
        xForm.setCoeff21(-0.53412667);
        xForm.setPostCoeff00(1);
        xForm.setPostCoeff10(0);
        xForm.setPostCoeff01(0);
        xForm.setPostCoeff11(1);
        xForm.setPostCoeff20(0);
        xForm.setPostCoeff21(0);
        // change relative weights
        xForm.getModifiedWeights()[2] = 0;
        // variation 1
        {
            VariationFunc varFunc = VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname(), true);
            xForm.addVariation(0.4 + Math.random() * 0.2, varFunc);
        }
        // set default edit plane
        flame.setEditPlane(EditPlane.XY);
        // random affine transforms (uncomment to play around)
        // XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, false);
        // XFormTransformService.rotate(xForm, 360.0*Math.random(), false);
        // XFormTransformService.localTranslate(xForm, 1.0-2.0*Math.random(), 1.0-2.0*Math.random(), false);
        // random affine post transforms (uncomment to play around)
        // XFormTransformService.scale(xForm, 1.25 - Math.random() * 0.5, true, true, true);
        XFormTransformService.rotate(xForm, 360.0 * Math.random(), true);
    // XFormTransformService.localTranslate(xForm, 1.0-2.0*Math.random(), 1.0-2.0*Math.random(), true);
    }
    return flame;
}
Also used : XForm(org.jwildfire.create.tina.base.XForm) Layer(org.jwildfire.create.tina.base.Layer) VariationFunc(org.jwildfire.create.tina.variation.VariationFunc) Flame(org.jwildfire.create.tina.base.Flame)

Example 17 with Flame

use of org.jwildfire.create.tina.base.Flame in project JWildfire by thargor6.

the class RandomFlameGenerator method createFlame.

public Flame createFlame(Prefs pPrefs, RandomFlameGeneratorState pState) {
    Flame flame = prepareFlame(pState);
    if (flame.getName() == null || flame.getName().length() == 0)
        flame.setName(this.getName() + " - " + flame.hashCode());
    flame.setBGTransparency(pPrefs.isTinaDefaultBGTransparency());
    if ((pPrefs.getTinaRandomBatchBGColorRed() > 0 || pPrefs.getTinaRandomBatchBGColorGreen() > 0 || pPrefs.getTinaRandomBatchBGColorBlue() > 0)) {
        flame.setBgColorType(BGColorType.SINGLE_COLOR);
        flame.setBgColorRed(pPrefs.getTinaRandomBatchBGColorRed());
        flame.setBgColorGreen(pPrefs.getTinaRandomBatchBGColorGreen());
        flame.setBgColorBlue(pPrefs.getTinaRandomBatchBGColorBlue());
    }
    return flame;
}
Also used : Flame(org.jwildfire.create.tina.base.Flame)

Example 18 with Flame

use of org.jwildfire.create.tina.base.Flame in project JWildfire by thargor6.

the class RandomFlameGeneratorSampler method createSample.

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);
            if (randGen.supportsSymmetry()) {
                randSymmGen.addSymmetry(flame);
            }
        } catch (Exception ex) {
            flame = new Flame();
            ex.printStackTrace();
        }
        flame.setWidth(imageWidth);
        flame.setHeight(imageHeight);
        flame.setPixelsPerUnit(10);
        for (Layer layer : flame.getLayers()) {
            RGBPalette palette = randGradientGen.generatePalette(paletteSize, fadePaletteColors, uniformWidth);
            layer.setPalette(palette);
        }
        flame = randGen.postProcessFlameBeforeRendering(randGenState, flame);
        // render it
        flame.setSampleDensity(25);
        RenderedFlame renderedFlame;
        flame.applyFastOversamplingSettings();
        try {
            FlameRenderer renderer = new FlameRenderer(flame, prefs, false, true);
            renderedFlame = renderer.renderFlame(info);
            flame = randGen.postProcessFlameAfterRendering(randGenState, flame);
            if (j == quality.getMaxSamples() - 1) {
                renderedFlame = new FlameRenderer(bestFlame, prefs, false, true).renderFlame(info);
                return new RandomFlameGeneratorSample(bestFlame, renderedFlame.getImage());
            } else {
                double fCoverage = calculateCoverage(renderedFlame.getImage(), bgRed, bgGreen, bgBlue, randGen.isUseFilter(randGenState));
                if (fCoverage >= quality.getCoverage() && fCoverage < randGen.getMaxCoverage()) {
                    return new RandomFlameGeneratorSample(flame, renderedFlame.getImage());
                } else {
                    if (bestFlame == null || fCoverage > bestCoverage) {
                        bestFlame = flame;
                        bestCoverage = fCoverage;
                    }
                }
            }
        } finally {
            flame.applyDefaultOversamplingSettings();
        }
    }
    throw new IllegalStateException();
}
Also used : RGBPalette(org.jwildfire.create.tina.palette.RGBPalette) FlameRenderer(org.jwildfire.create.tina.render.FlameRenderer) RenderInfo(org.jwildfire.create.tina.render.RenderInfo) Layer(org.jwildfire.create.tina.base.Layer) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Example 19 with Flame

use of org.jwildfire.create.tina.base.Flame in project JWildfire by thargor6.

the class BrokatRandomFlameGenerator method prepareFlame.

@Override
public Flame prepareFlame(RandomFlameGeneratorState pState) {
    Flame flame = new Flame();
    flame.setCentreX(0.0);
    flame.setCentreY(0.0);
    flame.setPixelsPerUnit(200);
    flame.setCamZoom(2.0);
    flame.setCamRoll(-90.0);
    Layer layer = flame.getFirstLayer();
    layer.getFinalXForms().clear();
    layer.getXForms().clear();
    // 1st xForm
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(1.5 + Math.random() * 1.0);
        VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("curl", true);
        varFunc.setParameter("c1", -1.0);
        varFunc.setParameter("c2", 0.001 + Math.random() * 0.0199);
        xForm.addVariation(1.6 + Math.random() * 0.8, varFunc);
        xForm.setColor(0.4 + Math.random() * 0.2);
        xForm.setColorSymmetry(0.82 + Math.random() * 0.16);
        XFormTransformService.rotate(xForm, 180, false);
        XFormTransformService.localTranslate(xForm, 1.0, 0.0, true);
        xForm.getModifiedWeights()[0] = 0.0;
        xForm.getModifiedWeights()[1] = 1.0;
        xForm.getModifiedWeights()[2] = 0.0;
        xForm.getModifiedWeights()[3] = 0.0;
    }
    // 2nd xForm
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(0.05 + Math.random() * 0.35);
        String[] fncNames = { "juliascope", "julia3D", "julia3Dz", "julian" };
        VariationFunc varFunc = VariationFuncList.getVariationFuncInstance(fncNames[Tools.randomInt(fncNames.length)], true);
        varFunc.setParameter("power", Math.random() < 0.33 ? 2 : Math.random() < 0.5 ? 3 : 4);
        xForm.addVariation(1.0, varFunc);
        xForm.setColor(0.5 + Math.random() * 0.5);
        xForm.setColorSymmetry(0.5);
        xForm.getModifiedWeights()[0] = 1.0;
        xForm.getModifiedWeights()[1] = 0.0;
        xForm.getModifiedWeights()[2] = 1.0;
        xForm.getModifiedWeights()[3] = 1.0;
    }
    // 3rd xForm
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(0.4 + Math.random() * 0.2);
        String fncName;
        if (Math.random() < 0.33) {
            fncName = "bubble";
        } else {
            fncName = ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL[Tools.randomInt(ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL.length)];
        }
        xForm.addVariation(0.01 + Math.random() * 0.04, VariationFuncList.getVariationFuncInstance(fncName, true));
        xForm.addVariation(5.0 + Math.random() * 10.0, VariationFuncList.getVariationFuncInstance("pre_blur", true));
        xForm.setColor(0.1 + Math.random() * 0.3);
        xForm.setColorSymmetry(0);
        XFormTransformService.localTranslate(xForm, -1.0, 0.0, true);
        xForm.getModifiedWeights()[0] = 1.0;
        xForm.getModifiedWeights()[1] = 1.0;
        xForm.getModifiedWeights()[2] = 0.0;
        xForm.getModifiedWeights()[3] = 0.0;
    }
    // 4th xForm
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(0.4 + Math.random() * 0.2);
        String fncName = ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL[Tools.randomInt(ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL.length)];
        xForm.addVariation(0.01 + Math.random() * 0.04, VariationFuncList.getVariationFuncInstance(fncName, true));
        if (Math.random() > 0.5) {
            xForm.addVariation((0.01 + Math.random() * 0.04) * 0.5, VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname(), true)).setPriority(-1);
        }
        xForm.setColor(0.1 + Math.random() * 0.3);
        xForm.setColorSymmetry(0);
        XFormTransformService.rotate(xForm, Math.random() * 360.0, true);
        XFormTransformService.scale(xForm, 1.1 + Math.random() * 3.0, true, true, true);
        xForm.getModifiedWeights()[0] = 1.0;
        xForm.getModifiedWeights()[1] = 1.0;
        xForm.getModifiedWeights()[2] = 1.0;
        xForm.getModifiedWeights()[3] = 1.0;
    }
    return flame;
}
Also used : XForm(org.jwildfire.create.tina.base.XForm) Layer(org.jwildfire.create.tina.base.Layer) VariationFunc(org.jwildfire.create.tina.variation.VariationFunc) Flame(org.jwildfire.create.tina.base.Flame)

Example 20 with Flame

use of org.jwildfire.create.tina.base.Flame in project JWildfire by thargor6.

the class BubblesRandomFlameGenerator method prepareFlame.

@Override
public Flame prepareFlame(RandomFlameGeneratorState pState) {
    Flame flame = new Flame();
    Layer layer = flame.getFirstLayer();
    flame.setCentreX(0.0);
    flame.setCentreY(0.0);
    flame.setCamZoom(0.5);
    flame.setPixelsPerUnit(200);
    layer.getFinalXForms().clear();
    layer.getXForms().clear();
    int fncCount = ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL.length;
    // 1st xForm
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(12.0 + Math.random() * 80.0);
        xForm.addVariation(2 + Math.random() * 4, VariationFuncList.getVariationFuncInstance("spherical", true));
        String fName;
        if (Math.random() < 0.15) {
            fName = ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL[Tools.randomInt(fncCount)];
        } else {
            fName = Math.random() < 0.8 ? "eyefish" : "fisheye";
        }
        xForm.addVariation(0.05 + Math.random() * 0.5, VariationFuncList.getVariationFuncInstance(fName, true));
        xForm.setColorSymmetry(0.991 + Math.random() * 0.08);
        XFormTransformService.scale(xForm, 0.5 - Math.random() * 0.5, true, true, false);
        XFormTransformService.rotate(xForm, 180 - Math.random() * 360.0, false);
        XFormTransformService.localTranslate(xForm, 3.0 - 6.0 * Math.random(), 3.0 - 6.0 * Math.random(), false);
        if (Math.random() < 0.33) {
            XFormTransformService.localTranslate(xForm, 0.75 - 1.5 * Math.random(), 0.75 - 1.5 * Math.random(), true);
        }
    }
    // 2nd xForm
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(0.5 + Math.random() * 0.8);
        if (Math.random() < 0.05) {
            xForm.addVariation(0.01 + Math.random() * 0.4, VariationFuncList.getVariationFuncInstance("bubble", true));
            VariationFunc checks = VariationFuncList.getVariationFuncInstance("checks", true);
            checks.setParameter("size", 5.0);
            checks.setParameter("x", 3.0);
            checks.setParameter("y", 3.0);
            xForm.addVariation(0.01 + Math.random() * 0.04, checks);
        } else {
            xForm.addVariation(0.1 + Math.random() * 0.5, VariationFuncList.getVariationFuncInstance("bubble", true));
        }
        xForm.addVariation(4 + Math.random() * 2, VariationFuncList.getVariationFuncInstance("pre_blur", true));
        xForm.setColorSymmetry(-0.5);
        XFormTransformService.scale(xForm, 1.1 + Math.random() * 1.9, true, true, false);
        XFormTransformService.localTranslate(xForm, 0.75 - 1.50 * Math.random(), 0.75 - 1.50 * Math.random(), false);
        XFormTransformService.rotate(xForm, 30 - Math.random() * 60.0, false);
    }
    // 3rd xForm
    if (Math.random() > 0.25) {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(0.5 + Math.random() * 1.5);
        String fName;
        if (Math.random() > 0.8) {
            fName = ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL[Tools.randomInt(fncCount)];
        } else {
            fName = Math.random() > 0.5 ? "linear3D" : "noise";
        }
        xForm.addVariation(0.5, VariationFuncList.getVariationFuncInstance(fName, true));
        xForm.setColorSymmetry(-0.5);
        XFormTransformService.rotate(xForm, 30.0 - Math.random() * 60.0, false);
        if (Math.random() < 0.5) {
            XFormTransformService.scale(xForm, 0.5 + Math.random() * 1.5, true, true, false);
        }
    }
    // 4th xForm
    if (Math.random() > 0.5) {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(0.5 + Math.random() * 1.5);
        String fName;
        if (Math.random() > 0.8) {
            fName = Math.random() > 0.75 ? VariationFuncList.getRandomVariationname() : ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL[Tools.randomInt(fncCount)];
        } else {
            fName = Math.random() > 0.5 ? "linear3D" : "gaussian_blur";
        }
        xForm.addVariation(0.5, VariationFuncList.getVariationFuncInstance(fName, true));
        xForm.setColorSymmetry(-0.5);
        XFormTransformService.rotate(xForm, 30.0 - Math.random() * 60.0, false);
        if (Math.random() < 0.5) {
            XFormTransformService.scale(xForm, 0.15 + Math.random() * 1.25, true, true, false);
        }
    }
    flame.getFirstLayer().distributeColors();
    return flame;
}
Also used : XForm(org.jwildfire.create.tina.base.XForm) Layer(org.jwildfire.create.tina.base.Layer) VariationFunc(org.jwildfire.create.tina.variation.VariationFunc) Flame(org.jwildfire.create.tina.base.Flame)

Aggregations

Flame (org.jwildfire.create.tina.base.Flame)232 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)109 Layer (org.jwildfire.create.tina.base.Layer)63 XForm (org.jwildfire.create.tina.base.XForm)55 VariationFunc (org.jwildfire.create.tina.variation.VariationFunc)30 FlameRenderer (org.jwildfire.create.tina.render.FlameRenderer)27 FlameReader (org.jwildfire.create.tina.io.FlameReader)24 File (java.io.File)21 RenderInfo (org.jwildfire.create.tina.render.RenderInfo)21 ArrayList (java.util.ArrayList)17 JFileChooser (javax.swing.JFileChooser)17 SimpleImage (org.jwildfire.image.SimpleImage)17 FlameWriter (org.jwildfire.create.tina.io.FlameWriter)15 Rectangle (java.awt.Rectangle)10 Clipboard (java.awt.datatransfer.Clipboard)10 FlamePanel (org.jwildfire.create.tina.swing.flamepanel.FlamePanel)9 RGBPalette (org.jwildfire.create.tina.palette.RGBPalette)8 Transferable (java.awt.datatransfer.Transferable)7 ResolutionProfile (org.jwildfire.base.ResolutionProfile)7 Test (org.junit.Test)6