/*
JWildfire - an image and animation processor written in Java
Copyright (C) 1995-2011 Andreas Maschke
This is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser
General Public License as published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this software;
if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jwildfire.create.tina.randomflame;
import org.jwildfire.create.tina.base.Flame;
import org.jwildfire.create.tina.base.Layer;
import org.jwildfire.create.tina.base.XForm;
import org.jwildfire.create.tina.transform.XFormTransformService;
import org.jwildfire.create.tina.variation.Linear3DFunc;
import org.jwildfire.create.tina.variation.VariationFuncList;
public class SimpleRandomFlameGenerator extends RandomFlameGenerator {
private static final String FNCLST_ORIGINAL[] = { "blur3D", "bubble", "curl3D", "diamond", "waves2_3D", "disc", "julia3D", "heart",
"julia3D", "hemisphere", "waffle", "bwraps7", "horseshoe", "boarders", "blob3D", "xtrb", "xheart", "julia3D", "pdj", "popcorn", "rings2", "rose_wf",
"spherical3D", "spiral", "rectangles", "blur", "waves", "swirl", "secant2", "boarders2" };
@Override
protected 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();
int maxXForms = (int) (2.0 + Math.random() * 5.0);
double scl = 1.0;
for (int i = 0; i < maxXForms; i++) {
XForm xForm = new XForm();
layer.getXForms().add(xForm);
if (Math.random() < 0.5) {
XFormTransformService.rotate(xForm, 360.0 * Math.random());
}
else {
XFormTransformService.rotate(xForm, -360.0 * Math.random());
}
XFormTransformService.localTranslate(xForm, Math.random() - 1.0, Math.random() - 1.0);
scl *= 0.75 + Math.random() / 4;
XFormTransformService.scale(xForm, scl, true, true);
xForm.setColor(Math.random());
xForm.addVariation(Math.random() * 0.8 + 0.2, new Linear3DFunc());
if (Math.random() > 0.33) {
String[] fnc = FNCLST_ORIGINAL;
int fncIdx = (int) (Math.random() * fnc.length);
xForm.addVariation(Math.random() * 0.5, VariationFuncList.getVariationFuncInstance(fnc[fncIdx], true));
}
xForm.setWeight(Math.random() * 0.9 + 0.1);
}
return flame;
}
@Override
public String getName() {
return "Simple (stunning)";
}
@Override
public boolean isUseFilter(RandomFlameGeneratorState pState) {
return true;
}
@Override
protected Flame postProcessFlame(RandomFlameGeneratorState pState, Flame pFlame) {
return pFlame;
}
}