In Scheme, we write larger programs and functions by combining the results of smaller ones. This set of questions helps you practice combining programs. Using a set of functions that we've provided for you, you will create images of swatches of fabric and items of clothing printed in those fabrics. The functions we've already written are in a file called a teachpack. Go to the Language menu in DrScheme and choose Clear all teachpacks. Now right-click on this link: the fabric teachpack and download it to your computer, then use the Add Teachpack option under the Language menu to load the teachpack contents into DrScheme (use "Install Teachpack..."). After you add the teachpack, hit the Run button.
The teachpack provides three images of clothing - a white tshirt, a white hat, and a pair of white gloves, and three smaller images that can be used for logos or to add prints to a fabric - a worm, a chili pepper, and a flower. It also provides a set of functions for creating fabric in different colors and prints, that are sized to fit certain items of clothing. Here is a description of the functions and images in the teachpack.
create-solid-fabric to create a swatch of red fabric big enough
for a t-shirt (Hint: Look in the image.ss documentation in DrScheme's helpdesk to
get information about
functions that return the size of an image)
add-print and create-solid-fabric to create a swatch of red
fabric with a worm print. Your swatch should be sized big enough for a
tshirt.
add-horiz-stripe to add blue stripes of width 5 to the fabric you
created in the previous step. The stripes should not cover the images
of the worms.
overlay to create an image of a tshirt printed in the fabric you created in the previous step.
Use comments in your file to clearly indicate the number of the problem you are solving.
define to create a fabric of your own design, sized for a
tshirt. Name your fabric
TSHIRT-FABRIC. Your fabric design
should involve the use of at least two functions from the
fabric teachpack.
create-sized-swatch that consumes
an image of a clothing item and produces an image of a
swatch of fabric of your own design, that is sized correctly for the
given clothing item.
This is a
function - don't forget to document it with a contract
and purpose. Show three test cases for your function, one for
each kind of clothing.
cut-clothing that consumes an image
for a clothing item and an image of a swatch of fabric
sized to fit that clothing item, and produces an image
of the clothing item in the given fabric. This is a
function - don't forget to document it with a contract
and purpose. Show two test cases for your function: one which creates
an image of a tshirt printed in TSHIRT-FABRIC, and one which
uses create-sized-swatch to create an image
of gloves.
add-center-logo that consumes an image for
a logo and an image for a clothing item and produces an
image of the clothing item with the logo centered on it.
As before, start with a contract and purpose.
Show two test
cases for your function, at least one of which creates a clothing item in which
the logo appears over a printed or striped fabric.
Write a function stack-logos that consumes images
of two logos and returns an image with the first logo just above the
second logo.
[HINT: use create-solid-fabric to create an image
large enough for the two logos.] You should center the logos on the
fabric. Start with
a contract and purpose, and provide test
cases.
Note that Scheme has a function max that consumes two
numbers and produces the larger of the numbers.
Write a function side-by-side-logos that consumes
images of two logos and returns an image with the first logo to the
left of the second logo.
[HINT: use create-solid-fabric to create an
image large enough for the two logos.] You should center the logos on the
fabric. Start with
a contract and purpose, and provide test
cases.
Using web-based turnin, turn in a single file hw1.scm containing all code and documentation for this assignment. Your name must be listed in a comment at the top of the file. Files submitted after 11:59pm on Wednesday, September 3, will be considered late and will be given a grade of zero.