From Michael Bourne, 2 Years ago, written in Plain Text.
Embed
  1. import org.jwildfire.create.tina.base.Flame;
  2. import org.jwildfire.create.tina.base.XForm;
  3. import org.jwildfire.create.tina.palette.RGBPalette;
  4. import org.jwildfire.create.tina.script.ScriptRunnerEnvironment;
  5. import org.jwildfire.create.tina.transform.XFormTransformService;
  6. import org.jwildfire.create.tina.base.Layer;
  7. import org.jwildfire.create.tina.variation.Variation;
  8. import org.jwildfire.create.tina.variation.VariationFunc;
  9. import org.jwildfire.create.tina.variation.VariationFuncList;
  10. import org.jwildfire.create.tina.mutagen.RandomGradientMutation;
  11. import org.jwildfire.create.tina.transform.XFormTransformService;
  12. import org.jwildfire.create.tina.base.EditPlane;
  13.  
  14. public void run(ScriptRunnerEnvironment pEnv) throws Exception {
  15. // create a new flame
  16. Flame flame=new Flame();
  17. flame.getLayers().clear(); // get rid of the default layer because we create all layers by ourselves
  18. // set the flame main attributes
  19. flame.setCamRoll(0);
  20. flame.setCamPitch(0);
  21. flame.setCamYaw(0);
  22. flame.setCamPerspective(0);
  23. flame.setWidth(1159);
  24. flame.setHeight(652);
  25. flame.setPixelsPerUnit(265);
  26. flame.setCamZoom(0.27);
  27. flame.setBGTransparency(false);
  28. flame.setName("Julian-Bipolar 2");
  29. flame.setBrightness(80);
  30. flame.setWhiteLevel(220);
  31. flame.setGamma(3);
  32. flame.setLowDensityBrightness(0.1);
  33. //flame.setSaturation(1.2);
  34. // create layer 1
  35. {
  36. Layer layer = new Layer();
  37. flame.getLayers().add(layer);
  38. layer.setWeight(1);
  39. layer.setVisible(true);
  40. // create a random gradient
  41. new RandomGradientMutation().execute(layer);
  42. // create transform 1
  43. {
  44. XForm xForm = new XForm();
  45. layer.getXForms().add(xForm);
  46. xForm.setWeight(3.6);
  47. xForm.setColor(0.63);
  48. xForm.setColorSymmetry(0.235);
  49. xForm.setMaterial(0);
  50. xForm.setMaterialSpeed(0);
  51. xForm.setModGamma(0.4);
  52.  
  53. xForm.setCoeff00(0.4096); // a
  54. xForm.setCoeff10(0); // b
  55. xForm.setCoeff20(0.17171177); // e
  56. xForm.setCoeff01(0); // c
  57. xForm.setCoeff11(0.4096); // d
  58. xForm.setCoeff21(0.11478421); // f
  59.  
  60. xForm.setPostCoeff00(1.14083266);
  61. xForm.setPostCoeff10(0);
  62. xForm.setPostCoeff01(0);
  63. xForm.setPostCoeff11(1.14083266);
  64. xForm.setPostCoeff20(-0.29105138);
  65. xForm.setPostCoeff21(-0.39369486);
  66.  
  67. // variation 1
  68. {
  69. VariationFunc varFunc=VariationFuncList.getVariationFuncInstance("julian", true);
  70. varFunc.setParameter("power", 2);
  71. varFunc.setParameter("dist", 1);
  72. xForm.addVariation(1.45375993, varFunc);
  73. }
  74. // set default edit plane
  75. flame.setEditPlane(EditPlane.XY);
  76. // random affine transforms (uncomment to play around)
  77. XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, false);
  78. XFormTransformService.rotate(xForm, 360.0*Math.random(), false);
  79. // XFormTransformService.localTranslate(xForm, 1.0-2.0*Math.random(), 1.0-2.0*Math.random(), false);
  80. // random affine post transforms (uncomment to play around)
  81. // XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, true);
  82. // XFormTransformService.rotate(xForm, 360.0*Math.random(), true);
  83. // XFormTransformService.localTranslate(xForm, 1.0-2.0*Math.random(), 1.0-2.0*Math.random(), true);
  84. }
  85. // create transform 2
  86. {
  87. XForm xForm = new XForm();
  88. layer.getXForms().add(xForm);
  89. xForm.setWeight(0.175);
  90. xForm.setColor(1);
  91. xForm.setColorSymmetry(0);
  92. xForm.setMaterial(0);
  93. xForm.setMaterialSpeed(0);
  94.  
  95. xForm.setCoeff00(1); // a
  96. xForm.setCoeff10(0); // b
  97. xForm.setCoeff20(0.62793713); // e
  98. xForm.setCoeff01(0); // c
  99. xForm.setCoeff11(1); // d
  100. xForm.setCoeff21(0.45913682); // f
  101.  
  102. xForm.setPostCoeff00(1);
  103. xForm.setPostCoeff10(0);
  104. xForm.setPostCoeff01(0);
  105. xForm.setPostCoeff11(1);
  106. xForm.setPostCoeff20(0);
  107. xForm.setPostCoeff21(0);
  108.  
  109. // variation 1
  110. xForm.addVariation(0.325, VariationFuncList.getVariationFuncInstance("bubble", true));
  111. // variation 2
  112. xForm.addVariation(2.6, VariationFuncList.getVariationFuncInstance("pre_blur", true));
  113. // set default edit plane
  114. flame.setEditPlane(EditPlane.XY);
  115. // random affine transforms (uncomment to play around)
  116. XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, false);
  117. XFormTransformService.rotate(xForm, 360.0*Math.random(), false);
  118. // XFormTransformService.localTranslate(xForm, 1.0-2.0*Math.random(), 1.0-2.0*Math.random(), false);
  119. // random affine post transforms (uncomment to play around)
  120. // XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, true);
  121. // XFormTransformService.rotate(xForm, 360.0*Math.random(), true);
  122. // XFormTransformService.localTranslate(xForm, 1.0-2.0*Math.random(), 1.0-2.0*Math.random(), true);
  123. }
  124. // create transform 3
  125. {
  126. XForm xForm = new XForm();
  127. layer.getXForms().add(xForm);
  128. xForm.setWeight(0.5);
  129. xForm.setColor(0.2);
  130. xForm.setColorSymmetry(0);
  131. xForm.setMaterial(0);
  132. xForm.setMaterialSpeed(0);
  133.  
  134. xForm.setCoeff00(1); // a
  135. xForm.setCoeff10(0); // b
  136. xForm.setCoeff20(-0.75622536); // e
  137. xForm.setCoeff01(0); // c
  138. xForm.setCoeff11(1); // d
  139. xForm.setCoeff21(0.28358451); // f
  140.  
  141. xForm.setPostCoeff00(2.22405201);
  142. xForm.setPostCoeff10(0);
  143. xForm.setPostCoeff01(0);
  144. xForm.setPostCoeff11(2.22405201);
  145. xForm.setPostCoeff20(1.45762885);
  146. xForm.setPostCoeff21(-1.92572166);
  147.  
  148. // variation 1
  149. xForm.addVariation(0.589, VariationFuncList.getVariationFuncInstance("linear3D", true));
  150. // variation 2
  151. {
  152. VariationFunc varFunc=VariationFuncList.getVariationFuncInstance("bipolar", true);
  153. varFunc.setParameter("shift", 0);
  154. xForm.addVariation(1.37, varFunc);
  155. }
  156. // variation 3
  157. xForm.addVariation(2, VariationFuncList.getVariationFuncInstance("pre_blur", true));
  158. // variation 4
  159. {
  160. VariationFunc varFunc=VariationFuncList.getVariationFuncInstance("rectangles", true);
  161. varFunc.setParameter("x", -0.3);
  162. varFunc.setParameter("y", 1.9);
  163. xForm.addVariation(13.27637454, varFunc);
  164. }
  165. // set default edit plane
  166. flame.setEditPlane(EditPlane.XY);
  167. // random affine transforms (uncomment to play around)
  168. XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, false);
  169. XFormTransformService.rotate(xForm, 360.0*Math.random(), false);
  170. // XFormTransformService.localTranslate(xForm, 1.0-2.0*Math.random(), 1.0-2.0*Math.random(), false);
  171. // random affine post transforms (uncomment to play around)
  172. // XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, true);
  173. // XFormTransformService.rotate(xForm, 360.0*Math.random(), true);
  174. // XFormTransformService.localTranslate(xForm, 1.0-2.0*Math.random(), 1.0-2.0*Math.random(), true);
  175. }
  176.  
  177. // create transform 4
  178. {
  179. XForm xForm = new XForm();
  180. layer.getXForms().add(xForm);
  181. xForm.setWeight(0.5);
  182. xForm.setColor(0);
  183. xForm.setColorSymmetry(0);
  184. xForm.setMaterial(0);
  185. xForm.setMaterialSpeed(0);
  186.  
  187. xForm.setCoeff00(1); // a
  188. xForm.setCoeff10(0); // b
  189. xForm.setCoeff20(0.08102415); // e
  190. xForm.setCoeff01(0); // c
  191. xForm.setCoeff11(1); // d
  192. xForm.setCoeff21(-0.73596932); // f
  193.  
  194. xForm.setPostCoeff00(1);
  195. xForm.setPostCoeff10(0);
  196. xForm.setPostCoeff01(0);
  197. xForm.setPostCoeff11(1);
  198. xForm.setPostCoeff20(-0.4);
  199. xForm.setPostCoeff21(0);
  200.  
  201. // variation 1
  202. xForm.addVariation(0.05, VariationFuncList.getVariationFuncInstance("cylinder", true));
  203. // variation 2
  204. xForm.addVariation(3.6, VariationFuncList.getVariationFuncInstance("pre_blur", true));
  205. // set default edit plane
  206. flame.setEditPlane(EditPlane.XY);
  207. // random affine transforms (uncomment to play around)
  208. XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, false);
  209. XFormTransformService.rotate(xForm, 360.0*Math.random(), false);
  210. XFormTransformService.localTranslate(xForm, 1.0-2.0*Math.random(), 1.0-2.0*Math.random(), false);
  211. // random affine post transforms (uncomment to play around)
  212. XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, true);
  213. XFormTransformService.rotate(xForm, 360.0*Math.random(), true);
  214. XFormTransformService.localTranslate(xForm, 1.0-2.0*Math.random(), 1.0-2.0*Math.random(), true);
  215. }
  216. // create transform 5
  217. {
  218. XForm xForm = new XForm();
  219. layer.getXForms().add(xForm);
  220. xForm.setWeight(0.5);
  221. xForm.setColor(0);
  222. xForm.setColorSymmetry(0);
  223. xForm.setMaterial(0);
  224. xForm.setMaterialSpeed(0);
  225.  
  226. xForm.setCoeff00(1); // a
  227. xForm.setCoeff10(0); // b
  228. xForm.setCoeff20(-1.43817858); // e
  229. xForm.setCoeff01(0); // c
  230. xForm.setCoeff11(1); // d
  231. xForm.setCoeff21(0.06076811); // f
  232.  
  233. xForm.setPostCoeff00(1);
  234. xForm.setPostCoeff10(0);
  235. xForm.setPostCoeff01(0);
  236. xForm.setPostCoeff11(1);
  237. xForm.setPostCoeff20(0);
  238. xForm.setPostCoeff21(0);
  239.  
  240. // variation 1
  241. xForm.addVariation(-0.02, VariationFuncList.getVariationFuncInstance("linear3D", true));
  242. // set default edit plane
  243. flame.setEditPlane(EditPlane.XY);
  244. // random affine transforms (uncomment to play around)
  245. XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, false);
  246. XFormTransformService.rotate(xForm, 360.0*Math.random(), false);
  247. XFormTransformService.localTranslate(xForm, 1.0-2.0*Math.random(), 1.0-2.0*Math.random(), false);
  248. // random affine post transforms (uncomment to play around)
  249. // XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, true);
  250. // XFormTransformService.rotate(xForm, 360.0*Math.random(), true);
  251. // XFormTransformService.localTranslate(xForm, 1.0-2.0*Math.random(), 1.0-2.0*Math.random(), true);
  252. }
  253. // create final transform 1
  254. {
  255. XForm xForm = new XForm();
  256. layer.getFinalXForms().add(xForm);
  257. xForm.setWeight(0);
  258. xForm.setColor(0);
  259. xForm.setColorSymmetry(0);
  260. xForm.setMaterial(0);
  261. xForm.setMaterialSpeed(0);
  262.  
  263. xForm.setCoeff00(0.48446552); // a
  264. xForm.setCoeff10(0); // b
  265. xForm.setCoeff20(0); // e
  266. xForm.setCoeff01(0); // c
  267. xForm.setCoeff11(0.48446552); // d
  268. xForm.setCoeff21(0); // f
  269.  
  270. xForm.setPostCoeff00(0.91682478);
  271. xForm.setPostCoeff10(0);
  272. xForm.setPostCoeff01(0);
  273. xForm.setPostCoeff11(0.91682478);
  274. xForm.setPostCoeff20(0);
  275. xForm.setPostCoeff21(0);
  276.  
  277. // variation 1
  278. xForm.addVariation(1.52, VariationFuncList.getVariationFuncInstance("foci", true));
  279. // set default edit plane
  280. flame.setEditPlane(EditPlane.XY);
  281. // random affine transforms (uncomment to play around)
  282. // XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, false);
  283. // XFormTransformService.rotate(xForm, 360.0*Math.random(), false);
  284. // XFormTransformService.localTranslate(xForm, 1.0-2.0*Math.random(), 1.0-2.0*Math.random(), false);
  285. // random affine post transforms (uncomment to play around)
  286. // XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, true);
  287. // XFormTransformService.rotate(xForm, 360.0*Math.random(), true);
  288. // XFormTransformService.localTranslate(xForm, 1.0-2.0*Math.random(), 1.0-2.0*Math.random(), true);
  289. }
  290. }
  291. // Either update the currently selected flame (to not need to create a new thumbnail
  292. // in the thumbnail ribbon after each run of the script...
  293. Flame selFlame = pEnv.getCurrFlame();
  294. if(selFlame!=null) {
  295. selFlame.assign(flame);
  296. pEnv.refreshUI();
  297. }
  298. // ...or load the flame in the editor and refresh the UI
  299. else {
  300. pEnv.setCurrFlame(flame);
  301. }
  302. }