use of org.jwildfire.create.tina.variation.JuliaNFunc in project JWildfire by thargor6.
the class GnarlRandomFlameGenerator method prepareFlame.
@Override
public Flame prepareFlame(RandomFlameGeneratorState pState) {
// Bases loosely on the W2R Batch Script by parrotdolphin.deviantart.com */
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();
// init
double scaleX = Math.random() * 0.04 + 0.04;
if (Math.random() > 0.75) {
scaleX = 0 - scaleX;
}
double scaleY = Math.random() * 0.04 + 0.04;
if (Math.random() > 0.75) {
scaleY = 0 - scaleY;
} else if (Math.random() < 0.25) {
scaleY = scaleX;
}
double freqX, freqY;
if (Math.random() < 0.5) {
freqX = Math.random() * 2.0 + 2.0;
if (Math.random() > 0.5) {
freqY = freqX;
} else {
freqY = Math.random() * 2.0 + 2.0;
}
} else {
freqX = -Math.random() * 2.0 + 2.0;
if (Math.random() > 0.5) {
freqY = freqX;
} else {
freqY = -Math.random() * 2.0 + 16.0;
}
}
double blurAmount = 0.0025 * Math.random();
if (Math.random() < 0.33) {
blurAmount = 0.0 - blurAmount;
}
double wavesWeight = Math.random() * 15 + 135;
double _2ndWeight = 0.5;
double _3rdWeight = 0.5;
double symmetry = 0.7 + Math.random() * 0.3;
int sides = (int) (Math.random() * 8.0 + 3.0);
// 1st XForm
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(wavesWeight);
VariationFunc w2 = Math.random() > 0.89 ? createWaves2Variation(scaleX, scaleY, freqX, freqY) : createWaves2BVariation(scaleX, scaleY, freqX, freqY);
xForm.addVariation(1 + Math.random() * 0.001, w2);
String[] varLst = { "blur", "cos", "exp", "exponential", "lazysusan", "ngon", "sech", "sinh", "epispiral_wf", "tanh", "twintrian", "epispiral" };
String varName = Math.random() > 0.25 ? varLst[(int) (Math.random() * varLst.length)] : VariationFuncList.getRandomVariationname();
xForm.addVariation(blurAmount, VariationFuncList.getVariationFuncInstance(varName, true));
xForm.setColorSymmetry(symmetry);
xForm.setColor(0.9);
if (Math.random() > 0.5) {
XFormTransformService.scale(xForm, 0.995, true, true);
}
double angle, tx, ty;
switch(sides) {
case 3:
angle = -120;
tx = Math.random() * 8 - 4;
ty = Math.random() * 8 - 4;
break;
case 4:
angle = -90;
tx = Math.random() * 8 - 4;
ty = Math.random() * 8 - 4;
break;
case 5:
angle = -72;
tx = Math.random() * 7 - 3.5;
ty = Math.random() * 7 - 3.5;
break;
case 6:
angle = -60;
tx = Math.random() * 7 - 3.5;
ty = Math.random() * 7 - 3.5;
break;
case 7:
angle = -51.42857;
tx = Math.random() * 6 - 3;
ty = Math.random() * 6 - 3;
break;
case 8:
angle = -135;
tx = Math.random() * 6 - 3;
ty = Math.random() * 6 - 3;
break;
case 9:
angle = -40;
tx = Math.random() * 5 - 2.5;
ty = Math.random() * 5 - 2.5;
break;
case 10:
angle = -36;
tx = Math.random() * 4 - 2;
ty = Math.random() * 4 - 2;
break;
default:
throw new IllegalStateException();
}
XFormTransformService.rotate(xForm, angle);
XFormTransformService.localTranslate(xForm, tx * 1.5, ty * 1.5);
}
// 2nd XForm
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(_2ndWeight);
int f = Tools.randomInt(3);
switch(f) {
case 0:
xForm.addVariation(Math.random() * 0.37 + 0.1, VariationFuncList.getVariationFuncInstance("radial_blur", true));
break;
case 1:
xForm.addVariation(Math.random() * 0.37 + 0.3, VariationFuncList.getVariationFuncInstance("bubble", true));
xForm.addVariation(Math.random() * 0.37 + 0.1, VariationFuncList.getVariationFuncInstance("radial_blur", true));
break;
case 2:
xForm.addVariation(Math.random() * 0.1, VariationFuncList.getVariationFuncInstance("radial_blur", true));
JuliaNFunc juliaN = (JuliaNFunc) VariationFuncList.getVariationFuncInstance("julian", true);
juliaN.setParameter("power", 50 - Math.random() * 100);
juliaN.setParameter("dist", Math.random() * 10 - 2);
xForm.addVariation(Math.random() * 0.06 + 0.1, juliaN);
break;
default:
// nothing to do
break;
}
xForm.setColorSymmetry(-1);
}
// 3rd XForm
if (Math.random() > 0.75) {
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(_3rdWeight);
xForm.addVariation(1.0, VariationFuncList.getVariationFuncInstance("linear3D", true));
XFormTransformService.rotate(xForm, 180 - Math.random() * 360.0);
XFormTransformService.localTranslate(xForm, 1.0 - 2.0 * Math.random(), 1.0 - 2.0 * Math.random());
xForm.setColorSymmetry(-1);
}
return flame;
}
use of org.jwildfire.create.tina.variation.JuliaNFunc in project JWildfire by thargor6.
the class ExperimentalGnarlRandomFlameGenerator method prepareFlame.
@Override
public Flame prepareFlame(RandomFlameGeneratorState pState) {
// Bases loosely on the W2R Batch Script by parrotdolphin.deviantart.com */
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();
// init
double scaleX = Math.random() * 0.04 + 0.04;
if (Math.random() > 0.75) {
scaleX = 0 - scaleX;
}
double scaleY = Math.random() * 0.04 + 0.04;
if (Math.random() > 0.75) {
scaleY = 0 - scaleY;
} else if (Math.random() < 0.25) {
scaleY = scaleX;
}
double freqX = Math.random() * 2.0 + 7.0;
double freqY;
if (Math.random() < 0.25) {
freqY = freqX;
} else {
freqY = Math.random() * 2.0 + 7.0;
}
double blurAmount = 0.0025 * Math.random();
double nonBlurAmount = 0.25 * Math.random();
double wavesWeight = Math.random() * 10 + 75;
double _2ndWeight = 0.5;
double _3rdWeight = 0.5;
double symmetry = 0.6 + Math.random() * 0.4;
int sides = (int) (Math.random() * 11.0 + 2.0);
// 1st XForm
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(wavesWeight);
double varRnd = Math.random();
VariationFunc w2;
if (Math.random() > 0.5) {
w2 = createExpWaves2Variation(scaleX, scaleY, freqX, freqY, varRnd);
} else {
if (Math.random() < 0.25) {
w2 = GnarlRandomFlameGenerator.createWaves2Variation(scaleX, scaleY, freqX, freqY);
} else {
w2 = GnarlRandomFlameGenerator.createWaves2BVariation(scaleX, scaleY, freqX, freqY);
}
}
xForm.addVariation(1, w2);
switch(Tools.randomInt(36)) {
case 0:
xForm.addVariation(blurAmount, VariationFuncList.getVariationFuncInstance("blur", true));
break;
case 1:
xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("cos", true));
break;
case 2:
xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("exp", true));
break;
case 3:
xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("exponential", true));
break;
case 4:
xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("lazysusan", true));
break;
case 5:
xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("ngon", true));
break;
case 6:
xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("sech", true));
break;
case 7:
xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("sinh", true));
break;
case 8:
xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("epispiral_wf", true));
break;
case 9:
xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("tanh", true));
break;
case 10:
xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("twintrian", true));
break;
case 11:
xForm.addVariation(blurAmount, VariationFuncList.getVariationFuncInstance("bubble", true));
break;
case 12:
xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("epispiral", true));
break;
default:
{
int l = ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL.length;
String fName = ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL[Tools.randomInt(l)];
xForm.addVariation(blurAmount, VariationFuncList.getVariationFuncInstance(fName, true));
}
}
xForm.setColorSymmetry(symmetry);
xForm.setColor(0.9);
if (Math.random() > 0.5) {
XFormTransformService.scale(xForm, 0.9 + Math.random() * 0.09, true, true);
}
double angle, tx, ty;
switch(sides) {
case 2:
angle = -180;
tx = Math.random() * 8 - 4;
ty = Math.random() * 8 - 4;
break;
case 3:
angle = -120;
tx = Math.random() * 8 - 4;
ty = Math.random() * 8 - 4;
break;
case 4:
angle = -90;
tx = Math.random() * 8 - 4;
ty = Math.random() * 8 - 4;
break;
case 5:
angle = -72;
tx = Math.random() * 7 - 3.5;
ty = Math.random() * 7 - 3.5;
break;
case 6:
angle = -60;
tx = Math.random() * 7 - 3.5;
ty = Math.random() * 7 - 3.5;
break;
case 7:
angle = -51.42857;
tx = Math.random() * 6 - 3;
ty = Math.random() * 6 - 3;
break;
case 8:
angle = -135;
tx = Math.random() * 6 - 3;
ty = Math.random() * 6 - 3;
break;
case 9:
angle = -40;
tx = Math.random() * 5 - 2.5;
ty = Math.random() * 5 - 2.5;
break;
case 10:
angle = -36;
tx = Math.random() * 4 - 2;
ty = Math.random() * 4 - 2;
break;
case 11:
angle = -32.73;
tx = Math.random() * 4.2 - 3;
ty = Math.random() * 4.2 - 3;
break;
case 12:
angle = -30;
tx = Math.random() * 4.2 - 3;
ty = Math.random() * 4.2 - 3;
break;
default:
throw new IllegalStateException();
}
XFormTransformService.rotate(xForm, angle);
XFormTransformService.localTranslate(xForm, tx, ty);
}
// 2nd XForm
XForm secondXForm;
{
XForm xForm = secondXForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(_2ndWeight);
int f = Tools.randomInt(4);
switch(f) {
case 0:
xForm.addVariation(Math.random() * 0.7 + 0.1, VariationFuncList.getVariationFuncInstance("radial_blur", true));
break;
case 1:
xForm.addVariation(Math.random() * 0.7 + 0.3, VariationFuncList.getVariationFuncInstance("bubble", true));
xForm.addVariation(Math.random() * 0.7 + 0.1, VariationFuncList.getVariationFuncInstance("radial_blur", true));
break;
case 2:
xForm.addVariation(Math.random() * 0.1, VariationFuncList.getVariationFuncInstance("radial_blur", true));
JuliaNFunc juliaN = (JuliaNFunc) VariationFuncList.getVariationFuncInstance("julian", true);
juliaN.setParameter("power", 50 - Math.random() * 100);
juliaN.setParameter("dist", Math.random() * 10 - 2);
xForm.addVariation(Math.random() * 0.06 + 0.1, juliaN);
break;
case 3:
xForm.addVariation(Math.random() * 0.7 + 0.3, VariationFuncList.getVariationFuncInstance("spherical3D", true));
break;
default:
// nothing to do
break;
}
XFormTransformService.rotate(xForm, 180 - Math.random() * 360.0);
if (Math.random() > 0.5) {
XFormTransformService.scale(xForm, 0.5 + Math.random() * 1.0, true, true);
}
xForm.setColorSymmetry(-1);
}
// 3rd XForm
if (Math.random() > 0.75) {
if (Math.random() > 0.5) {
secondXForm.setWeight(5 + Math.random() * 20.0);
}
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(_3rdWeight);
xForm.addVariation(1.0, VariationFuncList.getVariationFuncInstance("linear3D", true));
XFormTransformService.rotate(xForm, 180 - Math.random() * 360.0);
XFormTransformService.localTranslate(xForm, 1.0 - 2.0 * Math.random(), 1.0 - 2.0 * Math.random());
xForm.setColorSymmetry(-1);
}
return flame;
}
Aggregations