## Problem 1: Scaling and overlaying

Write a function which takes an image and a scale factor as its parameters, then returns an image obtained by scaling image by scale factor and overlaying the result on top of image itself. Test your program with the following inputs:

``````    (scaleAndOverlay (circle 100 "outline" "green") 0.9)
(scaleAndOverlay (scaleAndOverlay (circle 100 "outline" "green") 0.9) 0.9)``````

## solution

``````    (define (scaleAndOverlay image scaleFactor)
(overlay
(scale scaleFactor image)
image))
(scaleAndOverlay (circle 100 "outline" "green") 0.9)
(scaleAndOverlay (scaleAndOverlay (circle 100 "outline" "green") 0.8) 0.8)``````

## Problem 2: dropping and bouncing ball

Consider the dropping ball animation we have made before:

``````    (define (animation1 frameNo)
(place-image
(circle 20 "solid" "green")
50 frameNo  ;note how the y-coordinate is related to frameNo
(empty-scene 400 400)))

(animate animation1)``````

We want to modify the animation so that the ball goes diagonal (at different speeds in each direction) an reappears from the wall across when it hits a wall. A simple way of doing this is to take modulo height/width of the distance it has travelled. You may use `(modulo ...)` function for these calculations.

## solution

``````    (define speedX 1)
(define speedY 2)
(define (animation1 frameNo)
(place-image
(circle 20 "solid" "green")
(modulo (* speedX frameNo) 400)
(modulo (* speedY frameNo) 400)
(empty-scene 400 400)))

(animate animation1)``````