#lang racket (require "hw4provided.rkt") ; change file name as appropriate ;; A simple library for displaying a 2x3 grid of pictures: used ;; for fun in the tests below (look for "Tests Start Here"). (require (lib "graphics.rkt" "graphics")) (open-graphics) (define window-name "CSE341, Homework 4") (define window-width 700) (define window-height 500) (define border-size 100) (define approx-pic-width 200) (define approx-pic-height 200) (define pic-grid-width 3) (define pic-grid-height 2) (define (open-window) (open-viewport window-name window-width window-height)) (define (grid-posn-to-posn grid-posn) (when (>= grid-posn (* pic-grid-height pic-grid-width)) (error "picture grid does not have that many positions")) (let ([row (quotient grid-posn pic-grid-width)] [col (remainder grid-posn pic-grid-width)]) (make-posn (+ border-size (* approx-pic-width col)) (+ border-size (* approx-pic-height row))))) (define (place-picture window filename grid-posn) (let ([posn (grid-posn-to-posn grid-posn)]) ((clear-solid-rectangle window) posn approx-pic-width approx-pic-height) ((draw-pixmap window) filename posn))) (define (place-repeatedly window pause stream n) (when (> n 0) (let* ([next (stream)] [filename (cdar next)] [grid-posn (caar next)] [stream (cdr next)]) (place-picture window filename grid-posn) (sleep pause) (place-repeatedly window pause stream (- n 1))))) ;; Tests Start Here ; These definitions will work only after you do some of the problems ; so for convenience they are initially commented out. ; Add more tests as appropriate of course. ;(define nums (sequence 0 5 1)) ;(define files (string-append-map ; (list "steele" "curry" "lambda" "parens" "rational") ; ".jpg")) ;(define (one-visual-test) ; (place-repeatedly (open-window) 0.5 (cycle-lists nums files) 25))