http://www.linuxplanet.com/linuxplanet/tutorials/6734/1
Creating a Fancy 3D-Effect GIMP Plugin in PythonYour Fresh New BlobiPy PluginApril 23, 2009 Last time I wrote about the basics of a GIMP plug-in written in Python. But how do you figure out how to do anything that's actually useful? This article will show you. Rounded 3D textGIMP is great for adding text to images. You can pick a nice font and color, but it still looks flat
It looks a little better if you add a drop shadow,
but what if you want the letters to look more rounded and three-dimensional? Here's a technique that gives a nice 3-D effect:
It makes a nice 3-D effect.
But it's a lot of steps. Who wants to do that every time? Let's make a Python script to do it. BlobiPyThe first step is to pick a name for your script. I called this technique "blobify" when I wrote it in script-fu, since it makes the letters look blobby. I showed it in a talk on GIMP scripting, and when I got to the Python section of the talk, a clever audience member suggested that the Python version should be "blobi-PY". And so it should! So the create a file called $HOME/.gimp-2.6/plug-ins/blobipy and make it executable, as in the previous article. The blobipy script will need at least a register function and a function that will do the real work. Start with something like this: #!/usr/bin/env python In the register function, I've specified three parameters for the script: a current image and a current layer -- "drawable" is just another name for "layer" -- and how much to blur. The python_blobify function takes three arguments corresponding to these three parameters. The image and layer will be passed in automatically; the blur amount will be chosen by the user from a dialog that looks like Figure 4.
PF_SPINNER is a way of specifying a numeric amount: the default value is 7, but it can adjust from 0 to 50 by increments of 1 at a time. Save the file and restart gimp. The script should show up in the Image window menus as Image->Filters->Light and Shadow->BlobyPy. |