Search in sources :

Example 66 with XForm

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

the class Boarders2Test method visual.

// @Ignore
@Test
public void visual() throws Exception {
    Prefs.getPrefs().setTinaRandomNumberGenerator(RandomGeneratorType.JAVA_INTERNAL);
    System.out.println(Prefs.getPrefs().getTinaRandomNumberGenerator().name());
    int side = 600;
    ResolutionProfile respro = new ResolutionProfile(true, side, side);
    int quality = 80;
    Flame f = new Flame();
    f.setWidth(side);
    f.setHeight(side);
    f.setGamma(4.0);
    f.setBGTransparency(false);
    f.setAntialiasAmount(1.0);
    f.setAntialiasRadius(.1);
    Layer l = new Layer();
    XForm xf = new XForm();
    Boarders2Func bf = new Boarders2Func();
    bf.setParameter("c", .6);
    bf.setParameter("left", .65);
    bf.setParameter("right", .35);
    xf.addVariation(1.0, bf);
    f.setCamZoom(6.461);
    xf.setWeight(5.5);
    l.getXForms().add(xf);
    RGBPalette pal = new RGBPalette();
    for (int i = 0; i < 256; i++) pal.addColor(0, i, 255);
    pal.setFlam3Name("test");
    l.setPalette(pal);
    f.setResolutionProfile(respro);
    f.getLayers().clear();
    f.getLayers().add(l);
    // this is "scale"
    f.setPixelsPerUnit(43.75);
    new FlameWriter().writeFlame(f, "/dev/shm/test.flame");
    JobRenderThreadController controller = new HeadlessBatchRendererController();
    List<Job> joblist = new ArrayList<>();
    Job j = new Job();
    j.setCustomHeight(side);
    j.setCustomWidth(side);
    j.setCustomQuality(quality);
    j.setFlameFilename("/dev/shm/test.flame");
    joblist.add(j);
    QualityProfile qualpro = new QualityProfile();
    qualpro.setQuality(quality);
    JobRenderThread job = new JobRenderThread(controller, joblist, respro, qualpro, true);
    job.run();
}
Also used : ResolutionProfile(org.jwildfire.base.ResolutionProfile) XForm(org.jwildfire.create.tina.base.XForm) RGBPalette(org.jwildfire.create.tina.palette.RGBPalette) HeadlessBatchRendererController(org.jwildfire.create.tina.batch.HeadlessBatchRendererController) ArrayList(java.util.ArrayList) Layer(org.jwildfire.create.tina.base.Layer) XYZPoint(org.jwildfire.create.tina.base.XYZPoint) FlameWriter(org.jwildfire.create.tina.io.FlameWriter) JobRenderThread(org.jwildfire.create.tina.batch.JobRenderThread) QualityProfile(org.jwildfire.base.QualityProfile) Job(org.jwildfire.create.tina.batch.Job) JobRenderThreadController(org.jwildfire.create.tina.batch.JobRenderThreadController) Flame(org.jwildfire.create.tina.base.Flame) Test(org.junit.Test)

Example 67 with XForm

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

the class PolylogarithmTest method testBean.

// n - int
// zpow - double
@Test
public void testBean() {
    PolylogarithmFunc bf = new PolylogarithmFunc();
    bf.setParameter("n", 0);
    bf.setParameter("zpow", 0);
    bf.init(null, null, new XForm(), 10);
    Assert.assertNotNull(bf.getName());
    bf.setParameter("n", 5);
    bf.setParameter("zpow", 6);
    try {
        bf.setParameter("doesn't exist", 5);
        Assert.fail("Expected exception");
    } catch (Exception e) {
    }
    Assert.assertEquals(2, bf.getParameterValues().length);
    Assert.assertEquals(5, bf.getParameter("n"));
    Assert.assertEquals(6.0, bf.getParameter("zpow"));
}
Also used : XForm(org.jwildfire.create.tina.base.XForm) Test(org.junit.Test)

Example 68 with XForm

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

the class DancingFractalsController method validateDancingFlame.

private Flame validateDancingFlame(Flame pFlame) {
    for (Layer layer : pFlame.getLayers()) {
        if (layer.getFinalXForms().size() == 0) {
            XForm xForm = new XForm();
            xForm.addVariation(1.0, new Linear3DFunc());
            layer.getFinalXForms().add(xForm);
        }
    }
    return pFlame;
}
Also used : Linear3DFunc(org.jwildfire.create.tina.variation.Linear3DFunc) XForm(org.jwildfire.create.tina.base.XForm) Layer(org.jwildfire.create.tina.base.Layer)

Example 69 with XForm

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

the class FilledFlowers3DRandomFlameGenerator method prepareFlame.

@Override
public Flame prepareFlame(RandomFlameGeneratorState pState) {
    Flame flame = new Flame();
    Layer layer = flame.getFirstLayer();
    flame.setCentreX(0);
    flame.setCentreY(0);
    flame.setCamPitch(37);
    flame.setCamRoll(0);
    flame.setCamYaw(0);
    flame.setPixelsPerUnit(200);
    flame.setCamZoom(2.0);
    flame.setCamPerspective(0.32);
    layer.getFinalXForms().clear();
    layer.getXForms().clear();
    // 1st xForm
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(0.25 + Math.random() * 0.5);
        {
            xForm.addVariation(0.25 + Math.random() * 0.5, VariationFuncList.getVariationFuncInstance("gaussian_blur", true));
        }
        xForm.setColor(0);
        xForm.setColorSymmetry(0);
    }
    // 2nd xForm
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(1 + Math.random() * 50.0);
        XFormTransformService.localTranslate(xForm, 0.3 - 0.6 * Math.random(), 0.3 - 0.6 * Math.random(), false);
        XFormTransformService.rotate(xForm, 90.0 + Math.random() * 180.0, false);
        XFormTransformService.scale(xForm, 1.25 + Math.random() * 1.25, true, true, false);
        {
            VariationFunc varFunc;
            xForm.addVariation(1, VariationFuncList.getVariationFuncInstance("linear3D", true));
            xForm.addVariation(0.01 - Math.random() * 0.02, VariationFuncList.getVariationFuncInstance("epispiral_wf", true));
            xForm.addVariation(0.1 + Math.random() * 0.1, VariationFuncList.getVariationFuncInstance("ztranslate", true));
            xForm.addVariation(0.00001 - Math.random() * 0.00002, VariationFuncList.getVariationFuncInstance("zcone", true));
            {
                String[] fncLst = { "bubble", "log" };
                xForm.addVariation(0.001 + Math.random() * 0.099, VariationFuncList.getVariationFuncInstance(fncLst[Tools.randomInt(fncLst.length)], true));
            }
            {
                String[] fncLst = { "arch", "bipolar", "hyperbolic", "butterfly", "cannabiscurve_wf", "cell", "checks", "circlize", "conic", "coth", "cpow", "ex", "falloff2", "fan", "flux", "foci", "heart", "kaleidoscope", "log", "mobius", "ngon", "pdj", "oscilloscope", "spherical", "spiral" };
                xForm.addVariation(0.001 + Math.random() * 0.099, VariationFuncList.getVariationFuncInstance(fncLst[Tools.randomInt(fncLst.length)], true));
            }
            {
                String[] fncLst = { "waves2", "waves2_wf", "waves3_wf", "waves4_wf" };
                varFunc = VariationFuncList.getVariationFuncInstance(fncLst[Tools.randomInt(fncLst.length)], true);
                varFunc.setParameter("scalex", 0.5 + Math.random());
                varFunc.setParameter("scaley", 0.5 + Math.random());
                varFunc.setParameter("freqx", 1.0 + Math.random() * 2.0);
                varFunc.setParameter("freqy", 1.0 + Math.random() * 2.0);
                xForm.addVariation(0.05 - Math.random() * 0.1, varFunc);
            }
            {
                String[] fncLst = { "cross", "checks", "conic", "kaleidoscope", "lazysusan", "log" };
                xForm.addVariation(0.001 + Math.random() * 0.015, VariationFuncList.getVariationFuncInstance(fncLst[Tools.randomInt(fncLst.length)], true));
            }
        }
        xForm.setColor(0.33);
        xForm.setColorSymmetry(0);
    }
    // blur xForms
    {
        int blurCount = Tools.randomInt(5);
        double weight = 0.25 + Math.random() * 0.5;
        for (int i = 0; i < blurCount; i++) {
            XForm xForm = new XForm();
            layer.getXForms().add(xForm);
            xForm.setWeight(weight);
            weight *= 0.75;
            xForm.addVariation(0.25 + Math.random() * 0.5, VariationFuncList.getVariationFuncInstance("gaussian_blur", true));
            xForm.setColor(0);
            xForm.setColorSymmetry(0);
            XFormTransformService.localTranslate(xForm, 0.3 - 0.6 * Math.random(), 0.3 - 0.6 * Math.random(), true);
        }
    }
    // satellite xForm
    {
        String[] fncLst = { "blade", "blur", "blur3D", "bubble_wf", "cannabiscurve_wf", "circlecrop", "cloverleaf_wf", "conic", "crop", "cross", "flower", "flux", "hemisphere", "hyperbolic", "julia3D", "julia3Dz", "lazysusan", "lissajous", "log", "mandelbrot", "mobius", "npolar", "pdj", "perspective", "pie", "pie3D", "polar", "polar2", "power", "pre_subflame_wf", "radial_blur", "scry", "separation", "spiral", "spirograph", "split", "tangent", "tangent3D", "twintrian", "unpolar", "wedge_sph", "zblur" };
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(0.1 + Math.random() * 1.4);
        XFormTransformService.localTranslate(xForm, 0.3 - 0.6 * Math.random(), 0.3 - 0.6 * Math.random(), true);
        switch(Tools.randomInt(3)) {
            case 0:
                xForm.addVariation(0.05 + Math.random() * 0.15, VariationFuncList.getVariationFuncInstance("bubble", true));
                xForm.addVariation(0.01 + Math.random() * 0.5, VariationFuncList.getVariationFuncInstance(fncLst[Tools.randomInt(fncLst.length)], true));
                break;
            case 1:
                xForm.addVariation(0.05 + Math.random() * 0.15, VariationFuncList.getVariationFuncInstance("bubble", true));
                break;
            default:
                xForm.addVariation(0.05 + Math.random() * 0.15, VariationFuncList.getVariationFuncInstance(fncLst[Tools.randomInt(fncLst.length)], true));
                break;
        }
        xForm.addVariation(0.05 + Math.random() * 0.15, VariationFuncList.getVariationFuncInstance("bubble", true));
        xForm.setColor(0);
        xForm.setColorSymmetry(0.8 + Math.random() * 0.2);
    }
    // final xForm
    {
        XForm xForm = new XForm();
        layer.getFinalXForms().add(xForm);
        {
            VariationFunc varFunc;
            xForm.addVariation(0.05 + Math.random() * 0.2, VariationFuncList.getVariationFuncInstance("zscale", true));
            varFunc = VariationFuncList.getVariationFuncInstance("julia3D", true);
            varFunc.setParameter("power", Math.random() < 0.5 ? -3 : -4);
            xForm.addVariation(1, varFunc);
            varFunc = VariationFuncList.getVariationFuncInstance("pre_circlecrop", true);
            varFunc.setParameter("radius", 10000);
            varFunc.setParameter("zero", Math.random() < 0.5 ? 1 : 0);
            xForm.addVariation(1, varFunc);
        }
    }
    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 70 with XForm

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

the class GhostsRandomFlameGenerator 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());
        {
            VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("spherical", true);
            xForm.addVariation(0.5 + Math.random(), varFunc);
        }
        {
            VariationFunc varFunc = VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname(), true);
            xForm.addVariation(0.05 + Math.random() * 0.15, varFunc).setPriority(Math.random() < 0.5 ? -1 : 1);
        }
        xForm.setColor(0.4 + Math.random() * 0.2);
        xForm.setColorSymmetry(0.82 + Math.random() * 0.16);
        XFormTransformService.rotate(xForm, 180, false);
        XFormTransformService.scale(xForm, 2.0 + Math.random() * 25.0, true, true, false);
        XFormTransformService.localTranslate(xForm, 0.5 * (0.5 - 1.0 * Math.random()), 0.5 - 1.0 * Math.random(), false);
    }
    // 2nd xForm
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(1.5 + Math.random());
        xForm.setColor(Math.random());
        {
            VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("linear", true);
            xForm.addVariation(0.05 + Math.random() * 0.25, varFunc);
        }
        if (Math.random() < 0.66) {
            VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("radial_blur", true);
            varFunc.setParameter("angle", Math.random() * MathLib.M_PI);
            xForm.addVariation(0.025 + Math.random() * 0.1, varFunc);
        } else {
            VariationFunc varFunc = VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname(), true);
            xForm.addVariation(0.05 + Math.random() * 0.5, varFunc);
        }
        {
            VariationFunc varFunc = VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname(), true);
            xForm.addVariation(0.05 + Math.random() * 0.5, varFunc).setPriority(Math.random() < 0.5 ? -1 : 1);
        }
        XFormTransformService.scale(xForm, 0.1 + Math.random() * 0.8, false, true, false);
        XFormTransformService.scale(xForm, 1.0 + Math.random() * 3.0, true, false, false);
        XFormTransformService.scale(xForm, 0.1 + Math.random() * 0.8, true, true, false);
        XFormTransformService.rotate(xForm, 180, false);
        XFormTransformService.localTranslate(xForm, 2.0 - 4.0 * Math.random(), 0.5 * (2.0 - 4.0 * Math.random()), false);
        xForm.setColorSymmetry(Math.random());
    }
    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

XForm (org.jwildfire.create.tina.base.XForm)121 Layer (org.jwildfire.create.tina.base.Layer)73 Flame (org.jwildfire.create.tina.base.Flame)55 VariationFunc (org.jwildfire.create.tina.variation.VariationFunc)34 XYZPoint (org.jwildfire.create.tina.base.XYZPoint)19 Variation (org.jwildfire.create.tina.variation.Variation)15 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)7 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)7 FlameWriter (org.jwildfire.create.tina.io.FlameWriter)6 Linear3DFunc (org.jwildfire.create.tina.variation.Linear3DFunc)6 RandomGradientMutation (org.jwildfire.create.tina.mutagen.RandomGradientMutation)4 RGBPalette (org.jwildfire.create.tina.palette.RGBPalette)4 ZigguratRandomGenerator (org.jwildfire.create.tina.random.ZigguratRandomGenerator)4 FlameRenderer (org.jwildfire.create.tina.render.FlameRenderer)4 Field (java.lang.reflect.Field)3 SubFlameWFFunc (org.jwildfire.create.tina.variation.SubFlameWFFunc)3 DefaultTableModel (javax.swing.table.DefaultTableModel)2 QualityProfile (org.jwildfire.base.QualityProfile)2 ResolutionProfile (org.jwildfire.base.ResolutionProfile)2