(image-new width
height ) creates and returns an image of
a specified width and height. It returns a number that the GIMP and
MediaScript use to
identify the image. You will find it easiest to assign a name to the
image, as in the following.
image-new
procedure makes all the pixels in the image the same color as the background
color. You'll learn about setting the background color a little bit later
in this reading.
(image-load
file-name ). For example, you can load
a picture of one of the CS faculty with the
following definition.
image-id , which is an integer
representing the image.
(image-show
image-id ).
image-show returns the
id of the image it shows.
(image-width
image ) and
(image-height
image ).
(context-list-brushes)
gives a list of the names of all the available brushes.
(context-list-brushes name ) gives a list of the names of all the available brushes that include (context-list-brushes "circle") lists all the brushes whose name includes the word "circle".
(context-set-brush! brush-name )
sets the working brush. For example, (context-set-brush! "Pepper").
(context-set-fgcolor!
color ) and
(context-set-bgcolor!
color ). At this point in your
programming career, you can assume that colors are given
by strings, and you should stick to the primary colors.
However, if you want to explore a bit further, you can use
(context-list-colors )
to get a list of all colors. You can also use
(context-list-colors
pattern ), to get a
list of colors that contain a particular string, such as
(context-list-colors "red") to get
a list of all colors whose name includes the word red.
image-select-ellipse! and
image-select-rectangle!. The two procedures take exactly
the same list of parameters:
image, the image in which to select a region;
operation, the way in which we want to update the selection;
left, the left edge of the selected region;
top, the top edge of the selected region;
width, the width of the selected region; and
height, the height of the selected region.
left and top represent the left
edge and top edge of the rectangle that bounds the ellipse.
operation, all of the remaining parameters should
be obvious. The operation stems from an interesting, but useful, design
decision in GIMP: Often, we build more complex images by selecting
more complex regions. However, if our only building blocks for describing
selections are rectangles and ovals, we need appropriate ways to combine
those building blocks. That's where the operation comes into play. The
operation can be
REPLACE, in which case the old selection is
replaced by the new selection;
ADD, in which case the old selection is extended
by the new selection, even if the two selections are non-contiguous;
SUBTRACT (or SUB), in which case any pixels
in the the
old selection that are also in the new selection are de-selected; and
INTERSECT, in which case only pixels that
are in both the old and new selections remain selected.
(image-select-nothing! image) de-selects everything.
(image-select-all! image) selects everything in the
image.
(image-fill-selection! image). You can trace the exterior
of the selection with (image-stroke-selection! image). You've
seen examples of both commands in the code above. The third
possibility is that you can clearthe selection with
image-clear-selection!. In simple images, clearing a
selection results in the selection getting filled by the background
color. In layered images, clearing the selection may reveal images
from lower layers.
(context-update-displays!).
(image-blot! image
col row ) draws
a single spot at the specified position using the current brush and
foreground color.
(image-draw-line! image c1 r1 c2
r2 ) draws a line from (