forked from racket/htdp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
image.rkt
219 lines (184 loc) · 5.76 KB
/
image.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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#lang racket/base
#|
Need to test copy & paste. Also test that if the "if"
expression in image-snipclass%'s read
method returns #f, then you get a black circle out.
---
improvments/changes wrt to htdp/image:
- copying and pasting does not introduce jaggies
- equal comparisons are more efficient
- added rotation & scaling
- got rid of pinholes (see the new overlay, beside, and above functions)
- a bunch of new polygon functions
todo: sort out wxme library support (loading in text mode).
------------
From Matthias: (to use to compare with this library)
You asked about exercises and code snippets for HtDP/2e yesterday.
I actually do have a bunch of stuff in
svn: 2HtDP/SampleCode/
and they all have good sample contracts. (It is amazing what we can do with kids who have just
a few weeks of cs down; I would have never dared to write an editor after six weeks in Algol.)
|#
(require (except-in mrlib/image-core
make-color color
make-pen pen
make-pulled-point pulled-point)
"private/image-more.rkt"
"private/img-err.rkt"
(only-in lang/prim provide-primitive provide-primitives define-primitive)
htdp/error
(for-syntax racket/base))
(provide-primitives
overlay
overlay/align
overlay/offset
overlay/align/offset
overlay/xy
underlay
underlay/align
underlay/offset
underlay/align/offset
underlay/xy
beside
beside/align
above
above/align
crop
crop/align
rotate
flip-horizontal
flip-vertical
color-frame
frame
place-image
place-image/align
place-images
place-images/align
put-image
scale
scale/xy
circle
ellipse
wedge
rectangle
empty-scene
square
rhombus
regular-polygon
pulled-regular-polygon
polygon
star
star-polygon
radial-star
triangle
triangle/sss
triangle/ssa
triangle/sas
triangle/ass
triangle/aas
triangle/asa
triangle/saa
isosceles-triangle
right-triangle
line
add-line
add-polygon
add-curve
add-solid-curve
scene+line
scene+polygon
scene+curve
text
text/font
image->color-list
color-list->bitmap
x-place?
y-place?
image?
mode?
angle?
side-count?
image-color?
pen-style?
pen-cap?
pen-join?
real-valued-posn?
image-width
image-height
image-baseline
put-pinhole
clear-pinhole
center-pinhole
pinhole-x
pinhole-y
overlay/pinhole
underlay/pinhole
make-color
make-pen
make-pulled-point
step-count?
save-image
save-svg-image
freeze
bitmap/url
bitmap/file)
(provide bitmap
empty-image)
(define-primitive make-color build-color/make-color)
(define-primitive color build-color/color
(list #f
#'color #':color?
(list #':color-alpha #':color-blue #':color-green #':color-red)
(list #f #f #f #f)
#f))
(define-primitive make-pen build-pen/make-pen)
(define-primitive pen build-pen/pen
(list #f
#'pen #':pen?
(list #':pen-join #':pen-cap #':pen-style #':pen-width #':pen-color)
(list #f #f #f #f #f)
#f))
(define-primitive make-pulled-point build-pulled-point/make-pulled-point)
(define-primitive pulled-point build-pulled-point/pulled-point
(list #f
#'pulled-point #':pulled-point?
(list #':lpull #':langle #':x #':y #':rpull #':rangle)
(list #f #f #f #f #f #f)
#f))
(provide color pen pulled-point)
(define-primitive :color-red color-red)
(define-primitive :color-blue color-blue)
(define-primitive :color-green color-green)
(define-primitive :color-alpha color-alpha)
(define-primitive :color? color?)
(define-primitive :pen-color pen-color)
(define-primitive :pen-width pen-width)
(define-primitive :pen-style pen-style)
(define-primitive :pen-cap pen-cap)
(define-primitive :pen-join pen-join)
(define-primitive :pen? pen?)
(define-primitive :pulled-point-lpull pulled-point-lpull)
(define-primitive :pulled-point-langle pulled-point-langle)
(define-primitive :pulled-point-x pulled-point-x)
(define-primitive :pulled-point-y pulled-point-y)
(define-primitive :pulled-point-rpull pulled-point-rpull)
(define-primitive :pulled-point-rangle pulled-point-rangle)
(define-primitive :pulled-point? pulled-point?)
(provide (rename-out [:color-red color-red]
[:color-blue color-blue]
[:color-green color-green]
[:color-alpha color-alpha]
[:color? color?]
[:pen-color pen-color]
[:pen-width pen-width]
[:pen-style pen-style]
[:pen-cap pen-cap]
[:pen-join pen-join]
[:pen? pen?]
[:pulled-point-lpull pulled-point-lpull]
[:pulled-point-langle pulled-point-langle]
[:pulled-point-x pulled-point-x]
[:pulled-point-y pulled-point-y]
[:pulled-point-rpull pulled-point-rpull]
[:pulled-point-rangle pulled-point-rangle]
[:pulled-point? pulled-point?]))