Functional Problem Solving (CSC 151 2016S) : EBoards

CSC151.02 2016S, Class 22: Images as Functions from Position to Colors


Overview

Preliminaries

Admin

Reminders

Upcoming Work:

Extra Credit

Academic / Artistic

Peer

Misc

Far in the Future

No Extra Credit, But Still Good

Questions

Using image-compute

Demos!

> (define blend1
    (lambda (col row)
      (irgb (* 255 (/ col 200)) 0 0)))
> (image—show (image-compute blend1 200 200))

What do you think will this show?

> (define blend2
    (lambda (x y)
       (irgb (* 255 (/ x 200))
             0
             (- 255 (* 255 (/ x 200))))))
> (image-show (image-compute blend2 200 200))

What do you think will this show?

> (define blend3
     (lambda (x y)
        (irgb (remainder (*10 x) 256) 0 0)))
> (image-show (image-compute blend3 200 200))

What do you think will this show?

> (define blend4
    (lambda (x y)
      (irgb (abs (- 255 (remainder (* 10 x) (* 255 2))))
            0
            0)))
> (image-show (image-compute blend4 200 200))

What do you think it will show? * It will kind of be like the last one where it cycles? * It will cycle by going up first then back down. * Unlike the last one where it goes from a sharp turn from red to black, it’ll slowly go back from red to black again

> (define blend4
    (lambda (x y)
       (irgb (abs (- 255 (remainder (* 10 x) (* 255 2))))
             (abs (- 255 (remainder (* 10 y) (* 255 2))))
             0)))

We can do stuff other than cool blends.

> (define thing1
        (lambda (x y)
                (if (and (> x 50) (< x 100) (> y 50) (< y 100))
                (irgb 255 0 0)
                (irgb 0 0 255))))

What will this show?

> (define thing2
    (lambda (x y)
      (let ([num (remainder (truncate (/ x 20)) 3)])
        (cond 
          [(= num 0) 
           (irgb 255 0 0)]
          [(= num 1) 
           (irgb 0 255 0)]
          [else 
          i (irgb 0 0 255)]))))

What will this show?

> (define thing3
        (lambda (x y)
                (let ([num (remainder (truncate (/ x 20)) 3)]
                        [comp (* 255 (/ y 200))])
                (cond ((= num 0)

Lab

Writeup: Problem 3 (Class 22)