Search in sources :

Example 41 with VariationFunc

use of org.jwildfire.create.tina.variation.VariationFunc in project JWildfire by thargor6.

the class Bubbles3DRandomFlameGenerator 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.setCamPitch(49.0);
    flame.setCamYaw(12.0);
    flame.setCamPerspective(0.12);
    flame.setPixelsPerUnit(200);
    layer.getFinalXForms().clear();
    layer.getXForms().clear();
    // 1st xForm
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(1.0 + Math.random() * 100.0);
        if (Math.random() < 0.75) {
            xForm.addVariation(0.05 + Math.random() * 0.5, VariationFuncList.getVariationFuncInstance("bubble", true));
        } else {
            VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("bubble2", true);
            varFunc.setParameter("z", -0.5 - Math.random() * 2.0);
            xForm.addVariation(0.25 + Math.random() * 0.5, varFunc);
        }
        xForm.addVariation(0.5 + 1.5 * Math.random(), VariationFuncList.getVariationFuncInstance("pre_blur", true));
        final String[] workingFncList = { "fan2", "blade", "blade3D", "blob", "blob3D", "bwraps7", "cell", "cannabiscurve_wf", "cloverleaf_wf", "cos", "cot", "coth", "cross", "csch", "diamond", "disc", "edisc", "epispiral_wf", "fan", "fisheye", "eyefish", "flux", "heart", "julia", "julian", "juliascope", "log", "parabola", "power", "epispiral", "pre_subflame_wf", "rectangles", "rose_wf", "sech", "separation", "split", "truchet", "wedge", "zcone" };
        final String[] fncList = Math.random() < 0.5 ? workingFncList : ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL;
        VariationFunc varFunc;
        if (Math.random() < 0.5) {
            varFunc = VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname());
        } else {
            varFunc = VariationFuncList.getVariationFuncInstance(fncList[Tools.randomInt(fncList.length)], true);
        }
        xForm.addVariation(-0.02 + 0.04 * Math.random(), varFunc);
        double shape = Math.random();
        if (shape < 0.125) {
            xForm.addVariation(0.001 + Math.random() * 0.01, VariationFuncList.getVariationFuncInstance("hexes", true));
        } else if (shape < 0.25) {
            xForm.addVariation(0.001 + Math.random() * 0.01, VariationFuncList.getVariationFuncInstance("oscilloscope", true));
        } else if (shape < 0.5) {
            xForm.addVariation(0.001 + Math.random() * 0.01, VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname(), true));
        }
        if (Math.random() > 0.33) {
            XFormTransformService.globalTranslate(xForm, -1.0 + 2.0 * Math.random(), -1.0 + 2.0 * Math.random(), true);
        }
        if (Math.random() > 0.33) {
            XFormTransformService.rotate(xForm, -32.0 + Math.random() * 72.0, false);
        }
        if (Math.random() > 0.33) {
            XFormTransformService.scale(xForm, 0.8 + Math.random() * 0.4, true, false);
        }
        xForm.setColor(0.0);
        xForm.setColorSymmetry(0.0);
    }
    // 2nd xForm
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(1.0 + Math.random() * 50.0);
        int fncCount = ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL.length;
        String fncName = Math.random() > 0.5 ? ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL[Tools.randomInt(fncCount)] : "eyefish";
        xForm.addVariation(-1.5 + 2 * Math.random() * 3.0, VariationFuncList.getVariationFuncInstance(fncName, true));
        xForm.addVariation(1.0 - 3.5 * Math.random(), VariationFuncList.getVariationFuncInstance("hemisphere", true));
        xForm.setColor(0.0);
        xForm.setColorSymmetry(0.0);
        if (Math.random() > 0.33) {
            XFormTransformService.globalTranslate(xForm, -3.0 + 62.0 * Math.random(), -3.0 + 6.0 * Math.random(), false);
        }
        if (Math.random() > 0.33) {
            XFormTransformService.rotate(xForm, -32.0 + Math.random() * 72.0, false);
        }
        if (Math.random() > 0.33) {
            XFormTransformService.scale(xForm, 0.8 + Math.random() * 0.4, true, false);
        }
    }
    // 3rd xForm
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(1.0 + Math.random() * 100);
        VariationFunc varFunc = VariationFuncList.getVariationFuncInstance(Math.random() > 0.5 ? "julia3Dz" : "julia3D", true);
        int idx = Math.random() > 0.5 ? 2 : (int) (-20 + Math.random() * 40);
        if (idx == 0 || idx == 1) {
            idx = 2;
        }
        varFunc.setParameter("power", (double) idx);
        xForm.addVariation(1.0, varFunc);
        xForm.setColor(0.0);
        xForm.setColorSymmetry(0.0);
        XFormTransformService.globalTranslate(xForm, -1.0 + 2.0 * Math.random(), -3.0 + 6.0 * Math.random(), false);
        XFormTransformService.globalTranslate(xForm, -0.1 + 0.2 * Math.random(), -0.1 + 0.2 * Math.random(), true);
        XFormTransformService.rotate(xForm, -20.0 + Math.random() * 40.0, false);
        XFormTransformService.scale(xForm, 0.8 + Math.random() * 0.4, true, true);
    }
    flame.setPreserveZ(Math.random() > 0.5);
    flame.getLayers().get(0).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 42 with VariationFunc

use of org.jwildfire.create.tina.variation.VariationFunc in project JWildfire by thargor6.

the class DuckiesRandomFlameGenerator 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();
    // 1st xForm
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(0.5 + Math.random());
        xForm.addVariation(1.5 + Math.random(), VariationFuncList.getVariationFuncInstance(Math.random() < 0.12 ? VariationFuncList.getRandomVariationname() : "spherical", true));
        xForm.setColorSymmetry(-0.5);
        XFormTransformService.localTranslate(xForm, 0.75 - 5.50 * Math.random(), 0.75 - 1.50 * Math.random(), false);
        XFormTransformService.rotate(xForm, -60.0 + Math.random() * 30.0, false);
        XFormTransformService.scale(xForm, 0.1 + Math.random() * 0.4, true, true, false);
    }
    // 2nd xForm
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(1.0 + Math.random() * 100.0);
        VariationFunc varFunc = VariationFuncList.getVariationFuncInstance(Math.random() < 0.8 ? "juliascope" : "julian", true);
        varFunc.setParameter("power", Math.random() < 0.8 ? 2 : 2 + Math.random() * 10.0);
        varFunc.setParameter("dist", Math.random() < 0.8 ? 1.0 : -2.0 + 4.0 * Math.random());
        xForm.addVariation(0.5 + Math.random(), varFunc);
        xForm.setColorSymmetry(0.5);
        XFormTransformService.rotate(xForm, Math.random() * 360.0, false);
        XFormTransformService.localTranslate(xForm, 1.75 - 3.50 * Math.random(), 0.75 - 5.50 * Math.random(), false);
        XFormTransformService.scale(xForm, 1.1 + Math.random() * 2.0, true, true, false);
    }
    layer.getXForms().get(0).getModifiedWeights()[0] = 0.0;
    layer.getXForms().get(0).getModifiedWeights()[1] = 1.0;
    if (Math.random() > 0.667) {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(1.0 + Math.random() * 100.0);
        VariationFunc varFunc = VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname(), true);
        xForm.addVariation(0.25 + 1.25 * Math.random(), varFunc);
        XFormTransformService.rotate(xForm, -12.0 + Math.random() * 24.0, true);
        XFormTransformService.localTranslate(xForm, -0.125 + Math.random() * 0.25, -0.125 + Math.random() * 0.25, true);
        XFormTransformService.scale(xForm, 0.9 + Math.random() * 0.2, true, true, true);
        layer.getXForms().get(0).getModifiedWeights()[1] = 0.0;
        layer.getXForms().get(1).getModifiedWeights()[2] = 0.0;
        layer.getXForms().get(2).getModifiedWeights()[2] = 0.0;
        if (Math.random() > 0.667) {
            xForm = new XForm();
            layer.getXForms().add(xForm);
            xForm.setWeight(0.50 + Math.random() * 50.0);
            varFunc = VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname(), true);
            xForm.addVariation(0.125 + 0.75 * Math.random(), varFunc);
            XFormTransformService.rotate(xForm, -24.0 + Math.random() * 48.0, true);
            XFormTransformService.localTranslate(xForm, -0.25 + Math.random() * 0.5, -0.25 + Math.random() * 0.5, true);
            XFormTransformService.scale(xForm, 0.5 + Math.random() * 0.25, true, true, true);
            layer.getXForms().get(0).getModifiedWeights()[2] = 0.0;
            layer.getXForms().get(2).getModifiedWeights()[2] = 0.0;
            layer.getXForms().get(1).getModifiedWeights()[3] = 0.0;
            layer.getXForms().get(2).getModifiedWeights()[3] = 0.0;
            layer.getXForms().get(3).getModifiedWeights()[3] = 0.0;
        }
    }
    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 43 with VariationFunc

use of org.jwildfire.create.tina.variation.VariationFunc in project JWildfire by thargor6.

the class ExperimentalGnarlRandomFlameGenerator method prepareFlame.

@Override
public Flame prepareFlame(RandomFlameGeneratorState pState) {
    // Bases loosely on the W2R Batch Script by parrotdolphin.deviantart.com */
    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
    double scaleX = Math.random() * 0.04 + 0.04;
    if (Math.random() > 0.75) {
        scaleX = 0 - scaleX;
    }
    double scaleY = Math.random() * 0.04 + 0.04;
    if (Math.random() > 0.75) {
        scaleY = 0 - scaleY;
    } else if (Math.random() < 0.25) {
        scaleY = scaleX;
    }
    double freqX = Math.random() * 2.0 + 7.0;
    double freqY;
    if (Math.random() < 0.25) {
        freqY = freqX;
    } else {
        freqY = Math.random() * 2.0 + 7.0;
    }
    double blurAmount = 0.0025 * Math.random();
    double nonBlurAmount = 0.25 * Math.random();
    double wavesWeight = Math.random() * 10 + 75;
    double _2ndWeight = 0.5;
    double _3rdWeight = 0.5;
    double symmetry = 0.6 + Math.random() * 0.4;
    int sides = (int) (Math.random() * 11.0 + 2.0);
    // 1st XForm
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(wavesWeight);
        double varRnd = Math.random();
        VariationFunc w2;
        if (Math.random() > 0.5) {
            w2 = createExpWaves2Variation(scaleX, scaleY, freqX, freqY, varRnd);
        } else {
            if (Math.random() < 0.25) {
                w2 = GnarlRandomFlameGenerator.createWaves2Variation(scaleX, scaleY, freqX, freqY);
            } else {
                w2 = GnarlRandomFlameGenerator.createWaves2BVariation(scaleX, scaleY, freqX, freqY);
            }
        }
        xForm.addVariation(1, w2);
        switch(Tools.randomInt(36)) {
            case 0:
                xForm.addVariation(blurAmount, VariationFuncList.getVariationFuncInstance("blur", true));
                break;
            case 1:
                xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("cos", true));
                break;
            case 2:
                xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("exp", true));
                break;
            case 3:
                xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("exponential", true));
                break;
            case 4:
                xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("lazysusan", true));
                break;
            case 5:
                xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("ngon", true));
                break;
            case 6:
                xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("sech", true));
                break;
            case 7:
                xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("sinh", true));
                break;
            case 8:
                xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("epispiral_wf", true));
                break;
            case 9:
                xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("tanh", true));
                break;
            case 10:
                xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("twintrian", true));
                break;
            case 11:
                xForm.addVariation(blurAmount, VariationFuncList.getVariationFuncInstance("bubble", true));
                break;
            case 12:
                xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("epispiral", true));
                break;
            default:
                {
                    int l = ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL.length;
                    String fName = ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL[Tools.randomInt(l)];
                    xForm.addVariation(blurAmount, VariationFuncList.getVariationFuncInstance(fName, true));
                }
        }
        xForm.setColorSymmetry(symmetry);
        xForm.setColor(0.9);
        if (Math.random() > 0.5) {
            XFormTransformService.scale(xForm, 0.9 + Math.random() * 0.09, true, true);
        }
        double angle, tx, ty;
        switch(sides) {
            case 2:
                angle = -180;
                tx = Math.random() * 8 - 4;
                ty = Math.random() * 8 - 4;
                break;
            case 3:
                angle = -120;
                tx = Math.random() * 8 - 4;
                ty = Math.random() * 8 - 4;
                break;
            case 4:
                angle = -90;
                tx = Math.random() * 8 - 4;
                ty = Math.random() * 8 - 4;
                break;
            case 5:
                angle = -72;
                tx = Math.random() * 7 - 3.5;
                ty = Math.random() * 7 - 3.5;
                break;
            case 6:
                angle = -60;
                tx = Math.random() * 7 - 3.5;
                ty = Math.random() * 7 - 3.5;
                break;
            case 7:
                angle = -51.42857;
                tx = Math.random() * 6 - 3;
                ty = Math.random() * 6 - 3;
                break;
            case 8:
                angle = -135;
                tx = Math.random() * 6 - 3;
                ty = Math.random() * 6 - 3;
                break;
            case 9:
                angle = -40;
                tx = Math.random() * 5 - 2.5;
                ty = Math.random() * 5 - 2.5;
                break;
            case 10:
                angle = -36;
                tx = Math.random() * 4 - 2;
                ty = Math.random() * 4 - 2;
                break;
            case 11:
                angle = -32.73;
                tx = Math.random() * 4.2 - 3;
                ty = Math.random() * 4.2 - 3;
                break;
            case 12:
                angle = -30;
                tx = Math.random() * 4.2 - 3;
                ty = Math.random() * 4.2 - 3;
                break;
            default:
                throw new IllegalStateException();
        }
        XFormTransformService.rotate(xForm, angle);
        XFormTransformService.localTranslate(xForm, tx, ty);
    }
    // 2nd XForm
    XForm secondXForm;
    {
        XForm xForm = secondXForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(_2ndWeight);
        int f = Tools.randomInt(4);
        switch(f) {
            case 0:
                xForm.addVariation(Math.random() * 0.7 + 0.1, VariationFuncList.getVariationFuncInstance("radial_blur", true));
                break;
            case 1:
                xForm.addVariation(Math.random() * 0.7 + 0.3, VariationFuncList.getVariationFuncInstance("bubble", true));
                xForm.addVariation(Math.random() * 0.7 + 0.1, VariationFuncList.getVariationFuncInstance("radial_blur", true));
                break;
            case 2:
                xForm.addVariation(Math.random() * 0.1, VariationFuncList.getVariationFuncInstance("radial_blur", true));
                JuliaNFunc juliaN = (JuliaNFunc) VariationFuncList.getVariationFuncInstance("julian", true);
                juliaN.setParameter("power", 50 - Math.random() * 100);
                juliaN.setParameter("dist", Math.random() * 10 - 2);
                xForm.addVariation(Math.random() * 0.06 + 0.1, juliaN);
                break;
            case 3:
                xForm.addVariation(Math.random() * 0.7 + 0.3, VariationFuncList.getVariationFuncInstance("spherical3D", true));
                break;
            default:
                // nothing to do
                break;
        }
        XFormTransformService.rotate(xForm, 180 - Math.random() * 360.0);
        if (Math.random() > 0.5) {
            XFormTransformService.scale(xForm, 0.5 + Math.random() * 1.0, true, true);
        }
        xForm.setColorSymmetry(-1);
    }
    // 3rd XForm
    if (Math.random() > 0.75) {
        if (Math.random() > 0.5) {
            secondXForm.setWeight(5 + Math.random() * 20.0);
        }
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(_3rdWeight);
        xForm.addVariation(1.0, VariationFuncList.getVariationFuncInstance("linear3D", true));
        XFormTransformService.rotate(xForm, 180 - Math.random() * 360.0);
        XFormTransformService.localTranslate(xForm, 1.0 - 2.0 * Math.random(), 1.0 - 2.0 * Math.random());
        xForm.setColorSymmetry(-1);
    }
    return flame;
}
Also used : XForm(org.jwildfire.create.tina.base.XForm) JuliaNFunc(org.jwildfire.create.tina.variation.JuliaNFunc) Layer(org.jwildfire.create.tina.base.Layer) VariationFunc(org.jwildfire.create.tina.variation.VariationFunc) Flame(org.jwildfire.create.tina.base.Flame)

Aggregations

VariationFunc (org.jwildfire.create.tina.variation.VariationFunc)43 XForm (org.jwildfire.create.tina.base.XForm)34 Layer (org.jwildfire.create.tina.base.Layer)31 Flame (org.jwildfire.create.tina.base.Flame)30 Variation (org.jwildfire.create.tina.variation.Variation)9 ArrayList (java.util.ArrayList)4 MotionCurve (org.jwildfire.create.tina.base.motion.MotionCurve)4 Field (java.lang.reflect.Field)3 List (java.util.List)3 RandomGradientMutation (org.jwildfire.create.tina.mutagen.RandomGradientMutation)3 Map (java.util.Map)2 RGBPalette (org.jwildfire.create.tina.palette.RGBPalette)2 JuliaNFunc (org.jwildfire.create.tina.variation.JuliaNFunc)2 Font (java.awt.Font)1 XMLAttribute (org.jwildfire.base.Tools.XMLAttribute)1 XMLAttributes (org.jwildfire.base.Tools.XMLAttributes)1 AnimAware (org.jwildfire.create.tina.animate.AnimAware)1 MotionCurveAttribute (org.jwildfire.create.tina.animate.AnimationService.MotionCurveAttribute)1 SolidRenderSettings (org.jwildfire.create.tina.base.solidrender.SolidRenderSettings)1 FlameWriter (org.jwildfire.create.tina.io.FlameWriter)1