#lang racket
(require gigls/unsafe)
(provide (all-defined-out))

;;; File:
;;;   list-recursion-revisited-lab.rkt
;;; Authors:
;;;   Janet Davis
;;;   Samuel A. Rebelsky
;;;   Jerod Weinman
;;;   YOUR NAME HERE
;;; Summary:
;;;   Code for the lab entitled "List Recursion, Revisited"

; +-----------------+-----------------------------------------------------------
; | Color Utilities |
; +-----------------+

;;; Procedure:
;;;   irgb-brightness
;;; Parameters:
;;;   color, an integer-encoded RGB color
;;; Purpose:
;;;   Computes the brightness of color on a 0 (dark) to 100 (light) scale.
;;; Produces:
;;;   brightness, an integer
;;; Preconditions:
;;;   [No additional]
;;; Postconditions:
;;;   If color1 is likely to be perceived as lighter than color2,
;;;     then (irgb-brightness color1) > (irgb-brightness color2).
;;;   0 <= brightness <= 100
(define irgb-brightness
  (lambda (color)
    (round (* 100 (/ (+ (* 0.30 (irgb-red color))
                        (* 0.59 (irgb-green color))
                        (* 0.11 (irgb-blue color)))
                      255)))))

;;; Procedure:
;;;   irgb-brighter
;;; Parameters:
;;;   color1, an integer-encoded RGB color.
;;;   color2, an integer-encoded RGB color.
;;; Purpose:
;;;   Find the brighter of color1 and color2.
;;; Produces:
;;;   brighter, an RGB color.
;;; Preconditions:
;;;   irgb-brightness is defined
;;; Postconditions:
;;;   brighter is either color1 or color2
;;;   (irgb-brightness brighter) >= (irgb-brightness color1)
;;;   (irgb-brightness brighter) >= (irgb-brightness color2)
(define irgb-brighter
  (lambda (color1 color2)
    (if (>= (irgb-brightness color1) (irgb-brightness color2))
        color1
        color2)))

;;; Procedure:
;;;   irgb-bright?
;;; Parameters:
;;;   color, an integer-encoded RGB color
;;; Purpose:
;;;   Determines whether the color is bright.
;;; Produces:
;;;   bright?, a boolean
;;; Preconditions:
;;;   irgb-brightness is defined.
;;; Postconditions:
;;;   bright? is true iff (irgb-brightness color) >= 67.
(define irgb-bright?
  (lambda (color)
    (<= 67 (irgb-brightness color))))

; +-------------+---------------------------------------------------------------
; | Some Colors |
; +-------------+

(define my-color-names 
  (list "palevioletred" "cadetblue" "darkseagreen" "goldenrod"
        "hotpink" "lightsteelblue" "burlywood" "mistyrose"
        "salmon" "peru" "plum" "turquoise"))
(define my-colors
  (map color-name->irgb my-color-names))

; Names of green colors
(define green-names
  (list "darkgreen" "darkolivegreen" "darkseagreen" "forestgreen"
        "green" "greenyellow" "lawngreen" "lightgreen" "lightseagreen"
        "limegreen" "mediumseagreen" "mediumspringgreen" "palegreen"
        "seagreen" "springgreen" "yellowgreen"))

(define greens (map color->irgb green-names))

; The colors in the rainbow; almost the primary plus secondary
(define rainbow-color-names
  (list "red" "orange" "yellow" "green" "blue" "indigo" "violet"))
(define rainbow-colors
  (map color->irgb rainbow-color-names))
