1 About This Teachpack
2 Installation
3 Functions
image-above
image-above-align-right
image-above-align-left
image-above-align-center
image-beside
image-beside-align-top
image-beside-align-bottom
image-beside-align-center
reflect-vert
reflect-horiz
reflect-main-diag
reflect-other-diag
rotate-cw
rotate-ccw
rotate-180
show-pinhole
crop-top
crop-bottom
crop-left
crop-right
4 Functions from image.ss

Tiles Teachpack

 (require tiles/tiles)

1 About This Teachpack

Provides a variety of functions for combining and manipulating images. Imagine that each image were on a ceramic tile; you would expect to be able to put two tiles together side by side, or one above another, or rotate a tile, etc. That’s exactly what this teachpack provides.

2 Installation

If you’re reading this, you’ve probably already installed the teachpack successfully, but if you need to install it on a different machine, ...
  • start DrScheme

  • switch languages to Module and click "Run"

  • in the Interactions pane, type
      (require (planet sbloch/tiles))

  • after a few seconds, you should see the message "Wrote file "tiles.ss" to installed-teachpacks directory."

  • switch languages back to one of the HtDP languages, like Beginning Student

  • from the Language menu, choose "Add Teachpack..." and select "tiles.ss"

  • click "Run"

3 Functions

(image-above img1 img2 ...)  image?
  img1 : image?
  img2 : image?
Combines two or more images into one, putting the first above the second (above the third, ...).

(image-above-align-right img1 img2 ...)  image?
  img1 : image?
  img2 : image?
Just like image-above, but lines up the right-hand edges of all the images.

(image-above-align-left img1 img2 ...)  image?
  img1 : image?
  img2 : image?
Just like image-above, but lines up the left-hand edges of all the images.

(image-above-align-center img1 img2 ...)  image?
  img1 : image?
  img2 : image?
Just like image-above, but lines up the centers of all the images.

(image-beside img1 img2 ...)  image?
  img1 : image?
  img2 : image?
Combines two or more images into one, putting the first to the left of the second (to the left of the third, ...).

(image-beside-align-top img1 img2 ...)  image?
  img1 : image?
  img2 : image?
Just like image-beside, but lines up the top edges of all the images.

(image-beside-align-bottom img1 img2 ...)  image?
  img1 : image?
  img2 : image?
Just like image-beside, but lines up the bottom edges of all the images.

(image-beside-align-center img1 img2 ...)  image?
  img1 : image?
  img2 : image?
Just like image-beside, but lines up the centers of all the images.

(reflect-vert img)  image?
  img : image?

Flips an image top-to-botom.

(reflect-horiz img)  image?
  img : image?
Flips an image left-to-right.

(reflect-main-diag img)  image?
  img : image?
Flips an image from top-right to bottom-left, leaving the top-left and bottom-right unchanged.

(reflect-other-diag img)  image?
  img : image?
Flips an image from top-left to bottom-right, leaving the top-right and bottom-left unchanged.

(rotate-cw img)  image?
  img : image?
Rotates an image 90 degrees clockwise.

(rotate-ccw img)  image?
  img : image?
Rotates an image 90 degrees counterclockwise.

(rotate-180 img)  image?
  img : image?
Rotates an image 180 degrees around its center.

(show-pinhole img)  image?
  img : image?
Overlays a small black dot at the pinhole of the given image, so you can see where it is. (This function will go away when pinholes go away....)

(crop-top img pixels)  image?
  img : image?
  pixels : natural-number/c
Chops off the specified number of pixels from the top of the image.

(crop-bottom img pixels)  image?
  img : image?
  pixels : natural-number/c
Chops off the specified number of pixels from the bottom of the image.

(crop-left img pixels)  image?
  img : image?
  pixels : natural-number/c
Chops off the specified number of pixels from the left side of the image.

(crop-right img pixels)  image?
  img : image?
  pixels : natural-number/c
Chops off the specified number of pixels from the right side of the image.

4 Functions from image.ss

Since anybody using these functions will almost certainly also want to use other image-creation and image-manipulation functions, this teachpack includes the standard teachpack image.ss. That is, if you have tiles.ss loaded, you don’t also need image.ss (and you’re better off not loading it).