Gimp - 2.4 Guía Del Usuario

Descargar
Página de 653
GNU Image Manipulation Program
152 / 653
DB Browser and let’s get cookin’!
Let’s begin by making a new image. We’ll create a new variable, theImage, set to the result of calling GIMP’s built-in function
gimp-image-new
.
As you can see from the DB Browser, the function gimp-image-new takes three parameters -- the image’s width, height and
the type of image. Because we’ll later resize the image to fit the text, we’ll make a 10x10 RGB image. We’ll store the image’s
width and sizes in some variables, too, as we’ll refer to and manipulate them later in the script.
(define (script-fu-text-box inText inFont inFontSize inTextColor)
(let*
(
; define our local variables
; create a new image:
(theImageWidth
10)
(theImageHeight 10)
(theImage (car
(gimp-image-new
theImageWidth
theImageHeight
RGB
)
)
)
(theText)
;a declaration for the text
;we create later
Note: We used the value RGB to specify that the image is an RGB image. We could have also used 0, but RGB is more descriptive
when we glance at the code.
You should also notice that we took the head of the result of the function call. This may seem strange, because the database
explicitly tells us that it returns only one value -- the ID of the newly created image. However, all GIMP functions return a list,
even if there is only one element in the list, so we need to get the head of the list.
11.3.5.2
Adding A New Layer To The Image
Now that we have an image, we need to add a layer to it. We’ll call the gimp-layer-new function to create the layer, passing
in the ID of the image we just created. (From now on, instead of listing the complete function, we’ll only list the lines we’re
adding to it. You can see the complete script here.) Because we’ve declared all of the local variables we’ll use, we’ll also close
the parentheses marking the end of our variable declarations:
;create a new layer for the image:
(theLayer
(car
(gimp-layer-new
theImage
theImageWidth
theImageHeight
RGB-IMAGE
"layer 1"
100
NORMAL
)
)
)
) ;end of our local variables
Once we have the new layer, we need to add it to the image:
(gimp-image-add-layer theImage theLayer 0)
Now, just for fun, let’s see the fruits of our labors up until this point, and add this line to show the new, empty image: