Because scripts are created with a random gradient instruction, each time you run them, it will randomly change colours. But what if you have a favourite gradient set you want to use? Well, read on and we’ll get to how to make sure the scripts only run the gradient set you want.
Time Needed : 30 minutes
Fixed gradients, how to set them up inside a script.
- Grab your gradient
You'll want to first make sure you have access to your gradient file. If you know where this is, great. You'll need to copy the gradient file to the folder that your script is in. It will be a UGR file or a MAP file. So go ahead and copy it into the folder now. If you can just see it in JWildfire and want to save it you can go to the gradient area and click save. Save it to your script folder
- Saving UGR files
More often than not, you'll want to save the UGR file (which is a collection of gradients, rather than a MAP file which is a single gradient only. To do this you'll need to know where your gradients are saved. Go to the settings area of JWildfire to find the path to them.
- Look for your gradient in the folders
Your gradient will be a UGR file typically, but if it's a single map file that's fine also. So copy it to your script folder
- Getting your script to read your gradient file only.
Look at the code for your script, at the top you'll see a bunch of lines that start “import.org” etc You'll need to add the following lines underneath all the lines that start import.org so copy these three lines and paste them underneath the last line of the import.org section in your script, as seen in the picture.
- Adding the gradient selector
Once you've pasted the 3 lines above, you need to scroll down your script code. You're looking for the line that creates the random gradient. See example underneath.
// create a random gradient
Now, this has to be replaced with the code that's found at the bottom of these steps. So, copy all the code underneath these steps (underneath the title “Code to add for fixed gradient”) click the copy button, then switch back to your script. Highlight the random gradient lines, and paste the new code over the top of it.
- Change the line of code to point to your gradient.
String custom_code_file = script_dir + file_separator + “carr.ugr”;
When you've pasted the code from the bottom of this page over the random gradient instruction, look for the above line in your new code. What you're wanting to do is change the carr.ugr filename, to the filename of your gradient. So it might look like… This tells the new code to look for your gradient file and not the carr.ugr. In the screenshot above I've changed it to leafy.ugr which is a leaf coloured gradient file I copied into my script folder.
String custom_code_file = script_dir + file_separator + “yourfilename.ugr”;
- Save the script
So, once you've done all of this.. make sure to save your script, I usually save it as scriptname-copy.jwfscript so that I don't overwrite the original script. Then go to the script area of JWildfire, hit the scan button and run your new script. As long as the gradient file is in the same folder as your script, and you changed the name. You'll now see your script running, but only using that gradient.
- Notepad ++
Code to add for fixed gradient
// This CODE Will Read a Gradients File (*.map , *.ugr , *.xml) just from the directory where the script is installed // Put your *.ugr file in the same directory as your script is located, // you can distribute the *.ugr file in your zip file with the script file *.jwfscript UniversalPaletteReader gradientReader=new UniversalPaletteReader(); String script_path = this.getScriptPath(); String file_separator = System.getProperty("file.separator"); String script_dir = script_path.substring(0, script_path.lastIndexOf(file_separator)); String custom_code_file = script_dir + file_separator + "carr.ugr"; // Provide the path to your gradient here --- ANY GRADIENT FILE of *.map , *.ugr , *.xml may be used List gradients= gradientReader.readPalettes(custom_code_file ); // <------ For Universality, create folder C:/Gradients, and put the gradient file in it // Choose a random gradient from the gradient file double gradSize = gradients.size(); RGBPalette palete=(RGBPalette)gradients.get((int)(Math.random()* gradSize)); flame.setPalette(palete);