use of org.jwildfire.create.tina.io.FlameWriter in project JWildfire by thargor6.
the class SolidLabyrinthRandomFlameGenerator method embedSubFlame.
public void embedSubFlame(Flame flame, Flame subFlame) {
Layer layer = flame.getFirstLayer();
layer.getFinalXForms().clear();
layer.getXForms().clear();
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(0.5);
try {
SubFlameWFFunc var = new SubFlameWFFunc();
String flameXML = new FlameWriter().getFlameXML(subFlame);
var.setRessource("flame", flameXML.getBytes());
var.setParameter("color_mode", 0);
double cs = (1.5 - Math.random() * 3.0);
if (MathLib.fabs(cs) < 0.4) {
cs = (Math.random() < 0.5 ? -0.3 - Math.random() : 0.3 + Math.random());
}
var.setParameter("colorscale_z", cs);
xForm.addVariation(1, var);
} catch (Exception ex) {
ex.printStackTrace();
Unchecker.rethrow(ex);
}
xForm.setColor(0);
xForm.setColorSymmetry(-0.22);
}
}
use of org.jwildfire.create.tina.io.FlameWriter in project JWildfire by thargor6.
the class SubFlameRandomFlameGenerator method embedFlame.
public Flame embedFlame(Flame pSubFlame) throws Exception {
Flame flame = new Flame();
flame.assign(pSubFlame);
Layer layer = flame.getFirstLayer();
layer.getFinalXForms().clear();
layer.getXForms().clear();
flame.getFirstLayer().setPalette(pSubFlame.getFirstLayer().getPalette().makeCopy());
// 1st xForm
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(0.5);
{
{
SubFlameWFFunc var = new SubFlameWFFunc();
String flameXML = new FlameWriter().getFlameXML(pSubFlame);
var.setRessource("flame", flameXML.getBytes());
xForm.addVariation(1, var);
}
}
xForm.setColor(0);
xForm.setColorSymmetry(-0.22);
}
// 2nd xForm
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(0.25 + Math.random() * 0.5);
xForm.setCoeff00(0.17254603006834707);
xForm.setCoeff01(0.6439505508593787);
xForm.setCoeff10(-0.6439505508593787);
xForm.setCoeff11(0.17254603006834707);
xForm.setCoeff20(1.5 + Math.random() * 2.5);
xForm.setCoeff21(-0.25 - Math.random() * 0.35);
xForm.addVariation(1, VariationFuncList.getVariationFuncInstance("linear3D", true));
xForm.setColor(Math.random());
xForm.setColorSymmetry(-0.62);
}
// 3rd xForm
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(0.25 + Math.random() * 0.5);
xForm.setCoeff00(0.17254603006834707);
xForm.setCoeff01(0.6439505508593787);
xForm.setCoeff10(-0.6439505508593787);
xForm.setCoeff11(0.17254603006834707);
xForm.setCoeff20(-3.0);
xForm.setCoeff21(0.3);
{
VariationFunc varFunc;
varFunc = VariationFuncList.getVariationFuncInstance("curl3D", true);
varFunc.setParameter("cx", -0.2 + 0.4 * Math.random());
varFunc.setParameter("cy", 0);
varFunc.setParameter("cz", 0);
xForm.addVariation(1, varFunc);
}
xForm.setColor(Math.random());
xForm.setColorSymmetry(0);
}
return flame;
}
use of org.jwildfire.create.tina.io.FlameWriter in project JWildfire by thargor6.
the class IFlamesController method createNewFlame.
private Flame createNewFlame() {
Flame flame = new Flame();
flame.setBGTransparency(prefs.isTinaDefaultBGTransparency());
flame.setCamRoll(0);
flame.setCamPitch(0);
flame.setCamYaw(0);
flame.setCamPerspective(0);
flame.setWidth(800);
flame.setHeight(600);
flame.setCamZoom(1);
{
Layer layer = flame.getFirstLayer();
new RandomGradientMutation().execute(layer);
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(0.5);
IFlamesFunc iflames = (IFlamesFunc) VariationFuncList.getVariationFuncInstance("iflames_wf", true);
if (imageLibrary.size() > 0) {
String imgFilename = imageLibrary.get((int) (Math.random() * imageLibrary.size())).getFilename();
iflames.getImageParams().setImageFilename(imgFilename);
}
if (flameLibrary.size() > 0) {
for (int i = 0; i < IFlamesFunc.MAX_FLAME_COUNT; i++) {
if (i > 1 && Math.random() < 0.33) {
iflames.getFlameParams(i).setFlameXML(null);
} else if (Math.random() < 0.50) {
Flame libFlame = flameLibrary.get((int) (Math.random() * flameLibrary.size())).getFlame();
String libFlameXML;
try {
libFlameXML = new FlameWriter().getFlameXML(libFlame);
} catch (Exception e) {
libFlameXML = null;
e.printStackTrace();
}
iflames.getFlameParams(i).setFlameXML(libFlameXML);
}
}
}
if (Math.random() < 0.5) {
iflames.getImageParams().setShape_distribution(ShapeDistribution.HUE);
} else {
iflames.getImageParams().setShape_distribution(ShapeDistribution.RANDOM);
}
for (int i = 0; i < IFlamesFunc.MAX_FLAME_COUNT; i++) {
iflames.getFlameParams(i).setSize(2.0 + Math.random() * 4.0);
}
iflames.getMotionParams().setPreview(previewButton.isSelected() ? 1 : 0);
xForm.addVariation(1.0, iflames);
}
return flame.makeCopy();
}
use of org.jwildfire.create.tina.io.FlameWriter in project JWildfire by thargor6.
the class IFlamesController method saveIFlameButton_clicked.
public void saveIFlameButton_clicked() {
try {
if (getFlame() != null) {
JFileChooser chooser = new FlameFileChooser(prefs);
if (prefs.getOutputFlamePath() != null) {
try {
chooser.setCurrentDirectory(new File(prefs.getOutputFlamePath()));
} catch (Exception ex) {
ex.printStackTrace();
}
}
if (chooser.showSaveDialog(centerPanel) == JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
new FlameWriter().writeFlame(getFlame(), file.getAbsolutePath());
getFlame().setLastFilename(file.getName());
messageHelper.showStatusMessage(getFlame(), "flame saved to disc");
prefs.setLastOutputFlameFile(file);
}
}
} catch (Throwable ex) {
errorHandler.handleError(ex);
}
}
use of org.jwildfire.create.tina.io.FlameWriter in project JWildfire by thargor6.
the class IFlamesController method saveIFlameToClipboardButton_clicked.
public void saveIFlameToClipboardButton_clicked() {
try {
if (getFlame() != null) {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
String xml = new FlameWriter().getFlameXML(getFlame());
StringSelection data = new StringSelection(xml);
clipboard.setContents(data, data);
messageHelper.showStatusMessage(getFlame(), "flame saved to clipboard");
}
} catch (Throwable ex) {
errorHandler.handleError(ex);
}
}
Aggregations