use of org.jwildfire.create.tina.base.XForm in project JWildfire by thargor6.
the class GalaxiesRandomFlameGenerator method prepareFlame.
@Override
public Flame prepareFlame(RandomFlameGeneratorState pState) {
Flame flame = new Flame();
Layer layer = flame.getFirstLayer();
flame.setCamRoll(1.49758722);
flame.setCamPitch(0);
flame.setCamYaw(0);
flame.setCamPerspective(0);
flame.setWidth(601);
flame.setHeight(338);
flame.setPixelsPerUnit(92.48366013);
flame.setCamZoom(0.72 + Math.random() * 0.42);
flame.setCentreX(1.5357526);
flame.setCentreY(-0.4416446);
layer.getFinalXForms().clear();
layer.getXForms().clear();
// create transform 1
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(25.75871591);
xForm.setColor(0.74488914);
xForm.setColorSymmetry(0);
// a
xForm.setCoeff00(1);
// b
xForm.setCoeff10(0);
// e
xForm.setCoeff20(1.09171281);
// c
xForm.setCoeff01(0);
// d
xForm.setCoeff11(1);
// f
xForm.setCoeff21(-1.22115911);
xForm.setPostCoeff00(1);
xForm.setPostCoeff10(0);
xForm.setPostCoeff01(0);
xForm.setPostCoeff11(1);
xForm.setPostCoeff20(0);
xForm.setPostCoeff21(0);
// variation 1
{
double amount = Math.random() > 0.25 ? 1.0 - 2.0 * Math.random() : 1.0;
xForm.addVariation(amount, getRandomVariation());
if (Math.random() > 0.5) {
new RandomParamMutation().setRandomFlameProperty(flame.getFirstLayer(), 1.0);
}
}
}
// create transform 2
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(286.87636036);
xForm.setColor(0.90312262);
xForm.setColorSymmetry(0.95);
// a
xForm.setCoeff00(0.96333808);
// b
xForm.setCoeff10(0.12845865);
// e
xForm.setCoeff20(0.31387449);
// c
xForm.setCoeff01(-0.12845865);
// d
xForm.setCoeff11(0.96333808);
// f
xForm.setCoeff21(0.08003269);
xForm.setPostCoeff00(1);
xForm.setPostCoeff10(0);
xForm.setPostCoeff01(0);
xForm.setPostCoeff11(1);
xForm.setPostCoeff20(0);
xForm.setPostCoeff21(0);
// variation 1
xForm.addVariation(1, VariationFuncList.getVariationFuncInstance("sec", true));
}
if (Math.random() > 0.5) {
new LocalGammaMutation().execute(flame.getFirstLayer());
}
return flame;
}
use of org.jwildfire.create.tina.base.XForm 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.base.XForm 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.XForm in project JWildfire by thargor6.
the class RandomParamMutation method setRandomFlameProperty.
public void setRandomFlameProperty(Layer pLayer, double pAmount) {
List<VariationFunc> variations = new ArrayList<VariationFunc>();
for (XForm xForm : pLayer.getXForms()) {
addVariations(variations, xForm);
}
for (XForm xForm : pLayer.getFinalXForms()) {
addVariations(variations, xForm);
}
filterVariations(variations);
if (variations.size() > 0) {
int idx = (int) (Math.random() * variations.size());
VariationFunc var = variations.get(idx);
int pIdx = (int) (Math.random() * var.getParameterNames().length);
Object oldVal = var.getParameterValues()[pIdx];
if (oldVal instanceof Integer) {
int o = (Integer) oldVal;
int da = Tools.FTOI(pAmount);
if (da < 1) {
da = 1;
}
if (o >= 0) {
o += da;
} else {
o -= da;
}
var.setParameter(var.getParameterNames()[pIdx], o);
} else if (oldVal instanceof Double) {
double o = (Double) oldVal;
if (o < EPSILON || Math.random() < 0.3) {
if (o >= 0) {
o += 0.1 * pAmount;
} else {
o -= 0.1 * pAmount;
}
} else {
if (o >= 0) {
o += o / 100.0 * pAmount;
} else {
o -= o / 100.0 * pAmount;
}
}
var.setParameter(var.getParameterNames()[pIdx], o);
}
}
}
use of org.jwildfire.create.tina.base.XForm in project JWildfire by thargor6.
the class AbstractAffine3DRandomFlameGenerator method scaleXForm.
protected void scaleXForm(Flame pFlame, int idx, double offset, double amp0) {
Layer layer = pFlame.getFirstLayer();
if (layer.getXForms().size() > idx) {
pFlame.setEditPlane(EditPlane.ZX);
XForm xform = layer.getXForms().get(idx);
XFormTransformService.scale(xform, offset + (0.5 - Math.random()) * amp0, true, true);
pFlame.setEditPlane(EditPlane.XY);
}
}
Aggregations