summaryrefslogblamecommitdiffstats
path: root/ex/2/50.rkt
blob: 70c23db4fd75fa011a0d0721b97511cd7fc44a4f (plain) (tree)
1
2
3
4
5
6
7
8
9



                     



                      
 













                                                          
 





                                          
 




                                          






                                          






                                          
;;;; License: CC0-1.0

#lang racket

(provide
 transform-painter
 counterclockwise-180
 counterclockwise-270)

(require "46.rkt")
(require "47.rkt")
(require "49.rkt")


(define (transform-painter painter origin corner1 corner2)
  (lambda (frame)
    (let ((m (frame-coord-map frame)))
      (let ((new-origin (m origin)))
        (painter (make-frame
                  new-origin
                  (sub-vect (m corner1) new-origin)
                  (sub-vect (m corner2) new-origin)))))))


(define (flip-vert painter)
  (transform-painter painter
                     (make-vect 0.0 1.0)
                     (make-vect 1.0 1.0)
                     (make-vect 0.0 0.0)))


(define (flip-horiz painter)
  (transform-painter painter
                     (make-vect 1.0 0.0)
                     (make-vect 0.0 0.0)
                     (make-vect 1.0 1.0)))


(define (counterclockwise-180 painter)
  (transform-painter painter
                     (make-vect 1.0 1.0)
                     (make-vect 0.0 1.0)
                     (make-vect 1.0 0.0)))


(define (counterclockwise-270 painter)
  (transform-painter painter
                     (make-vect 1.0 0.0)
                     (make-vect 1.0 1.0)
                     (make-vect 0.0 0.0)))