-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontest.scm
128 lines (115 loc) · 2.76 KB
/
contest.scm
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
;;; Scheme Recursive Art Contest Entry
;;;
;;; Please do not include your name or personal info in this file.
;;;
;;; Title: the sad and sudden death of kiwibot
;;;
;;; Description:
;;; why did you leave us?
;;; here alone in the darkness
;;; dying of hunger
(define (map fn vals)
(if (null? vals)
()
(cons (fn (car vals))
(map fn (cdr vals)))))
(define-macro (for sym vals expr)
(list 'map (list 'lambda (list sym) expr) vals))
(define (pos x y)
(penup)
(setposition x y)
(pendown)
)
(define (drawcircle radius x y)
(pos x y)
(begin_fill)
(circle radius)
(end_fill)
(pos (- x radius 15) (- y 10))
(color "white")
(write 'RIP 16 'Arial)
(penup)
)
(define (range a b step)
(if (> a b) nil (cons a (range (+ a step) b step))))
(define (get index lst)
(if (= index 0)
(car lst)
(get (- index 1) (cdr lst))
)
)
(define colors '("green" "blue" "cadetblue" "burlywood" "cornflowerblue" "orange" "olive" "rosybrown" "tan" "indianred" "chocolate" "crimson" "darkseagreen" "slategray" "darkslategray" "darkred" "purple" "brown"))
(define (drawcircles radius)
(define i 0)
(for x (range (/ (screen_width) -2) (+ (/ (screen_width) 2) radius radius) (* radius 2))
(for y (range (/ (screen_height) -2) (/ (screen_height) 2) (* radius 2))
(begin
(color (get (random 0 (length colors)) colors))
(drawcircle radius x y)
)
)
)
)
(define (drawrectangle x y width height c)
(pos x y)
(color c)
(begin_fill)
(setheading -90)
(fd width)
(left 90)
(fd height)
(left 90)
(fd width)
(left 90)
(fd height)
(end_fill)
(penup)
)
(define (drawkiwibot)
(drawrectangle -150 -100 70 140 "black")
(drawrectangle 220 -100 70 140 "black")
(drawrectangle (/ (screen_width) 4) (/ (screen_height) 4) (/ (screen_width) 2) (/ (screen_height) 2) "white")
(drawrectangle 150 162 300 262 "black")
(drawrectangle 100 100 200 150 "white")
(drawrectangle 65 45 45 45 "dodgerblue")
(pos -50 50)
(setheading 135)
(color "dodgerblue")
(begin_fill)
(fd 40)
(right 90)
(fd 40)
(right 90)
(fd 10)
(right 90)
(fd 30)
(left 90)
(fd 30)
(right 90)
(fd 10)
(end_fill)
(drawrectangle -160 312 10 150 "black")
(pos -170 312)
(setheading -130)
(color "dodgerblue")
(begin_fill)
(fd 100)
(right 37)
(bk 80)
(right 90)
(fd 60)
(end_fill)
(pos -50 -90)
(color "white")
(write 'kiwibot)
)
(define (draw)
(bgcolor "mintcream")
(speed 0)
(drawcircles 50)
(drawkiwibot)
(hideturtle)
(exitonclick))
; Please leave this last line alone. You may add additional procedures above
; this line.
(draw)