Search in sources :

Example 26 with Flame

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

the class JuliansRandomFlameGenerator 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(1.0);
    Layer layer = flame.getFirstLayer();
    layer.getFinalXForms().clear();
    layer.getXForms().clear();
    String primary = Math.random() < 0.666 ? "julian" : "juliascope";
    // 1st xForm
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(0.00001 + Math.random() * 20.0);
        xForm.setColor(Math.random());
        if (Math.random() < 0.5) {
            xForm.addVariation(-1.0 + Math.random() * 2.0, VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname(), true));
        }
        VariationFunc varFunc = VariationFuncList.getVariationFuncInstance(primary, true);
        varFunc.setParameter("power", randInRange(1, 7));
        varFunc.setParameter("dist", -2.0 + 4.0 * Math.random());
        xForm.addVariation(-2.0 + Math.random() * 4.0, varFunc);
        randomAffine(xForm);
    }
    // 2nd xForm
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(0.00001 + Math.random() * 6.0);
        xForm.setColor(Math.random());
        VariationFunc varFunc = VariationFuncList.getVariationFuncInstance(primary, true);
        varFunc.setParameter("power", randInRange(1, 7));
        varFunc.setParameter("dist", -2.0 + 4.0 * Math.random());
        xForm.addVariation(-2.0 + Math.random() * 4.0, varFunc);
        if (Math.random() < 0.8) {
            xForm.addVariation(-1.0 + Math.random() * 2.0, VariationFuncList.getVariationFuncInstance("linear", true));
            xForm.addVariation(-1.0 + Math.random() * 2.0, VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname(), true));
        }
        xForm.getModifiedWeights()[1] = Math.random() < 0.5 ? 0.0 : Math.random();
        XFormTransformService.scale(xForm, 0.5 + Math.random() * 0.5, Math.random() < 0.5, Math.random() < 0.5);
        randomAffine(xForm);
    }
    // 3rd xForm
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(0.00001 + Math.random() * 2.0);
        xForm.setColor(Math.random());
        VariationFunc varFunc = VariationFuncList.getVariationFuncInstance(primary, true);
        varFunc.setParameter("power", randInRange(1, 5));
        varFunc.setParameter("dist", -2.0 + 4.0 * Math.random());
        xForm.addVariation(-2.0 + Math.random() * 4.0, varFunc);
        randomAffine(xForm);
        randomPostAffine(xForm);
    }
    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 27 with Flame

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

the class LayersRandomFlameGenerator method prepareFlame.

@Override
public Flame prepareFlame(RandomFlameGeneratorState pState) {
    Flame flame = createSubFlame(pState);
    int layerCount = 2 + ((Math.random() > 0.66) ? 1 : 0);
    for (int i = 1; i < layerCount; i++) {
        Flame subFlame = createSubFlame(pState);
        flame.getLayers().add(subFlame.getFirstLayer());
        flame.getLayers().get(0).setWeight(0.85 + Math.random() * 0.3);
    }
    flame.setPixelsPerUnit(200);
    return flame;
}
Also used : Flame(org.jwildfire.create.tina.base.Flame)

Example 28 with Flame

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

the class MutaGenController method drawSelectedSet.

public void drawSelectedSet() {
    Dimension imgSize = calcImageSize();
    MutationSet selectedSet = mutationList.get(selectedGenerationIdx);
    int rows = selectedSet.getRows();
    int cols = selectedSet.getCols();
    initProgress(rows, cols);
    int step = 0;
    for (int i = 0; i < rows; i++) {
        for (int j = 0; j < cols; j++) {
            Flame mutation = selectedSet.getFlame(i, j).makeCopy();
            Flame morphed = createWeightedFlame(selectedSet.getBaseFlame(), mutation);
            SimpleImage renderedImg = renderFlame(morphed, imgSize, false);
            ImagePanel pnl = imagePanels[i][j];
            pnl.setImage(renderedImg);
            showProgress(++step);
            pnl.invalidate();
            try {
                Graphics g = pnl.getGraphics();
                if (g != null) {
                    pnl.paint(g);
                }
            } catch (Throwable ex) {
                ex.printStackTrace();
            }
        }
    }
    enableControls();
}
Also used : Graphics(java.awt.Graphics) SimpleImage(org.jwildfire.image.SimpleImage) Dimension(java.awt.Dimension) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame) ImagePanel(org.jwildfire.swing.ImagePanel)

Example 29 with Flame

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

the class MutaGenController method executeRenderThread.

private SimpleImage executeRenderThread(Flame pFlame, int pImageWidth, int pImageHeight, boolean pWithTimeout) {
    Flame flame = pFlame.makeCopy();
    flame.applyFastOversamplingSettings();
    RenderThread thread = new RenderThread(flame, pImageWidth, pImageHeight);
    long tMax = 300;
    long t0 = System.currentTimeMillis();
    new Thread(thread).start();
    while (!thread.isDone()) {
        try {
            Thread.sleep(1);
        } catch (InterruptedException ex) {
            throw new RuntimeException(ex);
        }
        long t1 = System.currentTimeMillis();
        if (pWithTimeout && (t1 - t0 > tMax)) {
            thread.forceAbort();
            return null;
        }
    }
    return thread.getRenderResult();
}
Also used : Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Example 30 with Flame

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

the class MutaGenController method loadFlameFromFileBtn_clicked.

public void loadFlameFromFileBtn_clicked() {
    try {
        JFileChooser chooser = new FlameFileChooser(prefs);
        if (prefs.getInputFlamePath() != null) {
            try {
                chooser.setCurrentDirectory(new File(prefs.getInputFlamePath()));
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
        if (chooser.showOpenDialog(rootPanel) == JFileChooser.APPROVE_OPTION) {
            File file = chooser.getSelectedFile();
            List<Flame> flames = new FlameReader(prefs).readFlames(file.getAbsolutePath());
            Flame flame = flames.get(0);
            prefs.setLastInputFlameFile(file);
            if (flame != null) {
                importFlame(flame);
            }
        }
    } catch (Throwable ex) {
        errorHandler.handleError(ex);
    }
}
Also used : JFileChooser(javax.swing.JFileChooser) FlameReader(org.jwildfire.create.tina.io.FlameReader) FlameFileChooser(org.jwildfire.create.tina.swing.FlameFileChooser) File(java.io.File) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

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