1 / 12

Programming with Images (continued)

Programming with Images (continued). Another teachpack – “tiles.ss”. Download from the website: “http://www.adelphi.edu/sbloch/class/171/tiles.plt Save to the folder: “C:ProgramFilesPLTTeachpack” Open DrScheme. Go to Add Teachpack. Right click on file, then click open.

phillipl
Download Presentation

Programming with Images (continued)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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. • Download and install “tiles.ss” on your computer. Press “Run”. • 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. • Reflect the hands picture horizontally. • 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!

More Related