This laboratory is also available in PDF.
Summary: We explore two techniques for algorithmically generating interesting images: Random drawing and Color grids.
For this laboratory, you will need to have a copy of
grid.scm in your GIMP
a. Open a new terminal window.
ln -f -s /home/rebelsky/Web/Courses/CS151/2007S/Examples/grid.scm .gimp-2.2/scripts/grid.scm
c. Start GIMP and verify that themenu contains a submenu.
a. Set the current brush to a medium circle.
(set-brush "Circle (09)")
a. From the
Color Grid. A dialog
box should appear. Enter 100 for the width and height, and 10 for the
horizontal and vertical spacing. Observe the image that appears.
b. What do you expect to happen if you use 8 for the horizontal and vertical spacing? Confirm or reject your prediction experimentally.
c. Set the current brush to a larger fuzzy circle.
(set-brush "Circle Fuzzy (15)")
d. What do you expect to happen if you again use 8 for the horizontal and vertical spacing? Confirm or reject your prediction experimentally.
e. What do you expect to happen if you use
func3 for the red
component (continuing to use
func2 for green and
for blue)? Confirm or reject your prediction experimentally.
f. Try one or two other brushes and one or two other arrangements of functions.
a. With DrScheme, create a new file on your desktop,
b. Add the following function to that file.
(define func4 (lambda (x y) (modulo (+ (* 3 x) (* 5 y)) 256)))
c. Make a link to that file in your Script-Fu scripts folder by opening a new terminal window and typing the following command:
ln -s /home/username/Desktop/components.scm .gimp-2.2/scripts/components.scm
(You only need to do this once, but it makes sure that the GIMP knows about the file.)
d. Refresh scripts by selecting
e. Verify that you can now use
func4 in building a Color Grid.
f. Add the following procedure to
(define func5 (lambda (x y) (modulo (* x (abs (sin y))) 256)))
g. Verify that you can use this procedure. (If you can't remember that you need to save the file and to refresh scripts.)
h. Add a few of your own
interesting component functions.
As you may have noted from the previous exercise, it can be a bit of a pain to remember to save and refresh every time you define a new component function. As the reading suggests, we can instead use anonymous functions.
a. Open the Color Grid dialog box, use the following for the red, green, and blue components, and then display the grid.
(lambda (x y) (modulo (* x 5) 256))
(lambda (x y) (modulo (* y 5) 256))
(lambda (x y) 0)
b. Try some functions of your own design. Remember that each function has
(lambda (x y) expression) and that the
expression should return a value in the range [0..255].
Some people (myself included) prefer to generate their grids from the console.
As you may recall from the reading, the
color-grid procedure has
For example, here's the command that we might use for the first grid we drew (100x100, 10x10 grid)
(color-grid 100 100 10 10 func1 func2 func3)
a. Try that example.
b. Try varying the parameters (e.g., using a different width, height, spacing, or function).
c. Try using lambda expressions for the functions. For example
(color-grid 100 100 8 9 (lambda (x y) (modulo (* x y) 256)) (lambda (x y) (modulo (* x 5) 256)) (lambda (x y) (trunc (* 255 (abs (sin (* x y)))))))
I usually create these pages
on the fly, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Thu Sep 13 20:54:14 2007.
The source to the document was last modified on Mon Apr 9 10:28:01 2007.
This document may be found at
You may wish to validate this document's HTML ; ;Samuel A. Rebelsky, email@example.com
http://creativecommons.org/licenses/by-nc/2.5/or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.