use of org.jwildfire.create.tina.base.Layer in project JWildfire by thargor6.
the class SubFlameWFFunc method transform.
@Override
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
int iter = 0;
final int MAX_ITER = 1000;
if (p.isInfinite() || p.isNaN()) {
prefuseIter(pContext);
}
while (xf != null) {
if (++iter > MAX_ITER) {
return;
}
xf = xf.getNextAppliedXFormTable()[pContext.random(Constants.NEXT_APPLIED_XFORM_TABLE_SIZE)];
if (xf == null) {
return;
}
// double parentColor = pAffineTP.color;
a.clear();
v.clear();
xf.transformPoint(pContext, a, v, p, p);
if (xf.getDrawMode() == DrawMode.HIDDEN)
continue;
else if ((xf.getDrawMode() == DrawMode.OPAQUE) && (pContext.random() > xf.getOpacity()))
continue;
Layer layer = flame.getFirstLayer();
List<XForm> finalXForms = layer.getFinalXForms();
if (finalXForms.size() > 0) {
finalXForms.get(0).transformPoint(pContext, pAffineTP, pVarTP, p, q);
for (int i = 1; i < finalXForms.size(); i++) {
finalXForms.get(i).transformPoint(pContext, pAffineTP, pVarTP, q, q);
}
} else {
q.assign(p);
}
// pVarTP.color -= 1.0;
break;
}
if (!q.doHide) {
pVarTP.doHide = false;
pVarTP.x += q.x + offset_x;
pVarTP.y += q.y + offset_y;
pVarTP.z += q.z + offset_z + colorscale_z * q.color;
if (color_mode != CM_OFF) {
if (q.rgbColor) {
pVarTP.rgbColor = true;
pVarTP.redColor = q.redColor;
pVarTP.greenColor = q.greenColor;
pVarTP.blueColor = q.blueColor;
}
switch(color_mode) {
case CM_DIRECT:
pVarTP.color = q.color;
break;
case CM_RED:
pVarTP.color = pVarTP.redColor / 255.0;
break;
case CM_GREEN:
pVarTP.color = pVarTP.greenColor / 255.0;
break;
case CM_BLUE:
pVarTP.color = pVarTP.blueColor / 255.0;
break;
case CM_BRIGHTNESS:
pVarTP.color = (0.2990 * pVarTP.redColor + 0.5880 * pVarTP.greenColor + 0.1130 * pVarTP.blueColor) / 255.0;
break;
}
}
} else {
pVarTP.doHide = true;
}
}
use of org.jwildfire.create.tina.base.Layer in project JWildfire by thargor6.
the class PolylogarithmTest method visual.
@Test
@Ignore
public void visual() throws Exception {
int side = 400;
ResolutionProfile respro = new ResolutionProfile(true, side, side);
int quality = 200;
Flame f = new Flame();
f.setWidth(side);
f.setHeight(side);
f.setGamma(4.0);
f.setBGTransparency(false);
f.setAntialiasAmount(.1);
f.setAntialiasRadius(.1);
Layer l = new Layer();
XForm xf = new XForm();
SquishFunc df = new SquishFunc();
df.setParameter("power", 10);
xf.addVariation(1, df);
PolylogarithmFunc bf = new PolylogarithmFunc();
bf.setParameter("n", 2);
bf.setParameter("zpow", 1);
xf.addVariation(.1, bf);
f.setCamZoom(6);
xf.setWeight(10);
l.getXForms().add(xf);
RGBPalette pal = new RGBPalette();
for (int i = 0; i < 256; i++) pal.addColor(0, i, 255);
pal.setFlam3Name("PolylogarithmFunc");
l.setPalette(pal);
f.setResolutionProfile(respro);
f.getLayers().clear();
f.getLayers().add(l);
f.setPixelsPerUnit(43.75);
new FlameWriter().writeFlame(f, "/dev/shm/PolylogarithmFunc.flame");
JobRenderThreadController controller = new HeadlessBatchRendererController();
List<Job> joblist = new ArrayList<>();
Job j = new Job();
j.setCustomHeight(side);
j.setCustomWidth(side);
j.setCustomQuality(quality);
j.setFlameFilename("/dev/shm/PolylogarithmFunc.flame");
joblist.add(j);
QualityProfile qualpro = new QualityProfile();
qualpro.setQuality(quality);
JobRenderThread job = new JobRenderThread(controller, joblist, respro, qualpro, true);
job.run();
}
use of org.jwildfire.create.tina.base.Layer in project JWildfire by thargor6.
the class GradientController method gradientSaveBtn_clicked.
public void gradientSaveBtn_clicked() {
try {
Layer layer = tinaController.getCurrLayer();
if (layer != null) {
JFileChooser chooser = new MapFileChooser(prefs);
if (prefs.getTinaGradientPath() != null) {
try {
chooser.setCurrentDirectory(new File(prefs.getTinaGradientPath()));
} catch (Exception ex) {
ex.printStackTrace();
}
}
if (chooser.showSaveDialog(rootPanel) == JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
RGBPalette gradient = layer.getPalette().makeCopy();
gradient.setFlam3Name(file.getName());
new MapGradientWriter().writeGradient(gradient, file.getAbsolutePath());
tinaController.getMessageHelper().showStatusMessage(gradient, "gradient saved to disc");
}
}
} catch (Throwable ex) {
errorHandler.handleError(ex);
}
}
use of org.jwildfire.create.tina.base.Layer in project JWildfire by thargor6.
the class Bubbles3DRandomFlameGenerator 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.setCamPitch(49.0);
flame.setCamYaw(12.0);
flame.setCamPerspective(0.12);
flame.setPixelsPerUnit(200);
layer.getFinalXForms().clear();
layer.getXForms().clear();
// 1st xForm
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(1.0 + Math.random() * 100.0);
if (Math.random() < 0.75) {
xForm.addVariation(0.05 + Math.random() * 0.5, VariationFuncList.getVariationFuncInstance("bubble", true));
} else {
VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("bubble2", true);
varFunc.setParameter("z", -0.5 - Math.random() * 2.0);
xForm.addVariation(0.25 + Math.random() * 0.5, varFunc);
}
xForm.addVariation(0.5 + 1.5 * Math.random(), VariationFuncList.getVariationFuncInstance("pre_blur", true));
final String[] workingFncList = { "fan2", "blade", "blade3D", "blob", "blob3D", "bwraps7", "cell", "cannabiscurve_wf", "cloverleaf_wf", "cos", "cot", "coth", "cross", "csch", "diamond", "disc", "edisc", "epispiral_wf", "fan", "fisheye", "eyefish", "flux", "heart", "julia", "julian", "juliascope", "log", "parabola", "power", "epispiral", "pre_subflame_wf", "rectangles", "rose_wf", "sech", "separation", "split", "truchet", "wedge", "zcone" };
final String[] fncList = Math.random() < 0.5 ? workingFncList : ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL;
VariationFunc varFunc;
if (Math.random() < 0.5) {
varFunc = VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname());
} else {
varFunc = VariationFuncList.getVariationFuncInstance(fncList[Tools.randomInt(fncList.length)], true);
}
xForm.addVariation(-0.02 + 0.04 * Math.random(), varFunc);
double shape = Math.random();
if (shape < 0.125) {
xForm.addVariation(0.001 + Math.random() * 0.01, VariationFuncList.getVariationFuncInstance("hexes", true));
} else if (shape < 0.25) {
xForm.addVariation(0.001 + Math.random() * 0.01, VariationFuncList.getVariationFuncInstance("oscilloscope", true));
} else if (shape < 0.5) {
xForm.addVariation(0.001 + Math.random() * 0.01, VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname(), true));
}
if (Math.random() > 0.33) {
XFormTransformService.globalTranslate(xForm, -1.0 + 2.0 * Math.random(), -1.0 + 2.0 * Math.random(), true);
}
if (Math.random() > 0.33) {
XFormTransformService.rotate(xForm, -32.0 + Math.random() * 72.0, false);
}
if (Math.random() > 0.33) {
XFormTransformService.scale(xForm, 0.8 + Math.random() * 0.4, true, false);
}
xForm.setColor(0.0);
xForm.setColorSymmetry(0.0);
}
// 2nd xForm
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(1.0 + Math.random() * 50.0);
int fncCount = ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL.length;
String fncName = Math.random() > 0.5 ? ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL[Tools.randomInt(fncCount)] : "eyefish";
xForm.addVariation(-1.5 + 2 * Math.random() * 3.0, VariationFuncList.getVariationFuncInstance(fncName, true));
xForm.addVariation(1.0 - 3.5 * Math.random(), VariationFuncList.getVariationFuncInstance("hemisphere", true));
xForm.setColor(0.0);
xForm.setColorSymmetry(0.0);
if (Math.random() > 0.33) {
XFormTransformService.globalTranslate(xForm, -3.0 + 62.0 * Math.random(), -3.0 + 6.0 * Math.random(), false);
}
if (Math.random() > 0.33) {
XFormTransformService.rotate(xForm, -32.0 + Math.random() * 72.0, false);
}
if (Math.random() > 0.33) {
XFormTransformService.scale(xForm, 0.8 + Math.random() * 0.4, true, false);
}
}
// 3rd xForm
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(1.0 + Math.random() * 100);
VariationFunc varFunc = VariationFuncList.getVariationFuncInstance(Math.random() > 0.5 ? "julia3Dz" : "julia3D", true);
int idx = Math.random() > 0.5 ? 2 : (int) (-20 + Math.random() * 40);
if (idx == 0 || idx == 1) {
idx = 2;
}
varFunc.setParameter("power", (double) idx);
xForm.addVariation(1.0, varFunc);
xForm.setColor(0.0);
xForm.setColorSymmetry(0.0);
XFormTransformService.globalTranslate(xForm, -1.0 + 2.0 * Math.random(), -3.0 + 6.0 * Math.random(), false);
XFormTransformService.globalTranslate(xForm, -0.1 + 0.2 * Math.random(), -0.1 + 0.2 * Math.random(), true);
XFormTransformService.rotate(xForm, -20.0 + Math.random() * 40.0, false);
XFormTransformService.scale(xForm, 0.8 + Math.random() * 0.4, true, true);
}
flame.setPreserveZ(Math.random() > 0.5);
flame.getLayers().get(0).randomizeColors();
return flame;
}
use of org.jwildfire.create.tina.base.Layer in project JWildfire by thargor6.
the class DualityRandomFlameGenerator 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();
// create transform 1
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(0.01 + Math.random() * 50);
xForm.setColor(0.74488914);
xForm.setColorSymmetry(0);
// variation 1
xForm.addVariation(1.0, getRandomVariation1());
// random affine transforms (uncomment to play around)
// XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, false);
// XFormTransformService.rotate(xForm, 360.0*Math.random(), false);
XFormTransformService.localTranslate(xForm, 2.0 - 4.0 * Math.random(), 2.0 - 4.0 * Math.random(), false);
// random affine post transforms (uncomment to play around)
// XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, true);
// XFormTransformService.rotate(xForm, 360.0*Math.random(), true);
// XFormTransformService.localTranslate(xForm, 1.0-2.0*Math.random(), 1.0-2.0*Math.random(), true);
}
if (Math.random() > 0.25) {
new RandomParamMutation().execute(flame.getFirstLayer());
}
if (Math.random() > 0.50) {
new RandomParamMutation().execute(flame.getFirstLayer());
}
if (Math.random() > 0.75) {
new RandomParamMutation().execute(flame.getFirstLayer());
}
// create transform 2
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(0.1 + Math.random() * 400.0);
xForm.setColor(0.90312262);
xForm.setColorSymmetry(0.95);
if (Math.random() < 0.33) {
xForm.addVariation(0.5 + Math.random() * 0.5, getRandomVariation2());
} else {
xForm.addVariation(1.0, getRandomVariation2());
}
// random affine transforms (uncomment to play around)
XFormTransformService.scale(xForm, 1.25 - Math.random() * 0.5, true, true, false);
XFormTransformService.rotate(xForm, 36.0 * Math.random(), false);
XFormTransformService.localTranslate(xForm, 1.0 - 2.0 * Math.random(), 1.0 - 2.0 * Math.random(), false);
// XFormTransformService.localTranslate(xForm, 1.0-2.0*Math.random(), 1.0-2.0*Math.random(), true);
if (Math.random() < 0.5) {
if (Math.random() < 0.5) {
xForm.getModifiedWeights()[0] = 0.1 + Math.random() * 0.5;
} else {
xForm.getModifiedWeights()[0] = 3.0 + Math.random() * 7;
}
}
}
if (Math.random() > 0.25) {
new RandomParamMutation().execute(flame.getFirstLayer());
}
if (Math.random() > 0.50) {
new RandomParamMutation().execute(flame.getFirstLayer());
}
if (Math.random() > 0.75) {
new RandomParamMutation().execute(flame.getFirstLayer());
}
// create transform 3
if (Math.random() < 0.1) {
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(0.01 + Math.random() * 200.0);
xForm.setColor(0.6312262);
xForm.setColorSymmetry(0.12);
xForm.addVariation(0.5 + Math.random() * 0.75, getRandomVariation3());
xForm.getModifiedWeights()[2] = 0.0;
// random affine transforms (uncomment to play around)
XFormTransformService.scale(xForm, 1.05 - Math.random() * 0.45, true, true, false);
XFormTransformService.rotate(xForm, 24.0 * Math.random(), false);
XFormTransformService.localTranslate(xForm, 1.0 - 2.0 * Math.random(), 1.0 - 2.0 * Math.random(), false);
// random affine post transforms (uncomment to play around)
// XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, true);
// XFormTransformService.rotate(xForm, 360.0*Math.random(), true);
// XFormTransformService.localTranslate(xForm, 1.0-2.0*Math.random(), 1.0-2.0*Math.random(), true);
}
if (Math.random() > 0.25) {
new RandomParamMutation().execute(flame.getFirstLayer());
}
if (Math.random() > 0.50) {
new RandomParamMutation().execute(flame.getFirstLayer());
}
if (Math.random() > 0.75) {
new RandomParamMutation().execute(flame.getFirstLayer());
}
return flame;
}
Aggregations