Search in sources :

Example 1 with Flame

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

the class RasterRandomFlameGenerator method prepareFlame.

@Override
public Flame prepareFlame(RandomFlameGeneratorState pState) {
    Flame flame = new Flame();
    Layer layer = flame.getFirstLayer();
    flame.setCentreX(2.45);
    flame.setCentreY(1.37);
    flame.setCamZoom(1.25 + Math.random() * 0.5);
    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(0.05);
        xForm.setColor(0);
        xForm.setColorSymmetry(0.89103422);
        xForm.setMaterial(0);
        xForm.setMaterialSpeed(0);
        // a
        xForm.setCoeff00(1);
        // b
        xForm.setCoeff10(0);
        // e
        xForm.setCoeff20(0);
        // c
        xForm.setCoeff01(0);
        // d
        xForm.setCoeff11(1);
        // f
        xForm.setCoeff21(0);
        xForm.setPostCoeff00(0.45811152);
        xForm.setPostCoeff10(0);
        xForm.setPostCoeff01(0);
        xForm.setPostCoeff11(0.45811152);
        xForm.setPostCoeff20(0);
        xForm.setPostCoeff21(0);
        // variation 1
        {
            VariationFunc varFunc = VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname(), true);
            xForm.addVariation(0.5 + Math.random() * 0.65, varFunc);
        }
        // variation 2
        if (Math.random() < 0.20) {
            VariationFunc varFunc = VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname(), true);
            xForm.addVariation(0.4 + Math.random() * 0.5, varFunc);
        }
        // variation 3
        if (Math.random() < 0.10) {
            VariationFunc varFunc = VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname(), true);
            xForm.addVariation(0.3 + Math.random() * 0.4, varFunc);
        }
        // set default edit plane
        flame.setEditPlane(EditPlane.XY);
        // XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, false);
        if (Math.random() < 0.5) {
            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.15 - Math.random() * 0.65, 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(0.5);
        xForm.setColor(0.33333333);
        xForm.setColorSymmetry(0.62668861);
        xForm.setMaterial(0);
        xForm.setMaterialSpeed(0);
        // a
        xForm.setCoeff00(1);
        // b
        xForm.setCoeff10(0);
        // e
        xForm.setCoeff20(0);
        // c
        xForm.setCoeff01(0);
        // d
        xForm.setCoeff11(1);
        // f
        xForm.setCoeff21(0);
        xForm.setPostCoeff00(1);
        xForm.setPostCoeff10(0);
        xForm.setPostCoeff01(0);
        xForm.setPostCoeff11(1);
        xForm.setPostCoeff20(1);
        xForm.setPostCoeff21(0);
        // variation 1
        xForm.addVariation(1, VariationFuncList.getVariationFuncInstance("linear3D", 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 3
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(0.5);
        xForm.setColor(0.66666667);
        xForm.setColorSymmetry(0.33786964);
        xForm.setMaterial(0);
        xForm.setMaterialSpeed(0);
        // a
        xForm.setCoeff00(1);
        // b
        xForm.setCoeff10(0);
        // e
        xForm.setCoeff20(0);
        // c
        xForm.setCoeff01(0);
        // d
        xForm.setCoeff11(1);
        // f
        xForm.setCoeff21(0);
        xForm.setPostCoeff00(1);
        xForm.setPostCoeff10(0);
        xForm.setPostCoeff01(0);
        xForm.setPostCoeff11(1);
        xForm.setPostCoeff20(0);
        xForm.setPostCoeff21(1);
        // variation 1
        xForm.addVariation(1, VariationFuncList.getVariationFuncInstance("linear3D", 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 4
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(0.05);
        xForm.setColor(1);
        xForm.setColorSymmetry(0.95291095);
        xForm.setMaterial(0);
        xForm.setMaterialSpeed(0);
        // a
        xForm.setCoeff00(1);
        // b
        xForm.setCoeff10(0);
        // e
        xForm.setCoeff20(0);
        // c
        xForm.setCoeff01(0);
        // d
        xForm.setCoeff11(1);
        // f
        xForm.setCoeff21(0);
        xForm.setPostCoeff00(0.0423868);
        xForm.setPostCoeff10(0.14299816);
        xForm.setPostCoeff01(-0.14299816);
        xForm.setPostCoeff11(0.0423868);
        xForm.setPostCoeff20(0.5);
        xForm.setPostCoeff21(0.5);
        // variation 1
        {
            VariationFunc varFunc = VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname(), true);
            xForm.addVariation(0.4 + Math.random() * 0.65, varFunc);
        }
        // variation 2
        if (Math.random() < 0.10) {
            VariationFunc varFunc = VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname(), true);
            xForm.addVariation(0.4 + Math.random() * 0.5, varFunc);
        }
        // variation 3
        if (Math.random() < 0.05) {
            VariationFunc varFunc = VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname(), true);
            xForm.addVariation(0.3 + Math.random() * 0.4, varFunc);
        }
        // set default edit plane
        flame.setEditPlane(EditPlane.XY);
        // XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, false);
        if (Math.random() < 0.25) {
            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.15 - Math.random() * 0.75, true, true, true);
        XFormTransformService.rotate(xForm, 360.0 * Math.random(), true);
        XFormTransformService.localTranslate(xForm, 0.25 - 0.5 * Math.random(), 0.25 - 0.5 * Math.random(), true);
    }
    flame.getFirstLayer().randomizeColors();
    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 2 with Flame

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

the class RaysRandomFlameGenerator method prepareFlame.

@Override
public Flame prepareFlame(RandomFlameGeneratorState pState) {
    Flame flame = new Flame();
    Layer layer = flame.getFirstLayer();
    flame.setCamRoll(Math.random() * 360.0);
    flame.setCamZoom(1.0 + Math.random() * 0.75);
    flame.setGamma(1.2 + Math.random() * 0.8);
    flame.setGammaThreshold(Math.random() * 0.15);
    flame.setBrightness(2.5 + Math.random() * 1.5);
    flame.setCamPitch(0);
    flame.setCamYaw(0);
    flame.setCamPerspective(0);
    flame.setCentreX(0.0);
    flame.setCentreY(0.0);
    flame.setPixelsPerUnit(200);
    layer.getFinalXForms().clear();
    layer.getXForms().clear();
    // create a random gradient
    layer.setPalette(new TwoColorsRandomGradientGenerator().generatePalette(2, true, true));
    // create transform 1
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(0.1 + Math.random() * 0.7);
        xForm.setColor(0);
        xForm.setColorSymmetry(0);
        // a
        xForm.setCoeff00(-0.43686351);
        // b
        xForm.setCoeff10(0.63649767);
        // e
        xForm.setCoeff20(0.7325555);
        // c
        xForm.setCoeff01(-0.59864436);
        // d
        xForm.setCoeff11(-0.50111868);
        // f
        xForm.setCoeff21(0.08008955);
        xForm.setPostCoeff00(1);
        xForm.setPostCoeff10(0);
        xForm.setPostCoeff01(0);
        xForm.setPostCoeff11(1);
        xForm.setPostCoeff20(0);
        xForm.setPostCoeff21(0);
        // variation 1
        xForm.addVariation(0.125 + Math.random() * 0.125, VariationFuncList.getVariationFuncInstance("linear", true));
        // variation 2
        {
            VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("julian", true);
            varFunc.setParameter("power", 3);
            varFunc.setParameter("dist", 1);
            xForm.addVariation(0.6 + Math.random() * 0.4, varFunc);
        }
        // variation 3
        {
            VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("juliascope", true);
            varFunc.setParameter("power", 6);
            varFunc.setParameter("dist", 1);
            xForm.addVariation(0.6 + Math.random() * 0.3, varFunc);
        }
        XFormTransformService.localTranslate(xForm, 1.0 - 2.0 * Math.random(), 1.0 - 2.0 * Math.random(), false);
        XFormTransformService.scale(xForm, 0.9 + Math.random() * 0.5, true, true, false);
        XFormTransformService.rotate(xForm, 360.0 * Math.random(), false);
    }
    // create transform 2
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(0.23272111);
        xForm.setColor(0.8);
        xForm.setColorSymmetry(0);
        // a
        xForm.setCoeff00(-0.15514012);
        // b
        xForm.setCoeff10(0.20816567);
        // e
        xForm.setCoeff20(0.19004075);
        // c
        xForm.setCoeff01(-0.15087636);
        // d
        xForm.setCoeff11(0.20174952);
        // f
        xForm.setCoeff21(-0.04671182);
        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("linear", true));
        // variation 2
        {
            VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("juliascope", true);
            varFunc.setParameter("power", 2);
            varFunc.setParameter("dist", 1);
            xForm.addVariation(0.25 + Math.random() * 0.5, varFunc);
        }
        String fName;
        if (Math.random() < 0.33) {
            int idx = ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL.length;
            fName = ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL[Tools.randomInt(idx)];
        } else {
            fName = VariationFuncList.getRandomVariationname();
        }
        xForm.addVariation(0.18 - Math.random() * 0.36, VariationFuncList.getVariationFuncInstance(fName, true));
        XFormTransformService.localTranslate(xForm, 1.0 - 2.0 * Math.random(), 1.0 - 2.0 * Math.random(), false);
        XFormTransformService.scale(xForm, 0.9 + Math.random() * 0.5, true, true, false);
        XFormTransformService.rotate(xForm, 360.0 * Math.random(), false);
    }
    // create transform 3
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(0.04166667);
        xForm.setColor(0.1);
        xForm.setColorSymmetry(0.75);
        // a
        xForm.setCoeff00(0.92931929);
        // b
        xForm.setCoeff10(0.17076568);
        // e
        xForm.setCoeff20(0.15869232);
        // c
        xForm.setCoeff01(-0.02999303);
        // d
        xForm.setCoeff11(0.67104838);
        // f
        xForm.setCoeff21(-0.19510192);
        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(Math.random() > 0.5 ? "linear" : getRandomVariationName(), true));
    }
    // create transform 4
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(0.04166667);
        xForm.setColor(0.15);
        xForm.setColorSymmetry(0.75);
        // a
        xForm.setCoeff00(0.53699507);
        // b
        xForm.setCoeff10(0.12206942);
        // e
        xForm.setCoeff20(-0.0380713);
        // c
        xForm.setCoeff01(0.23469299);
        // d
        xForm.setCoeff11(0.79862481);
        // f
        xForm.setCoeff21(0.04291273);
        xForm.setPostCoeff00(1);
        xForm.setPostCoeff10(0);
        xForm.setPostCoeff01(0);
        xForm.setPostCoeff11(1);
        xForm.setPostCoeff20(0);
        xForm.setPostCoeff21(0);
        xForm.addVariation(1, VariationFuncList.getVariationFuncInstance(Math.random() > 0.5 ? "linear" : getRandomVariationName(), true));
    }
    // create transform 5
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(0.04166667);
        xForm.setColor(0.2);
        xForm.setColorSymmetry(0);
        // a
        xForm.setCoeff00(0.89779523);
        // b
        xForm.setCoeff10(-0.23112747);
        // e
        xForm.setCoeff20(-0.4497571);
        // c
        xForm.setCoeff01(0.1734196);
        // d
        xForm.setCoeff11(0.94619577);
        // f
        xForm.setCoeff21(-0.0672393);
        xForm.setPostCoeff00(1);
        xForm.setPostCoeff10(0);
        xForm.setPostCoeff01(0);
        xForm.setPostCoeff11(1);
        xForm.setPostCoeff20(0);
        xForm.setPostCoeff21(0);
        xForm.addVariation(1, VariationFuncList.getVariationFuncInstance(Math.random() > 0.5 ? "linear" : getRandomVariationName(), true));
    }
    // create transform 6
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(0.04166667);
        xForm.setColor(0.25);
        xForm.setColorSymmetry(0);
        // a
        xForm.setCoeff00(0.70624241);
        // b
        xForm.setCoeff10(0.15652237);
        // e
        xForm.setCoeff20(0.43007701);
        // c
        xForm.setCoeff01(-0.04953437);
        // d
        xForm.setCoeff11(0.78838922);
        // f
        xForm.setCoeff21(0.21371425);
        xForm.setPostCoeff00(1);
        xForm.setPostCoeff10(0);
        xForm.setPostCoeff01(0);
        xForm.setPostCoeff11(1);
        xForm.setPostCoeff20(0);
        xForm.setPostCoeff21(0);
        xForm.addVariation(1, VariationFuncList.getVariationFuncInstance(Math.random() > 0.5 ? "linear" : getRandomVariationName(), true));
    }
    // final transform
    if (Math.random() > 0.33) {
        XForm xForm = new XForm();
        layer.getFinalXForms().add(xForm);
        String[] finals = { "falloff2", "bwrands", "bwraps7", "cosine", "falloff3", "bwrands", "bwrands", "falloff2" };
        VariationFunc var = VariationFuncList.getVariationFuncInstance(finals[(int) (Math.random() * finals.length)], true);
        if (var.getName().equals("bwrands")) {
            var.setParameter("seed", Tools.randomInt(Short.MAX_VALUE));
            var.setParameter("minpetals", (int) (3 + Math.random() * 3));
            var.setParameter("maxpetals", (int) (6 + Math.random() * 12));
        }
        if (var.getName().equals("bwrands") || var.getName().equals("bwraps7")) {
            var.setParameter("cellsize", 1.0 - Math.random() * 0.9);
            var.setParameter("space", Math.random() * 0.2);
            if (Math.random() > 0.5) {
                var.setParameter("inner_twist", 0.2 - Math.random() * 0.4);
                var.setParameter("outer_twist", 2.0 - Math.random() * 4.0);
            }
        }
        xForm.addVariation(1, var);
    }
    return flame;
}
Also used : XForm(org.jwildfire.create.tina.base.XForm) TwoColorsRandomGradientGenerator(org.jwildfire.create.tina.randomgradient.TwoColorsRandomGradientGenerator) Layer(org.jwildfire.create.tina.base.Layer) VariationFunc(org.jwildfire.create.tina.variation.VariationFunc) Flame(org.jwildfire.create.tina.base.Flame)

Example 3 with Flame

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

the class SierpinskyRandomFlameGenerator method prepareFlame.

@Override
public Flame prepareFlame(RandomFlameGeneratorState pState) {
    Flame flame = new Flame();
    Layer layer = flame.getFirstLayer();
    flame.setCentreX(0.0);
    flame.setCamRoll(Tools.randomInt(8) * -45.0);
    flame.setCentreY(0.0);
    flame.setPixelsPerUnit(200);
    layer.getFinalXForms().clear();
    layer.getXForms().clear();
    flame.setCamZoom(4.56);
    double[] posx = { -0.5, 0.5, 0.5, -0.5 };
    double[] posy = { -0.5, -0.5, 0.5, 0.5 };
    for (int i = 0; i < posx.length; i++) {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(0.5);
        xForm.setCoeff20(posx[i]);
        xForm.setCoeff21(posy[i]);
        xForm.setColor(Math.random());
        xForm.setColorSymmetry(Math.random());
        XFormTransformService.scale(xForm, 1.0, true, true);
        if (i == posx.length - 1) {
            if (Math.random() < 0.5) {
                xForm.addVariation(0.5, VariationFuncList.getVariationFuncInstance(Math.random() < 0.25 ? "dc_linear" : "linear3D", true));
                XFormTransformService.rotate(xForm, 5.0 - 10.0 * Math.random());
                XFormTransformService.localTranslate(xForm, 0.1 - 0.2 * Math.random(), 0.1 - 0.2 * Math.random());
                XFormTransformService.scale(xForm, 1.0 - 0.1 * Math.random(), Math.random() < 0.75, Math.random() > 0.25);
            }
            String fncName = ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL[(int) (Math.random() * ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL.length)];
            double amount;
            if (Math.random() < 0.33) {
                amount = 0.5 - Math.random();
            } else if (Math.random() < 0.67) {
                amount = 0.25 + 0.5 * Math.random();
            } else {
                amount = 0.5;
            }
            xForm.addVariation(amount, VariationFuncList.getVariationFuncInstance(fncName, true));
            if (Math.random() < 0.5) {
                XFormTransformService.scale(xForm, 1.0 - 0.1 * Math.random(), Math.random() < 0.75, Math.random() > 0.25);
            }
        } else {
            xForm.addVariation(0.5, VariationFuncList.getVariationFuncInstance(Math.random() < 0.25 ? "dc_linear" : "linear3D", true));
        }
    }
    return flame;
}
Also used : XForm(org.jwildfire.create.tina.base.XForm) Layer(org.jwildfire.create.tina.base.Layer) Flame(org.jwildfire.create.tina.base.Flame)

Example 4 with Flame

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

the class SimpleTilingRandomFlameGenerator 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.setPixelsPerUnit(200);
    layer.getFinalXForms().clear();
    layer.getXForms().clear();
    // init
    // 1st XForm
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(0.4 + Math.random() * 50.0);
        xForm.addVariation(0.01 + 0.4 * Math.random(), VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname(), true));
        xForm.addVariation(0.02 + 0.2 * Math.random(), VariationFuncList.getVariationFuncInstance("linear3D", true));
        xForm.setColor(0.87 + Math.random() * 0.1);
    }
    // 2nd XForm
    boolean twoPrimaryXForms = Math.random() > 0.33;
    boolean linkedXForms = Math.random() < 0.4;
    if (twoPrimaryXForms) {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(0.4 + Math.random() * 72.0);
        xForm.addVariation(1.0, VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname(), true));
        xForm.setColorSymmetry(-1);
        xForm.setColor(0.89 + Math.random() * 0.06);
        XFormTransformService.scale(xForm, 0.75 + Math.random() * 0.25, Math.random() > 0.125, Math.random() < 0.875);
        XFormTransformService.rotate(xForm, -180.0 + Math.random() * 360.0);
    }
    // Tiling
    int nForms = 2 + Tools.randomInt(5);
    for (int i = 0; i < nForms; i++) {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(0.25 + Math.random() * 0.5);
        xForm.addVariation(0.5 + Math.random() * 0.5, VariationFuncList.getVariationFuncInstance("linear3D", true));
        if (Math.random() > 0.75) {
            XFormTransformService.scale(xForm, 0.125 + Math.random() * 0.5, Math.random() > 0.5, Math.random() < 0.5);
        } else {
            XFormTransformService.scale(xForm, 0.75 + Math.random() * 0.25, Math.random() > 0.5, Math.random() < 0.5);
        }
        XFormTransformService.rotate(xForm, -45.0 + Math.random() * 90.0);
        XFormTransformService.localTranslate(xForm, -2.0 + i * 0.5 + Math.random() * 4.0, -2.0 + i * 0.5 + Math.random() * 4.0);
        xForm.setColor(Math.random());
    }
    if (linkedXForms) {
        for (int i = 0; i < layer.getXForms().size(); i++) {
            if (i == 0) {
                for (int j = 0; j < layer.getXForms().size(); j++) {
                    layer.getXForms().get(i).getModifiedWeights()[j] = (j != 1) ? 0 : 1;
                }
            } else {
                for (int j = 0; j < layer.getXForms().size(); j++) {
                    layer.getXForms().get(i).getModifiedWeights()[j] = (j != 1) ? 1 : 0;
                }
            }
        }
    } else {
        for (int i = 0; i < layer.getXForms().size(); i++) {
            if (i == 0) {
                double wg = Math.random() * 12.0;
                if (Math.random() < 0.25) {
                    wg = 0.0;
                }
                for (int j = 0; j < layer.getXForms().size(); j++) {
                    layer.getXForms().get(i).getModifiedWeights()[j] = (j != 1) ? wg : 1;
                }
            } else {
                double wg = Math.random() * 12.0;
                if (Math.random() < 0.25) {
                    wg = 0.0;
                }
                for (int j = 0; j < layer.getXForms().size(); j++) {
                    layer.getXForms().get(i).getModifiedWeights()[j] = (j != 1) ? 1 : wg;
                }
            }
        }
    }
    return flame;
}
Also used : XForm(org.jwildfire.create.tina.base.XForm) Layer(org.jwildfire.create.tina.base.Layer) Flame(org.jwildfire.create.tina.base.Flame)

Example 5 with Flame

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

the class SolidExperimentalRandomFlameGenerator method prepareFlame.

@Override
public Flame prepareFlame(RandomFlameGeneratorState pState) {
    Flame flame = new Flame();
    Layer layer = flame.getFirstLayer();
    flame.setCamRoll(0);
    flame.setCamPitch(90.0 - Math.random() * 180.0);
    flame.setCamYaw(30.0 - Math.random() * 60.0);
    flame.setCamPerspective(Math.random() * 0.2);
    flame.setWidth(601);
    flame.setHeight(338);
    flame.setPixelsPerUnit(92.48366013);
    flame.setCamZoom(0.2 + Math.random() * 0.4);
    randomizeSolidRenderingSettings(flame);
    layer.getFinalXForms().clear();
    layer.getXForms().clear();
    // create transform 1
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(Math.random() < 0.3 ? 0.5 : 0.25 + Math.random());
        xForm.setColor(Math.random());
        xForm.setColorSymmetry(1.0 - 2 * Math.random());
        xForm.setMaterial(0);
        xForm.setMaterialSpeed(0);
        // a
        xForm.setXYCoeff00(0.58839186);
        // b
        xForm.setXYCoeff10(-0.93477004);
        // e
        xForm.setXYCoeff20(0.88339811);
        // c
        xForm.setXYCoeff01(0.93477004);
        // d
        xForm.setXYCoeff11(0.58839186);
        // f
        xForm.setXYCoeff21(0.59357541);
        xForm.setXYPostCoeff00(-1);
        xForm.setXYPostCoeff10(0.0000000000000001);
        xForm.setXYPostCoeff01(-0.0000000000000001);
        xForm.setXYPostCoeff11(-1);
        xForm.setXYPostCoeff20(0);
        xForm.setXYPostCoeff21(0);
        xForm.setYZCoeff00(1);
        xForm.setYZCoeff10(0);
        xForm.setYZCoeff20(0);
        xForm.setYZCoeff01(0);
        xForm.setYZCoeff11(1);
        xForm.setYZCoeff21(0);
        xForm.setYZPostCoeff00(-0.00074102);
        xForm.setYZPostCoeff10(0.99999973);
        xForm.setYZPostCoeff01(-0.99999973);
        xForm.setYZPostCoeff11(-0.00074102);
        xForm.setYZPostCoeff20(0);
        xForm.setYZPostCoeff21(0);
        xForm.setZXCoeff00(1);
        xForm.setZXCoeff10(0);
        xForm.setZXCoeff20(0);
        xForm.setZXCoeff01(0);
        xForm.setZXCoeff11(1);
        xForm.setZXCoeff21(0);
        xForm.setZXPostCoeff00(1);
        xForm.setZXPostCoeff10(0);
        xForm.setZXPostCoeff01(0);
        xForm.setZXPostCoeff11(1);
        xForm.setZXPostCoeff20(0);
        xForm.setZXPostCoeff21(0);
        // variation 1
        if (Math.random() < 0.85) {
            VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("hypertile3D2", true);
            if (Math.random() > 0.75) {
                varFunc.setParameter("p", 4 + Math.random() * 3.0);
                varFunc.setParameter("q", 4 + Math.random() * 2.0);
            } else {
                varFunc.setParameter("p", 5);
                varFunc.setParameter("q", 4);
            }
            xForm.addVariation(0.25 + Math.random() * 0.75, varFunc);
        } else {
            xForm.addVariation(0.25 + Math.random() * 0.75, getRandomVariation());
        }
        // 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(0.5);
        xForm.setColor(Math.random());
        xForm.setColorSymmetry(1.0 - 2 * Math.random());
        xForm.setMaterial(0);
        xForm.setMaterialSpeed(0);
        // a
        xForm.setCoeff00(1);
        // b
        xForm.setCoeff10(0);
        // e
        xForm.setCoeff20(0);
        // c
        xForm.setCoeff01(0);
        // d
        xForm.setCoeff11(1);
        // f
        xForm.setCoeff21(0);
        xForm.setPostCoeff00(1);
        xForm.setPostCoeff10(0);
        xForm.setPostCoeff01(0);
        xForm.setPostCoeff11(1);
        xForm.setPostCoeff20(0);
        xForm.setPostCoeff21(0);
        if (Math.random() > 0.125) {
            xForm.setDrawMode(DrawMode.HIDDEN);
        }
        // variation 1
        xForm.addVariation(0.2 + Math.random() * 0.5, getRandom3DShape());
        // set default edit plane
        flame.setEditPlane(Math.random() > 0.666 ? EditPlane.XY : Math.random() < 0.5 ? EditPlane.YZ : EditPlane.ZX);
        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);
        if (Math.random() > 0.5) {
            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 final transform 1
    if (Math.random() > 0.666) {
        XForm xForm = new XForm();
        layer.getFinalXForms().add(xForm);
        xForm.setWeight(0);
        xForm.setColor(0);
        xForm.setColorSymmetry(0);
        xForm.setMaterial(0);
        xForm.setMaterialSpeed(0);
        // a
        xForm.setCoeff00(1);
        // b
        xForm.setCoeff10(0);
        // e
        xForm.setCoeff20(0);
        // c
        xForm.setCoeff01(0);
        // d
        xForm.setCoeff11(1);
        // f
        xForm.setCoeff21(0);
        xForm.setPostCoeff00(1);
        xForm.setPostCoeff10(0);
        xForm.setPostCoeff01(0);
        xForm.setPostCoeff11(1);
        xForm.setPostCoeff20(0);
        xForm.setPostCoeff21(0);
        // variation 1
        {
            xForm.addVariation(0.75 + Math.random() * 0.25, getRandomVariation());
        }
        // variation 2
        if (Math.random() > 0.5) {
            xForm.addVariation(0.25 + Math.random() * 0.25, VariationFuncList.getVariationFuncInstance("linear3D", true));
        }
        // set default edit plane
        flame.setEditPlane(EditPlane.XY);
        if (Math.random() > 0.5) {
            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);
        }
        if (Math.random() > 0.5) {
            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)

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