public class BubblesRandomFlameGenerator extends RandomFlameGenerator {
@Override
protected Flame prepareFlame(RandomFlameGeneratorState pState) {
Flame flame = new Flame();
Layer layer = flame.getFirstLayer();
flame.setCentreX(0.0);
flame.setCentreY(0.0);
flame.setCamZoom(0.5);
flame.setPixelsPerUnit(200);
layer.getFinalXForms().clear();
layer.getXForms().clear();
int fncCount = ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL.length;
// 1st xForm
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(12.0 + Math.random() * 80.0);
xForm.addVariation(2 + Math.random() * 4, VariationFuncList.getVariationFuncInstance("spherical", true));
String fName;
if (Math.random() < 0.15) {
fName = ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL[(int) (Math.random() * fncCount)];
}
else {
fName = Math.random() < 0.8 ? "eyefish" : "fisheye";
}
xForm.addVariation(0.05 + Math.random() * 0.5, VariationFuncList.getVariationFuncInstance(fName, true));
xForm.setColorSymmetry(0.991 + Math.random() * 0.08);
XFormTransformService.scale(xForm, 0.5 - Math.random() * 0.5, true, true, false);
XFormTransformService.rotate(xForm, 180 - Math.random() * 360.0, false);
XFormTransformService.localTranslate(xForm, 3.0 - 6.0 * Math.random(), 3.0 - 6.0 * Math.random(), false);
if (Math.random() < 0.33) {
XFormTransformService.localTranslate(xForm, 0.75 - 1.5 * Math.random(), 0.75 - 1.5 * Math.random(), true);
}
}
// 2nd xForm
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(0.5 + Math.random() * 0.8);
if (Math.random() < 0.05) {
xForm.addVariation(0.01 + Math.random() * 0.4, VariationFuncList.getVariationFuncInstance("bubble", true));
VariationFunc checks = VariationFuncList.getVariationFuncInstance("checks", true);
checks.setParameter("size", 5.0);
checks.setParameter("x", 3.0);
checks.setParameter("y", 3.0);
xForm.addVariation(0.01 + Math.random() * 0.04, checks);
}
else {
xForm.addVariation(0.1 + Math.random() * 0.5, VariationFuncList.getVariationFuncInstance("bubble", true));
}
xForm.addVariation(4 + Math.random() * 2, VariationFuncList.getVariationFuncInstance("pre_blur", true));
xForm.setColorSymmetry(-0.5);
XFormTransformService.scale(xForm, 1.1 + Math.random() * 1.9, true, true, false);
XFormTransformService.localTranslate(xForm, 0.75 - 1.50 * Math.random(), 0.75 - 1.50 * Math.random(), false);
XFormTransformService.rotate(xForm, 30 - Math.random() * 60.0, false);
}
// 3rd xForm
if (Math.random() > 0.25) {
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(0.5 + Math.random() * 1.5);
String fName;
if (Math.random() > 0.8) {
fName = ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL[(int) (Math.random() * fncCount)];
}
else {
fName = Math.random() > 0.5 ? "linear3D" : "noise";
}
xForm.addVariation(0.5, VariationFuncList.getVariationFuncInstance(fName, true));
xForm.setColorSymmetry(-0.5);
XFormTransformService.rotate(xForm, 30.0 - Math.random() * 60.0, false);
if (Math.random() < 0.5) {
XFormTransformService.scale(xForm, 0.5 + Math.random() * 1.5, true, true, false);
}
}
// 4th xForm
if (Math.random() > 0.5) {
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(0.5 + Math.random() * 1.5);
String fName;
if (Math.random() > 0.8) {
fName = Math.random() > 0.75 ? VariationFuncList.getRandomVariationname() : ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL[(int) (Math.random() * fncCount)];
}
else {
fName = Math.random() > 0.5 ? "linear3D" : "gaussian_blur";
}
xForm.addVariation(0.5, VariationFuncList.getVariationFuncInstance(fName, true));
xForm.setColorSymmetry(-0.5);
XFormTransformService.rotate(xForm, 30.0 - Math.random() * 60.0, false);
if (Math.random() < 0.5) {
XFormTransformService.scale(xForm, 0.15 + Math.random() * 1.25, true, true, false);
}
}
flame.getFirstLayer().distributeColors();
return flame;
}