protected ErrorHandler getErrorHandler() {
return errorHandler;
}
public void bokehBtn_clicked() {
Flame flame = getCurrFlame();
if (flame != null) {
saveUndoPoint();
flame.setCamDOF(0.1 + Math.random() * 0.3);
flame.setNewCamDOF(true);
flame.setCamPitch(30 + Math.random() * 20.0);
flame.setCamYaw(15 - Math.random() * 30.0);
flame.setCamPerspective(0.05 + Math.random() * 0.2);
flame.setCamDOFArea(0.2 + Math.random() * 0.5);
for (Layer layer : flame.getLayers()) {
Variation crackle = null;
for (XForm xform : layer.getXForms()) {
for (int i = xform.getVariationCount() - 1; i >= 0; i--) {
Variation var = xform.getVariation(i);
if (var.getFunc().getName().equals(CrackleFunc.VAR_NAME)) {
VariationFunc varFunc = var.getFunc();
double scale = (Double) varFunc.getParameter(CrackleFunc.PARAM_SCALE);
if (MathLib.fabs(scale) < MathLib.EPSILON) {
crackle = var;
xform.setColor(Math.random());
break;
}
}
}
}
if (crackle == null) {
XForm xform = new XForm();
xform.setWeight(0.5);
layer.getXForms().add(xform);
crackle = xform.addVariation(1.0, VariationFuncList.getVariationFuncInstance(CrackleFunc.VAR_NAME));
crackle.getFunc().setParameter(CrackleFunc.PARAM_SCALE, 0.0);
}
crackle.setAmount(1.0 + Math.random() * 2.0);
crackle.getFunc().setParameter(CrackleFunc.PARAM_DISTORT, 1.5 + Math.random() * 1.5);
crackle.getFunc().setParameter(CrackleFunc.PARAM_CELLSIZE, 0.5 + Math.random() * 2.0);
if (Math.random() < 0.33) {
flame.setFocusX(0.33 - Math.random() * 0.66);
flame.setFocusY(0.25 - Math.random() * 0.50);
flame.setFocusZ(0.1 - Math.random() * 0.2);
}
else {
flame.setFocusX(0.0);
flame.setFocusY(0.0);
flame.setFocusZ(0.0);
}
flame.setCamDOFScale(1.5 + Math.random() * 2.0);
flame.setCamDOFAngle(20.0 * Math.random());
flame.setCamDOFParam1(0);
flame.setCamDOFParam2(0);
flame.setCamDOFParam3(0);
flame.setCamDOFParam4(0);
flame.setCamDOFParam5(0);
double rnd = Math.random();
if (rnd < 0.1) {
flame.setCamDOFShape(DOFBlurShapeType.BUBBLE);
flame.setCamDOFFade(0.6 + Math.random() * 0.4);
}
else if (rnd < 0.2) {
flame.setCamDOFShape(DOFBlurShapeType.HEART);
if (Math.random() < 0.25) {
flame.setCamDOFFade(0.2 + Math.random() * 0.8);
}
else {
flame.setCamDOFFade(0.0);
}
}
else if (rnd < 0.4) {
flame.setCamDOFShape(DOFBlurShapeType.NBLUR);
flame.setCamDOFFade(0.0);
flame.setCamDOFParam1(3 + Math.random() * 5); // num edges
if (Math.random() < 0.33) {
flame.setCamDOFParam2(2 + Math.random() * 5); // num stripes
flame.setCamDOFParam3(1);// ratio stripes
flame.setCamDOFParam4(0);// ratio hole
flame.setCamDOFParam5(Math.random() < 0.33 ? 1 : 0);// circum circle
}
}
else if (rnd < 0.6) {
flame.setCamDOFShape(DOFBlurShapeType.SINEBLUR);
flame.setCamDOFFade(0.0);
flame.setCamDOFParam1(1.2 + Math.random());
}
else if (rnd < 0.8) {
flame.setCamDOFFade(0.2 + Math.random() * 0.8);
flame.setCamDOFShape(DOFBlurShapeType.STARBLUR);
flame.setCamDOFParam1(4 + Math.random() * 6);// power
flame.setCamDOFParam2(0.40162283177245455973959534526548);// range
}
else if (rnd < 0.9) {
flame.setCamDOFShape(DOFBlurShapeType.RECT);
flame.setCamDOFFade(0.0);
flame.setCamDOFParam1(0.4 + Math.random() * 0.4);
}
}
refreshUI();
}