; interpolate-image : image image number -> image
; Produce image interpolated n/DENOM between
; i1 and i2
; !!! write two check-expect expressions for interpolate-image, one
; for when n = DENOM, the other for whem n = NUMER
(define (interpolate-image i1 i2 n)
(local ; f is defined only inside interpolate-image
[(define (f c1 c2) (interpolate-color (/ n DENOM) c1 c2))]
(map-images f i1 i2)))
I was initially unfamiliar with the "local" clause and so this created a bit of confusion for me. Luckily, Professor Heap was available during office hours and helped me understand what the function was trying to do:
You should know that interpolate-color takes in a fraction and two colours to produce a colour that is an interpolate of the colours, by whatever fraction was given. For example, (interpolate-color 2/3 (make-color 0 0 0 255) (make-color 6 9 12 255)) will make a colour (make-color 4 6 8 255).
By taking in a number (n), and dividing it by DENOM (20), you have the fraction that the image will be interpolated at. The check-expect tests ask to use n=NUMER=0 and n=DENOM=20. When n=NUMER, the interpolate is at a minimum and will just produce the leftmost image (p1). However, when n=DENOM, the interpolate is at a maximum and will produce the rightmost image (p2).
Therefore, the check-expects can be listed as follows:
(check-expect (interpolate-image p1 p2 DENOM) p2)
(check-expect (interpolate-image p1 p2 NUMER) p1)