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;
}
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;
}
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();
}
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();
}
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);
}
}
Aggregations