#lang racket
(require gigls/unsafe)
(require rackunit)
(require rackunit/text-ui)

;;; File:
;;;   exam2.rkt
;;; Authors:
;;;   The student currently referred to as 000000
;;;   Charlie Curtsinger
;;;   Samuel A. Rebelsky
;;; Contents:
;;;   Code and solutions for Exam 2 2015F.
;;; Citations:
;;;

; +---------+--------------------------------------------------------
; | Grading |
; +---------+

; This section is for the grader's use.

; Problem 1: 
; Problem 2:
; Problem 3:
; Problem 4:
; Problem 5:
; Problem 6:
; Problem 7:
;           ----
;     Total:

;    Scaled:
;    Errors:
;     Times:
;          :
;          :
;          :
;           ----
;     Total:


; +-----------+------------------------------------------------------
; | Problem 1 |
; +-----------+

; Time Spent: 

; Citations:

; Solution:

;;; Name:
;;;   drawing-center-tests
;;; Type:
;;;   test suite
;;; Contents:
;;;   Tests for the drawing-center procedure.
(define drawing-center-tests
  (test-suite
   "Test of drawing-center"
   (test-case "center unit square at (1,1)"
    (let ([centered (drawing-center drawing-unit-square 1 1)])
      (check-equal? (drawing-type centered) 'rectangle)
      (check-equal? (drawing-width centered) 1)
      (check-equal? (drawing-height centered) 1)
      (check-= (drawing-left centered) 0.5 .00001) ; small fudge factor
      (check-= (drawing-top centered) 0.5 .00001) ; small fudge factor
      (check-equal? (drawing-color centered) 
                    (drawing-color drawing-unit-square))))))

; Examples/Tests:


; +-----------+------------------------------------------------------
; | Problem 2 |
; +-----------+

; Time Spent: 

; Citations:

; Solution:

;;; Procedure:
;;;   drawing-center
;;; Parameters:
;;;   drawing, a drawing
;;;   x, a real number
;;;   y, a real number
;;; Purpose:
;;;   Center drawing at (x,y)
;;; Produces:
;;;   centered, a new drawing
;;; Preconditions:
;;;   [No additional]
;;; Postconditions:
;;;   The colors, shapes, and relationships between shapes in centered 
;;;     are the same as the colors, shapes, and relationships in
;;;     drawing.  
;;;   (drawing-type centered) = (drawing-type drawing)
;;;   (drawing-width centered) = (drawing-width drawing)
;;;   (drawing-height centered) = (drawing-height drawing)
;;;   (+ (drawing-left centered) (* 1/2 (drawing-width centered))) = x
;;;   (+ (drawing-top centered) (* 1/2 (drawing-height centered))) = y

; An incorrect implementation.  Comment it out when you implement it
; correctly.
(define drawing-center
  (lambda (drawing x y)
    drawing))

; Examples/Tests:


; +-----------+------------------------------------------------------
; | Problem 3 |
; +-----------+

; Time Spent: 

; Citations:

; Solution:

;;; Procedure:
;;;   image->ellipses
;;; Parameters:
;;;   image, 
;;;   n, 
;;; Purpose:
;;;
;;; Produces:
;;;   
;;; Preconditions:
;;; 
;;; Postconditions:
;;;
(define image->ellipses
  (lambda (image n)
    drawing-unit-circle)) ; STUB

;;; Procedure:
;;;   image-row->ellipses
;;; Purpose:
;;;   Create a set of ellipses from one row of the image
(define image-row->ellipses
  (lambda (image n top height)
    drawing-unit-circle)) ; STUB

; Examples/Tests:


; +-----------+------------------------------------------------------
; | Problem 4 |
; +-----------+

; Time Spent: 

; Citations:

; Solution:

;;; Procedure:
;;;   image-target!
;;; Parameters:
;;;
;;; Purpose:
;;;   Draw a target described by the parameters.
;;; Produces:
;;;   target, an image
(define image-target!
  (lambda ()
    (context-set-bgcolor! "white")
    (let ([target (image-new 200 200)])
      (context-set-fgcolor! "red")
      (image-select-ellipse! target REPLACE 0 0 200 200)
      (image-select-ellipse! target SUBTRACT 30 30 140 140)
      (image-select-ellipse! target ADD 60 60 80 80)
      (image-select-ellipse! target SUBTRACT 90 90 20 20)
      (image-fill-selection! target)
      (image-select-nothing! target)
      (image-show target))))

; image-target! has _ parameters.
; _ describes _.  I included it because _.

; Examples/Tests:


; +-----------+------------------------------------------------------
; | Problem 5 |
; +-----------+

; Time Spent: 

; Citations:

; Solution:

;;; Procedure:
;;;   pos->stripes
;;; Parameters:
;;;   x, 
;;;   y,
;;;   width,
;;;   color1, 
;;;   color2, 
;;;   color3, 
;;; Purpose:
;;;
;;; Produces:
;;;   
;;; Preconditions:
;;; 
;;; Postconditions:
;;;
(define pos->stripes
  (lambda (x y width color1 color2 color3)
    color1)) ; STUB

; Examples/Tests:

(define red (irgb 255 0 0))
(define black (irgb 0 0 0))
(define grey (irgb 128 128 128))
; (image-compute (section pos->stripes <> <> 20 red black grey) 200 100)
; (image-compute (section pos->stripes <> <> 15 red black red) 200 100)

; +-----------+------------------------------------------------------
; | Problem 6 |
; +-----------+

; Time Spent: 

; Citations:

; Solution:

;;; Procedure:
;;;   grid
;;; Parameters:
;;;   width, a positive integer
;;;   height, a positive integer
;;; Purpose:
;;;   Create a list of (column row) pairs in which column takes
;;;   on all values from 0 to width-1 and row takes on all values from
;;;   0 to height-1.
;;; Produces:
;;;   grid-coordinates, a list of (column row) pairs.
;;; Preconditions:
;;;   [No additional]
;;; Postconditions:
;;;   For all column in [0..width), row in [0..height),
;;;     (member? (list column row) grid-coordinates)
(define grid
  (lambda (width height)
    (list (list 0 0)))) ; STUB

; Examples/Tests:


; +-----------+------------------------------------------------------
; | Problem 7 |
; +-----------+

; Time Spent: 

; Citations:

; Solution:

;;; Procedure:
;;;   
;;; Parameters:
;;;
;;; Purpose:
;;;
;;; Produces:
;;; 
;;; Preconditions:
;;;
;;; Postconditions:
;;;
;;; Process:
;;;
(define f (lambda (a b c) (let*
([p (> a b)] [r (> b c)] [q (> a c)]
[s (not p)]) (or (and p q a) (and r s
b) c)))) 

; Examples/Tests:


; ===================================================================

; BEFORE PRINTING, PLEASE MAKE A *SEPARATE* COPY OF YOUR CODE AND
; REMOVE EVERYTHING BELOW THIS LINE.

; PLEASE DO NOT ADD ANYTHING BELOW THIS POINT.

