- This lab describes how to install DrRacket on your machine.
- This lab will involve the running of Racket (Scheme) code, but it
does not require an understanding of the code at this time.
- You will submit an image file that you will create following the
installation process.
- Installation summary:
- Download DrRacket from the web.
- Install DrRacket on your machine.
- Install graphics manipulation procedures.
- Install images to accompany Chapter 1 of our text.
- Go to http://www.racket-lang.org and
click Download.
- Select your platform (Linux, Mac, or Windows) and click the
button labeled with the download package. (Note: For Ubuntu Linux
users, there is a convenient Ubuntu PPA package, if you are
familiar with Ubuntu software repositories.)
- The download may take a few minutes depending on your connection
speed.
- Execute the download package, and follow the installation and
launch instructions, which will vary
depending on your platform.
Depending on your operating system, the DrRacket executable may be on
your desktop, or you may need to find it with your window system's file
manager.
Look for the DrRacket icon:
and launch the executable. As it is loading, a window like this will
appear:
Note: The current Racket version is 8.2.
- On first running, you will have to choose a programming language.
- Click Language
on DrRacket's menu bar and select Choose Language.
- Select The Racket Language, and click OK
(see diagram at right).
- Put the language directive "#lang racket" in the
definitions pane (the top one) of DrRacket.
- Go to DrRacket's tool bar and click the Run button.
- Test the language by going to the interaction pane (the lower one)
and typing
(+ 2 3)
at the DrRacket prompt > .
- After pressing
Enter on the keyboard, the result 5 should be returned.
- You are now ready to use DrRacket for non-graphical applications.
Our text book has written some standard procedures for manipulating
images in DrRacket programs.
This section describes how to install and use these procedures.
- The graphics manipulation procedures need only be installed once
as long as DrRacket is installed on your own machine.
- Click File on DrRacket's menu bar, select Install
Package..., and specify the package source:
https://gustavus.edu/+max/concabs/schemes/drscheme/concabs.zip
then click Install.
- Upon successful installation you should see:
then click Close
- Add to the definitions pane of DrRacket so that the it looks like:
#lang racket
(require (lib "fungraph.ss" "concabs"))
- Click Run on the tool bar.
- Go to the interaction pane and enter the expression:
(filled-triangle -1 -1 0 1 1 -1)
- A black triangle should be displayed:
This section describes more graphics operations, and also a way to save
graphical images to files.
You will be asked to enter some Racket
(Scheme) code to verify that they have been correctly installed. Enter
the code into the interaction window exactly as it is given here. It is
not necessary that you understand it at this time.
Download and save this file to a folder of your choice:
graphics.scm.
In DrRacket, create a new tab, open
graphics.scm, and run
it. This will create the quilting basic blocks
test-bb
and
nova-bb. You can evaluate them in the interaction window,
but they will not produce any images. This is because they are not
actually images, but
procedures that make images.
To produce the images, you need to download, open, and run this file:
show.scm. Make sure this
file is located in the same folder as
graphics.scm.
In the interaction window, now enter
(show test-bb)
and you should see:
A common graphics operation is to produce a mirror image of an image.
Define the mirror image of
test-bb in the interaction window:
> (define test-bb-mirrored (make-mirrored-image test-bb))
It looks like this:
Another graphics operation is to overlay an image on another, provided
they are the same size (that is, their display areas have the same
width and height).
Overlay
test-bb and
test-bb-mirrored to get a
triangle:
> (define triangle (make-overlaid-image test-bb test-bb-mirrored))
It looks like this:
To rotate an image is to turn it around a center
point. The
make-turned-image operation turns an image by 90
degrees to the right.
Turn the triangle by 180 degrees to get an inverted
triangle as shown below. Note that this is accomplished with
consecutive applications of
make-turned-image:
> (define inverted-triangle (make-turned-image (make-turned-image triangle)))
We can stack an image on another to create a new image whose size is
the sum of the sizes of the images. The images are not overlaid.
Stack the triangle on the inverted triangle to get a diamond:
> (define diamond (make-stacked-image triangle inverted-triangle))
The graphics examples so far render images to a display screen
using
show. We can
also save images to files using the Encapsulated PostScript (eps)
format.
Instead of showing the image, save it to a file
using
image->eps.
Save our diamond image to a file named "
Diamond":
> (image->eps diamond "Diamond")
The "
.eps" file extension will be automatically added.
Diamond.eps will be found in the same folder
as
graphics.scm. It can be opened and viewed with any standard
document viewer.
Submit
Diamond.eps by going to
under the assignment
Lab: DrRacket Installation and Setup
Here is a summary of the commands that produce
Diamond.eps,
once
graphics.scm has been opened and run:
> (define test-bb-mirrored (make-mirrored-image test-bb))
> (define triangle (make-overlaid-image test-bb test-bb-mirrored))
> (define inverted-triangle (make-turned-image (make-turned-image triangle)))
> (define diamond (make-stacked-image triangle inverted-triangle))
> (image->eps diamond "Diamond")