use of org.jwildfire.create.tina.base.Layer in project JWildfire by thargor6.
the class SynthRandomFlameGenerator method prepareFlame.
@Override
public Flame prepareFlame(RandomFlameGeneratorState pState) {
// Bases loosely on the SynthRandomBatch Script by slobo777, http://slobo777.deviantart.com/art/Synth-V2-128594088 */
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
// These vars affect the style of the centre effect
double centre_synth = 0.7;
// 5;
double centre_mode = Tools.randomInt(20);
double centre_noise = .0;
double centre_power = -1.0;
double centre_smooth = 1;
double centre_color = 0.4 + 0.2 * Math.random();
double centre_symmetry = 0.6 + 0.4 * Math.random();
XForm xForm1;
// 1st XForm
{
XForm xForm = xForm1 = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(1.0);
xForm.setColor(0.0);
xForm.setColorSymmetry(-1.0);
VariationFunc synth = VariationFuncList.getVariationFuncInstance("synth");
xForm.addVariation(1.0, synth);
// 3;
synth.setParameter("mode", Tools.randomInt(20));
synth.setParameter("power", -0.2);
int numWaves = (int) (Math.random() * 3.5 + 2);
// Starting circle . . .
synth.setParameter("a", 0.8 + (Math.random() * 0.4));
// Wave #1
synth.setParameter("b", Math.random() * 2);
synth.setParameter("b_type", Tools.randomInt(7));
synth.setParameter("b_frq", Tools.randomInt(7) + 1);
synth.setParameter("b_phs", Math.random() * M_PI);
synth.setParameter("b_layer", Tools.randomInt(4));
// Skew effect?
if (Math.random() < 0.2) {
synth.setParameter("b_skew", Math.random() * 2 - 1);
}
// Exceptionally high frequency?
if (Math.random() < 0.1) {
synth.setParameter("b_frq", Tools.randomInt(20) + 7);
}
// Usually higher frequencies affect the amplitude
if (Math.random() < 0.8) {
synth.setParameter("b", (Double) synth.getParameter("b") / (1 + 0.3 * (Double) synth.getParameter("b_frq")));
}
// Wave #2
synth.setParameter("c", Math.random());
synth.setParameter("c_type", Tools.randomInt(7));
synth.setParameter("c_frq", Tools.randomInt(7) + 1);
synth.setParameter("c_phs", Math.random() * M_PI);
synth.setParameter("c_layer", Tools.randomInt(4));
// Skew effect?
if (Math.random() < 0.2) {
synth.setParameter("c_skew", Math.random() * 2 - 1);
}
// Exceptionally high frequency?
if (Math.random() < 0.1) {
synth.setParameter("c_frq", Tools.randomInt(20) + 7);
}
// Usually higher frequencies affect the amplitude
if (Math.random() < 0.8) {
synth.setParameter("c", (Double) synth.getParameter("c") / (1 + 0.3 * (Double) synth.getParameter("c_frq")));
}
// Wave #3
if (numWaves >= 3) {
synth.setParameter("d", Math.random());
synth.setParameter("d_type", Tools.randomInt(7));
synth.setParameter("d_frq", Tools.randomInt(7) + 1);
synth.setParameter("d_phs", Math.random() * M_PI);
synth.setParameter("d_layer", Tools.randomInt(4));
// Skew effect?
if (Math.random() < 0.2) {
synth.setParameter("d_skew", Math.random() * 2 - 1);
}
// Exceptionally high frequency?
if (Math.random() < 0.1) {
synth.setParameter("d_frq", Tools.randomInt(20) + 7);
}
// Usually higher frequencies affect the amplitude
if (Math.random() < 0.8) {
synth.setParameter("d", (Double) synth.getParameter("d") / (1 + 0.3 * (Double) synth.getParameter("d_frq")));
}
}
// Wave #4
if (numWaves >= 4) {
synth.setParameter("e", Math.random());
synth.setParameter("e_type", Tools.randomInt(7));
synth.setParameter("e_frq", Tools.randomInt(7) + 1);
synth.setParameter("e_phs", Math.random() * M_PI);
synth.setParameter("e_layer", Tools.randomInt(4));
// Skew effect?
if (Math.random() < 0.2) {
synth.setParameter("e_skew", Math.random() * 2 - 1);
}
// Exceptionally high frequency?
if (Math.random() < 0.1) {
synth.setParameter("e_frq", Tools.randomInt(20) + 7);
}
// Usually higher frequencies affect the amplitude
if (Math.random() < 0.8) {
synth.setParameter("e", (Double) synth.getParameter("e") / (1 + 0.3 * (Double) synth.getParameter("e_frq")));
}
}
// Wave #5
if (numWaves >= 5) {
synth.setParameter("f", Math.random());
synth.setParameter("f_type", Tools.randomInt(7));
synth.setParameter("f_frq", Tools.randomInt(7) + 1);
synth.setParameter("f_phs", Math.random() * M_PI);
synth.setParameter("f_layer", Tools.randomInt(4));
// Skew effect?
if (Math.random() < 0.2) {
synth.setParameter("f_skew", Math.random() * 2 - 1);
}
// Exceptionally high frequency?
if (Math.random() < 0.1) {
synth.setParameter("f_frq", Tools.randomInt(20) + 7);
}
// Usually higher frequencies affect the amplitude
if (Math.random() < 0.8) {
synth.setParameter("f", (Double) synth.getParameter("f") / (1 + 0.3 * (Double) synth.getParameter("f_frq")));
}
}
}
// Second "inner" transform is smaller with a little noise
// added to remove annoying lines at the centre
{
XForm xForm = xForm1.makeCopy();
layer.getXForms().add(xForm);
xForm.setWeight(1.0);
xForm.setColor(centre_color);
xForm.setColorSymmetry(centre_symmetry);
VariationFunc synth = xForm.getVariation(0).getFunc();
xForm.getVariation(0).setAmount(centre_synth);
synth.setParameter("power", centre_power);
synth.setParameter("mode", centre_mode);
synth.setParameter("smooth", centre_smooth);
VariationFunc noise = VariationFuncList.getVariationFuncInstance("noise");
xForm.addVariation(centre_noise, noise);
}
if (Math.random() < 0.55) {
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(5 * Math.random() + 0.125);
xForm.setColor(centre_color + 0.2 * Math.random());
xForm.setColorSymmetry(centre_symmetry - 0.4 * Math.random());
VariationFunc varFunc = VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname());
xForm.addVariation(0.25 + Math.random() * 1.5, varFunc);
xForm.getModifiedWeights()[1] = 0.0;
}
return flame;
}
use of org.jwildfire.create.tina.base.Layer in project JWildfire by thargor6.
the class TentacleRandomFlameGenerator method prepareFlame.
@Override
public 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 maxXFormsX = (int) (2.0 + Math.random() * 3.0);
int maxXFormsY = (int) (2.0 + Math.random() * 3.0);
double xMin = -(double) maxXFormsX * 0.5;
double yMin = -(double) maxXFormsY * 0.5 + 1;
String[] fnc = ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL;
double scl = 1.0;
for (int y = 0; y < maxXFormsY; y++) {
for (int x = 0; x < maxXFormsX; x++) {
XForm xForm = new XForm();
xForm.setWeight(0.5 + Math.random() * 99.5);
layer.getXForms().add(xForm);
XFormTransformService.globalTranslate(xForm, xMin + x, yMin + y, false);
if (Math.random() < 0.5) {
XFormTransformService.rotate(xForm, 360.0 * Math.random(), true);
} else {
XFormTransformService.rotate(xForm, -360.0 * Math.random(), true);
}
XFormTransformService.localTranslate(xForm, -1.0 + 2.0 * Math.random(), -1.0 + 2.0 * Math.random(), true);
scl *= 0.75 + Math.random() / 4;
XFormTransformService.scale(xForm, scl, true, true, true);
int fncIdx = (int) (Math.random() * fnc.length);
xForm.addVariation(Math.random() * 0.9 + 0.1, VariationFuncList.getVariationFuncInstance(Math.random() > 0.25 ? fnc[fncIdx] : "linear3D", true));
xForm.setColor(Math.random());
}
}
return flame;
}
use of org.jwildfire.create.tina.base.Layer in project JWildfire by thargor6.
the class TileBallRandomFlameGenerator method prepareFlame.
@Override
public Flame prepareFlame(RandomFlameGeneratorState pState) {
Flame flame = new Flame();
flame.setCentreX(0.1 - Math.random() * 0.2);
flame.setCentreY(-0.6 + Math.random() * 0.3);
flame.setPixelsPerUnit(200);
flame.setCamZoom(1.0 + Math.random() * 0.5);
flame.setCamPitch(25.0 + Math.random() * 40.0);
flame.setCamPerspective(0.1 + Math.random() * 0.2);
flame.setPreserveZ(true);
Layer layer = flame.getFirstLayer();
layer.getFinalXForms().clear();
layer.getXForms().clear();
double tileSpacing = 0.5;
// 1st xForm
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(0.5);
xForm.addVariation(1.0, VariationFuncList.getVariationFuncInstance("linear3D", true));
xForm.addVariation(1.5 + Math.random() * 1.5, VariationFuncList.getVariationFuncInstance("ztranslate", true));
xForm.setColor(Math.random());
xForm.setColorSymmetry(1.0);
xForm.getModifiedWeights()[10] = 0.0;
}
// 2nd xForm
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(0.5);
xForm.addVariation(1.0, VariationFuncList.getVariationFuncInstance("linear3D", true));
xForm.setColorSymmetry(1.0);
XFormTransformService.localTranslate(xForm, 0, tileSpacing);
xForm.getModifiedWeights()[10] = 0.0;
}
// 3rd xForm
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(0.5);
xForm.addVariation(1.0, VariationFuncList.getVariationFuncInstance("linear3D", true));
xForm.setColorSymmetry(1.0);
XFormTransformService.localTranslate(xForm, tileSpacing, tileSpacing);
xForm.getModifiedWeights()[10] = 0.0;
}
// 4th xForm
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(0.5);
xForm.addVariation(1.0, VariationFuncList.getVariationFuncInstance("linear3D", true));
xForm.setColorSymmetry(1.0);
XFormTransformService.localTranslate(xForm, tileSpacing, 0);
xForm.getModifiedWeights()[10] = 0.0;
}
// 5th xForm
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(0.5);
xForm.addVariation(1.0, VariationFuncList.getVariationFuncInstance("linear3D", true));
xForm.setColorSymmetry(1.0);
XFormTransformService.localTranslate(xForm, tileSpacing, -tileSpacing);
xForm.getModifiedWeights()[10] = 0.0;
}
// 6th xForm
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(0.5);
xForm.addVariation(1.0, VariationFuncList.getVariationFuncInstance("linear3D", true));
xForm.setColorSymmetry(1.0);
XFormTransformService.localTranslate(xForm, 0, -tileSpacing);
xForm.getModifiedWeights()[10] = 0.0;
}
// 7th xForm
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(0.5);
xForm.addVariation(1.0, VariationFuncList.getVariationFuncInstance("linear3D", true));
xForm.setColorSymmetry(1.0);
XFormTransformService.localTranslate(xForm, -tileSpacing, -tileSpacing);
xForm.getModifiedWeights()[10] = 0.0;
}
// 8th xForm
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(0.5);
xForm.addVariation(1.0, VariationFuncList.getVariationFuncInstance("linear3D", true));
xForm.setColorSymmetry(1.0);
XFormTransformService.localTranslate(xForm, -tileSpacing, 0);
xForm.getModifiedWeights()[10] = 0.0;
}
// 9th xForm
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(0.5);
xForm.addVariation(1.0, VariationFuncList.getVariationFuncInstance("linear3D", true));
xForm.setColorSymmetry(1.0);
XFormTransformService.localTranslate(xForm, -tileSpacing, tileSpacing);
xForm.getModifiedWeights()[10] = 0.0;
}
// 10th xForm
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(0.25 + Math.random() * 1.25);
VariationFunc var = VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname(), true);
xForm.addVariation(0.2 + Math.random() * 0.6, var);
randomizeParams(var);
xForm.addVariation(1.0, VariationFuncList.getVariationFuncInstance("flatten", true));
xForm.setColor(Math.random());
xForm.setColorSymmetry(Math.random());
xForm.getModifiedWeights()[0] = 0.0;
xForm.getModifiedWeights()[1] = 0.0;
xForm.getModifiedWeights()[2] = 0.0;
xForm.getModifiedWeights()[3] = 0.0;
xForm.getModifiedWeights()[4] = 0.0;
xForm.getModifiedWeights()[5] = 0.0;
xForm.getModifiedWeights()[6] = 0.0;
xForm.getModifiedWeights()[7] = 0.0;
xForm.getModifiedWeights()[8] = 0.0;
xForm.getModifiedWeights()[9] = 0.0;
xForm.getModifiedWeights()[10] = 1.0;
}
// 11st xForm
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(0.25 + Math.random() * 1.25);
VariationFunc var = VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname(), true);
xForm.addVariation(0.1 + Math.random() * 0.3, var);
randomizeParams(var);
xForm.addVariation(1.0, VariationFuncList.getVariationFuncInstance("flatten", true));
xForm.setColor(Math.random());
xForm.setColorSymmetry(Math.random());
xForm.getModifiedWeights()[10] = 0.0;
}
// final xForm
{
XForm xForm = new XForm();
layer.getFinalXForms().add(xForm);
xForm.setWeight(0.8 + Math.random() * 0.5);
VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("curl3D", true);
varFunc.setParameter("cx", -0.75 + Math.random() * 1.5);
varFunc.setParameter("cy", 0.8 + Math.random() * 0.4);
varFunc.setParameter("cz", 0.025 + Math.random() * 0.05);
xForm.addVariation(1.0, varFunc);
}
return flame;
}
use of org.jwildfire.create.tina.base.Layer in project JWildfire by thargor6.
the class LinearRandomFlameGenerator method prepareFlame.
@Override
public 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) (1.0 + Math.random() * 5.0);
double scl = 1.0;
double tscl = 2.0;
boolean contRot = Math.random() < 0.5;
double r0 = 0;
for (int i = 0; i < maxXForms; i++) {
XForm xForm = new XForm();
layer.getXForms().add(xForm);
if (contRot) {
r0 += 45.0 * Math.random() - 9.0 * Math.random();
XFormTransformService.rotate(xForm, r0);
} else {
if (Math.random() < 0.5) {
XFormTransformService.rotate(xForm, 360.0 * Math.random());
} else {
XFormTransformService.rotate(xForm, -360.0 * Math.random());
}
}
XFormTransformService.localTranslate(xForm, (2.0 * Math.random() - 1.0) * tscl, (2.0 * Math.random() - 1.0) * tscl);
scl *= 0.8 + Math.random() * 0.1;
tscl *= 0.8 + Math.random() * 0.1;
XFormTransformService.scale(xForm, scl, true, true);
xForm.setColor(Math.random());
xForm.addVariation(Math.random() * 0.5 + 0.5, new Linear3DFunc());
xForm.setWeight(scl * Math.random() * 19.9 + 0.1);
}
return flame;
}
use of org.jwildfire.create.tina.base.Layer in project JWildfire by thargor6.
the class MachineRandomFlameGenerator method prepareFlame.
@Override
public Flame prepareFlame(RandomFlameGeneratorState pState) {
Flame flame = new Flame();
Layer layer = flame.getFirstLayer();
flame.setCentreX(Math.random() - 0.5);
flame.setCentreY(Math.random() - 0.5);
flame.setCamRoll(0);
flame.setCamPitch(0);
flame.setCamYaw(0);
flame.setCamPerspective(0);
flame.setCamZoom(1);
flame.setPixelsPerUnit(200);
layer.getFinalXForms().clear();
layer.getXForms().clear();
// 1st xForm
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(32.16406573);
xForm.setColor(0.74488914);
xForm.setColorSymmetry(0);
xForm.setMaterial(0);
xForm.setMaterialSpeed(0);
// a
xForm.setCoeff00(1);
// b
xForm.setCoeff10(0);
// e
xForm.setCoeff20(1.82382673);
// c
xForm.setCoeff01(0);
// d
xForm.setCoeff11(1);
// f
xForm.setCoeff21(-1.8206164);
xForm.setPostCoeff00(1);
xForm.setPostCoeff10(0);
xForm.setPostCoeff01(0);
xForm.setPostCoeff11(1);
xForm.setPostCoeff20(0);
xForm.setPostCoeff21(0);
// variation 1
{
VariationFunc varFunc = VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname(), true);
xForm.addVariation(1, varFunc);
}
flame.setEditPlane(EditPlane.XY);
XFormTransformService.scale(xForm, 1.25 - Math.random() * 0.5, true, true, false);
XFormTransformService.rotate(xForm, 360.0 * Math.random(), false);
XFormTransformService.localTranslate(xForm, 1.0 - 2.0 * Math.random(), 1.0 - 2.0 * Math.random(), false);
}
// 2nd xForm
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(257.3608644);
xForm.setColor(0.90312262);
xForm.setColorSymmetry(0.95);
xForm.setMaterial(0);
xForm.setMaterialSpeed(0);
// a
xForm.setCoeff00(0.82496229);
// b
xForm.setCoeff10(0.55902149);
// e
xForm.setCoeff20(0.05455807);
// c
xForm.setCoeff01(-0.55902149);
// d
xForm.setCoeff11(0.82496229);
// f
xForm.setCoeff21(0.73105973);
xForm.setPostCoeff00(1);
xForm.setPostCoeff10(0);
xForm.setPostCoeff01(0);
xForm.setPostCoeff11(1);
xForm.setPostCoeff20(0);
xForm.setPostCoeff21(0);
// change relative weights
xForm.getModifiedWeights()[0] = 0.54127492;
// variation 1
{
VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("yin_yang", true);
varFunc.setParameter("radius", 0.25 + Math.random() * 0.5);
varFunc.setParameter("ang1", 0);
varFunc.setParameter("ang2", 0.1 + Math.random() * 0.5);
varFunc.setParameter("dual_t", 1);
varFunc.setParameter("outside", 1);
xForm.addVariation(0.75 + Math.random() * 0.5, varFunc);
}
flame.setEditPlane(EditPlane.XY);
XFormTransformService.scale(xForm, 1.25 - Math.random() * 0.5, true, true, false);
XFormTransformService.rotate(xForm, 360.0 * Math.random(), false);
XFormTransformService.localTranslate(xForm, 1.0 - 2.0 * Math.random(), 1.0 - 2.0 * Math.random(), false);
}
flame.getFirstLayer().randomizeColors();
return flame;
}
Aggregations