-
Notifications
You must be signed in to change notification settings - Fork 0
/
2.49.rkt
29 lines (23 loc) · 1.27 KB
/
2.49.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#lang sicp
;; Exercise 2.49: Use segments->painter to define the following primitive painters:
;; The painter that draws the outline of the designated frame.
;; The painter that draws an “X” by connecting opposite corners of the frame.
;; The painter that draws a diamond shape by connecting the midpoints of the sides of the frame.
;; The wave painter.
(#%require sicp-pict)
(define outline
(segments->painter (list
(make-segment (make-vect 0.0 0.0) (make-vect 0.0 1.0))
(make-segment (make-vect 0.0 1.0) (make-vect 1.0 1.0))
(make-segment (make-vect 1.0 1.0) (make-vect 1.0 0.0))
(make-segment (make-vect 1.0 0.0) (make-vect 0.0 0.0)))))
(define x
(segments->painter (list
(make-segment (make-vect 0.0 0.0) (make-vect 1.0 1.0))
(make-segment (make-vect 0.0 1.0) (make-vect 1.0 0.0)))))
(define diamond
(segments->painter (list
(make-segment (make-vect 0.0 0.5) (make-vect 0.5 1.0))
(make-segment (make-vect 0.5 1.0) (make-vect 1.0 0.5))
(make-segment (make-vect 1.0 0.5) (make-vect 0.5 0.0))
(make-segment (make-vect 0.5 0.0) (make-vect 0.0 0.5)))))