Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming with Images (continued). Another teachpack – “tiles.ss” Download from the website: “http://www.adelphi.edu/sbloch/class/171/tiles.plt Save.

Similar presentations


Presentation on theme: "Programming with Images (continued). Another teachpack – “tiles.ss” Download from the website: “http://www.adelphi.edu/sbloch/class/171/tiles.plt Save."— Presentation transcript:

1 Programming with Images (continued)

2 Another teachpack – “tiles.ss” Download from the website: “http://www.adelphi.edu/sbloch/class/171/tiles.plt Save to the folder: “C:\ProgramFiles\PLT\Teachpack” Open DrScheme. Go to Add Teachpack. Right click on file, then click open. These creates a second file. Install it. Press Run and Let’s Have Fun!

3 Exercise 4: Using “tiles.ss” Make sure that “world.ss” is installed. Make sure that “world.ss” is installed. Download and install “tiles.ss” on your computer. Press “Run”. Download and install “tiles.ss” on your computer. Press “Run”. Put the rectangle (from last class) next to the circle. Put the rectangle (from last class) next to the circle. Find the hands picture on your computer in “My Pictures”. Define it as a variable. Find the hands picture on your computer in “My Pictures”. Define it as a variable. Reflect the hands picture horizontally. Reflect the hands picture horizontally. Reflect the hands picture vertically. Reflect the hands picture vertically.

4 Writing our own function… ; Purpose: To create the horizontal mirror image of any picture. ; Contract: image -> image

5 Writing our own function… ; Purpose: To create the horizontal mirror image of any picture. ; Contract: image -> image “Examples of mirror-horiz:” (define ADAM ) (mirror-horiz ADAM) “should be” (image-beside Adam (reflect-horiz ADAM))

6 Writing our own function… ; Purpose: To create the horizontal mirror image of any picture. ; Contract: image -> image (define (mirror-horiz pic) (… pic …) ) “Examples of mirror-horiz:” (define ADAM ) (mirror-horiz ADAM) “should be” (image-beside ADAM (reflect-horiz ADAM))

7 Writing our own function… ; Purpose: To create the horizontal mirror image of any picture. ; Contract: image -> image (define (mirror-horiz pic) (image-beside pic (reflect-horiz pic))) “Examples of mirror-horiz:” (mirror-horiz ADAM) “should be” (image-beside ADAM (reflect-horiz ADAM))

8 Exercise 5: counterchange Define a function called counterchange that takes in two images and returns a 2x2 arrangement of them as shown here.

9 Solution: counterchange ; Purpose: To create a small checkerboard pattern with any ; two images. ; Contract: image image -> image ; Examples: ;(counterchange (rectangle 50 30 ‘solid ‘blue) (rectangle 20 ;20 ‘solid ‘red)) “should be” “a blue rectangle next to a red ;square with a red square next to a blue rectangle below it” ;(counterchange (circle 30 ‘solid ‘green) hands) “should be” ;“a green circle next to the hands with the hands next to a ;green circle below it”

10 Solution: counterchange ; Skeleton: ; (define (counterchange pic1 pic2) ; ( … pic1 … pic2 …)) ;Informal Thinking ;We need to put two images next to each other. How do we do this? ;How do we put an image directly above another?

11 Solution: counterchange ; Function: (define (counterchange pic1 pic2) (image-above (image-beside pic1 pic2) (image-beside pic2 pic1) )

12 Last five weeks… Programs that deal with Conditions Working with Compound Data The final!


Download ppt "Programming with Images (continued). Another teachpack – “tiles.ss” Download from the website: “http://www.adelphi.edu/sbloch/class/171/tiles.plt Save."

Similar presentations


Ads by Google