change 2htdp/image docs so that it uses just the regular evaluation mechanism instead of the fancy dance it was doing before

This commit is contained in:
Robby Findler 2010-12-31 14:44:10 -06:00
parent e75d6b3fae
commit 01fc959e63
135 changed files with 25 additions and 1033 deletions

View File

@ -1,125 +0,0 @@
#lang racket/gui
;; Run this file is generate the images in the img/ directory,
;; picked up by image-examples from image.scrbl
(require 2htdp/image
lang/posn
racket/runtime-path)
(define-runtime-path image.scrbl "image.scrbl")
(define-runtime-path img "img")
(define-namespace-anchor anchor)
(define ns (namespace-anchor->namespace anchor))
(define expressions
(parameterize ([current-namespace ns])
(putenv "PLTSHOWIMAGES" "show")
(let-values ([(in out) (make-pipe)])
(thread
(λ ()
(parameterize ([current-output-port out])
(dynamic-require image.scrbl #f))
(close-output-port out)))
(let loop ()
(let ([exp (read in)])
(if (eof-object? exp)
'()
(cons exp (loop))))))))
(define-namespace-anchor image-anchor)
(define image-ns (namespace-anchor->namespace anchor))
(define mapping '())
(define (handle-image exp)
(printf ".") (flush-output)
(let ([result
(with-handlers ([(λ (x) #t)
(λ (x)
(printf "\nerror evaluating:\n")
(pretty-write exp)
(raise x))])
(parameterize ([current-namespace image-ns])
(rewrite (eval exp))))])
(cond
[(image? result)
(let ([fn (exp->filename exp)])
(set! mapping (cons `(list ',exp 'image ,fn) mapping))
(let ([pth (build-path img fn)])
(unless (save-image result pth)
(fprintf (current-error-port) "failed to save ~s\n" pth))))]
[else
(unless (equal? result (read/write result))
(error 'handle-image "expression ~s produced ~s, which I can't write"
exp result))
(set! mapping (cons `(list ',exp 'val ',result) mapping))])))
(define (rewrite exp)
(let loop ([exp exp])
(cond
[(list? exp)
`(list ,@(map loop exp))]
[(color? exp)
`(color ,(color-red exp)
,(color-green exp)
,(color-blue exp))]
[else exp])))
(define (exp->filename exp)
(let loop ([prev 0])
(let ([candidate
(format "~a~a.png"
(number->string (exp->number exp) 16) ;; abs to avoid filenames beginning with hyphens
(if (zero? prev)
""
(format "-~a" (number->string prev 16))))])
(cond
[(anywhere? candidate mapping)
(printf "dup!\n")
(loop (+ prev 1))]
[else
candidate]))))
(define (anywhere? x sexp)
(let loop ([sexp sexp])
(cond
[(pair? sexp) (or (loop (car sexp))
(loop (cdr sexp)))]
[else (equal? x sexp)])))
;(define a-prime (- (expt 2 127) 1)) ;; Lucas found this in 1876. (too long filenames)
(define a-prime (/ (- (expt 2 59) 1) 179951)) ;; found by Landry in 1867
;(define a-prime 113) ;; has too many collisions
(define base 256)
(define (exp->number exp)
(let ([digits (map char->integer (string->list (format "~s" exp)))])
(when (ormap (λ (x) (not (<= 0 x (- base 1)))) digits)
(error 'exp->number "found a char that was bigger than ~a in ~s" (- base 1) exp))
(let loop ([n 1]
[digits digits])
(cond
[(null? digits) (modulo n a-prime)]
[else (loop (+ (car digits) (* n base))
(cdr digits))]))))
(define (read/write result)
(let-values ([(in out) (make-pipe)])
(thread (λ () (write result out) (close-output-port out)))
(read in)))
(for-each handle-image expressions)
(cond
[(null? mapping)
(printf "image-gen: didn't find any images; probably this means that you need to delete .zo files and try again\n")]
[else
(printf "\n")
(call-with-output-file "image-toc.rkt"
(λ (port)
(fprintf port "#lang racket/base\n(provide mapping)\n")
(fprintf port ";; this file is generated by image-gen.ss -- do not edit\n;; note that the file that creates this file depends on this file\n;; it is always safe to simply define (and provide) mapping as the empty list\n\n")
(pretty-write
`(define mapping (list ,@mapping))
port))
#:exists 'truncate)])

View File

@ -1,856 +0,0 @@
#lang racket/base
(provide mapping)
;; this file is generated by image-gen.ss -- do not edit
;; note that the file that creates this file depends on this file
;; it is always safe to simply define (and provide) mapping as the empty list
(define mapping
(list
(list
'(let* ((s
(crop
0
0
20
20
(rectangle
20
20
"outline"
(make-pen "black" 2 "solid" "round" "round"))))
(r (beside s s s s s s)))
(above r r r r r r))
'image
"5127be89b4-1.png")
(list
'(crop
0
0
20
20
(rectangle 20 20 "outline" (make-pen "black" 2 "solid" "round" "round")))
'image
"284a96a769b-1.png")
(list
'(let* ((s (rectangle 20 20 "outline" "black")) (r (beside s s s s s s)))
(above r r r r r r))
'image
"245380940d6-1.png")
(list
'(let* ((t (triangle 40 "solid" "orange"))
(w (image-width t))
(h (image-height t)))
(clear-pinhole
(overlay/pinhole
(put-pinhole (/ w 2) 0 t)
(put-pinhole w h t)
(put-pinhole 0 h t))))
'image
"1847b22ee5c.png")
(list
'(underlay/pinhole
(put-pinhole 25 10 (ellipse 100 50 "solid" "red"))
(put-pinhole 75 40 (ellipse 100 50 "solid" "blue")))
'image
"1648582961a.png")
(list
'(let ((petal (put-pinhole 20 20 (ellipse 100 40 "solid" "purple"))))
(clear-pinhole
(overlay/pinhole
(circle 30 "solid" "yellow")
(rotate (* 60 0) petal)
(rotate (* 60 1) petal)
(rotate (* 60 2) petal)
(rotate (* 60 3) petal)
(rotate (* 60 4) petal)
(rotate (* 60 5) petal))))
'image
"31011b92fc.png")
(list
'(overlay/pinhole
(put-pinhole 25 10 (ellipse 100 50 "solid" "red"))
(put-pinhole 75 40 (ellipse 100 50 "solid" "blue")))
'image
"d2d7809e7e.png")
(list '(pinhole-y (center-pinhole (rectangle 10 10 "solid" "red"))) 'val '5)
(list '(pinhole-x (center-pinhole (rectangle 10 10 "solid" "red"))) 'val '5)
(list
'(put-pinhole 2 18 (rectangle 40 20 "solid" "forestgreen"))
'image
"14fa9751041.png")
(list
'(rotate 30 (center-pinhole (rectangle 40 20 "solid" "orange")))
'image
"f89620acd3.png")
(list
'(center-pinhole (rectangle 40 20 "solid" "red"))
'image
"b2c3ee438.png")
(list '(image-height (rectangle 100 100 "solid" "black")) 'val '100)
(list '(image-baseline (rectangle 100 100 "solid" "black")) 'val '100)
(list '(image-height (text "Hello" 24 "black")) 'val '24)
(list '(image-baseline (text "Hello" 24 "black")) 'val '18)
(list '(image-height (rectangle 10 0 "solid" "purple")) 'val '0)
(list
'(image-height
(overlay (circle 20 "solid" "orange") (circle 30 "solid" "purple")))
'val
'60)
(list '(image-height (circle 30 "solid" "orange")) 'val '60)
(list '(image-height (ellipse 30 40 "solid" "orange")) 'val '40)
(list '(image-width (rectangle 0 10 "solid" "purple")) 'val '0)
(list
'(image-width
(beside (circle 20 "solid" "orange") (circle 20 "solid" "purple")))
'val
'80)
(list '(image-width (circle 30 "solid" "orange")) 'val '60)
(list '(image-width (ellipse 30 40 "solid" "orange")) 'val '30)
(list
'(scale 40 (color-list->bitmap (list "red" "green" "blue") 3 1))
'image
"2e45632f5de.png")
(list
'(image->color-list
(above
(beside
(rectangle 1 1 "solid" (make-color 1 1 1))
(rectangle 1 1 "solid" (make-color 2 2 2)))
(beside
(rectangle 1 1 "solid" (make-color 3 3 3))
(rectangle 1 1 "solid" (make-color 4 4 4)))))
'val
'(list (color 1 1 1) (color 2 2 2) (color 3 3 3) (color 4 4 4)))
(list
'(image->color-list (rectangle 2 2 "solid" "black"))
'val
'(list (color 0 0 0) (color 0 0 0) (color 0 0 0) (color 0 0 0)))
(list '(bitmap icons/b-run.png) 'image "13aef4074e9.png")
(list '(bitmap icons/stop-16x16.png) 'image "72aef3dc67.png")
(list
'(beside
(ellipse 20 70 "solid" "lightsteelblue")
(frame (ellipse 20 50 "solid" "mediumslateblue"))
(ellipse 20 30 "solid" "slateblue")
(ellipse 20 10 "solid" "navy"))
'image
"54a488e1a5.png")
(list '(frame (ellipse 40 40 "solid" "gray")) 'image "1a74ac09f8a.png")
(list
'(above
(beside
(crop 40 40 40 40 (circle 40 "solid" "palevioletred"))
(crop 0 40 40 40 (circle 40 "solid" "lightcoral")))
(beside
(crop 40 0 40 40 (circle 40 "solid" "lightcoral"))
(crop 0 0 40 40 (circle 40 "solid" "palevioletred"))))
'image
"164b8da7bf6.png")
(list
'(crop 40 60 40 60 (ellipse 80 120 "solid" "dodgerblue"))
'image
"6c262f1d24.png")
(list
'(crop 0 0 40 40 (circle 40 "solid" "chocolate"))
'image
"8e7c1870c7.png")
(list
'(above
(star 40 "solid" "firebrick")
(scale/xy 1 1/2 (flip-vertical (star 40 "solid" "gray"))))
'image
"25bd9b1ac5a.png")
(list
'(beside
(rotate 30 (square 50 "solid" "red"))
(flip-horizontal (rotate 30 (square 50 "solid" "blue"))))
'image
"e58911226.png")
(list '(ellipse 60 60 "solid" "blue") 'image "d92d6a49f1.png")
(list
'(scale/xy 3 2 (ellipse 20 30 "solid" "blue"))
'image
"2e6a31a9033.png")
(list '(ellipse 40 60 "solid" "blue") 'image "196bfa7b9c4.png")
(list '(scale 2 (ellipse 20 30 "solid" "blue")) 'image "2d9ba9032e.png")
(list
'(rotate
45
(beside/align
"center"
(rectangle 40 20 "solid" "darkseagreen")
(rectangle 20 100 "solid" "darkseagreen")))
'image
"fdaad0760b.png")
(list
'(rotate 5 (rectangle 50 50 "outline" "black"))
'image
"13b344ed2ff.png")
(list
'(rotate 45 (ellipse 60 20 "solid" "olivedrab"))
'image
"28daec71a64.png")
(list
'(scene+curve
(rectangle 100 100 "solid" "black")
-20
-20
0
1
120
120
0
1
"red")
'image
"25dd3e2d97c.png")
(list
'(scene+curve
(add-curve
(rectangle 40 100 "solid" "black")
20
10
180
1/2
20
90
180
1/2
"white")
20
10
0
1/2
20
90
0
1/2
"white")
'image
"1132401ea93.png")
(list
'(scene+curve
(rectangle 100 100 "solid" "black")
20
20
0
1
80
80
0
1
"white")
'image
"6efa12ea15.png")
(list
'(scene+curve
(rectangle 100 100 "solid" "black")
20
20
0
1/3
80
80
0
1/3
"white")
'image
"353ed4578.png")
(list
'(scene+line
(rectangle 100 100 "solid" "darkolivegreen")
25
25
100
100
(make-pen "goldenrod" 30 "solid" "round" "round"))
'image
"d629961aee.png")
(list
'(scene+line (rectangle 40 40 "solid" "gray") -10 50 50 -10 "maroon")
'image
"1f5944ec1ed.png")
(list
'(scene+line (ellipse 40 40 "outline" "maroon") 0 40 40 0 "maroon")
'image
"2b944b7ab91.png")
(list
'(beside
(place-image/align
(circle 8 "solid" "tomato")
0
0
"center"
"center"
(rectangle 32 32 "outline" "black"))
(place-image/align
(circle 8 "solid" "tomato")
8
8
"center"
"center"
(rectangle 32 32 "outline" "black"))
(place-image/align
(circle 8 "solid" "tomato")
16
16
"center"
"center"
(rectangle 32 32 "outline" "black"))
(place-image/align
(circle 8 "solid" "tomato")
24
24
"center"
"center"
(rectangle 32 32 "outline" "black"))
(place-image/align
(circle 8 "solid" "tomato")
32
32
"center"
"center"
(rectangle 32 32 "outline" "black")))
'image
"cf131e14ad.png")
(list
'(place-image/align
(triangle 48 "solid" "yellowgreen")
64
64
"right"
"bottom"
(rectangle 64 64 "solid" "mediumgoldenrod"))
'image
"11402043018.png")
(list
'(place-image
(circle 4 "solid" "white")
18
20
(place-image
(circle 4 "solid" "white")
0
6
(place-image
(circle 4 "solid" "white")
14
2
(place-image
(circle 4 "solid" "white")
8
14
(rectangle 24 24 "solid" "goldenrod")))))
'image
"ab1841ea36.png")
(list
'(place-image
(triangle 64 "solid" "red")
24
24
(rectangle 48 48 "solid" "gray"))
'image
"13e518b230e.png")
(list
'(place-image
(triangle 32 "solid" "red")
24
24
(rectangle 48 48 "solid" "gray"))
'image
"126418b230e.png")
(list '(empty-scene 160 90) 'image "216addb7809.png")
(list
'(above/align
"left"
(ellipse 70 20 "solid" "yellowgreen")
(ellipse 50 20 "solid" "olivedrab")
(ellipse 30 20 "solid" "darkolivegreen")
(ellipse 10 20 "solid" "darkgreen"))
'image
"ff11314e4e.png")
(list
'(above/align
"right"
(ellipse 70 20 "solid" "gold")
(ellipse 50 20 "solid" "goldenrod")
(ellipse 30 20 "solid" "darkgoldenrod")
(ellipse 10 20 "solid" "sienna"))
'image
"2758748ad7f.png")
(list
'(above
(ellipse 70 20 "solid" "gray")
(ellipse 50 20 "solid" "darkgray")
(ellipse 30 20 "solid" "dimgray")
(ellipse 10 20 "solid" "black"))
'image
"aac8b78b6e.png")
(list
'(beside/align "baseline" (text "ijy" 18 "black") (text "ijy" 24 "black"))
'image
"2187216ca96.png")
(list
'(beside/align
"top"
(ellipse 20 70 "solid" "mediumorchid")
(ellipse 20 50 "solid" "darkorchid")
(ellipse 20 30 "solid" "purple")
(ellipse 20 10 "solid" "indigo"))
'image
"10a0d35fa03.png")
(list
'(beside/align
"bottom"
(ellipse 20 70 "solid" "lightsteelblue")
(ellipse 20 50 "solid" "mediumslateblue")
(ellipse 20 30 "solid" "slateblue")
(ellipse 20 10 "solid" "navy"))
'image
"eb99639e31.png")
(list
'(beside
(ellipse 20 70 "solid" "gray")
(ellipse 20 50 "solid" "darkgray")
(ellipse 20 30 "solid" "dimgray")
(ellipse 20 10 "solid" "black"))
'image
"28c73238138.png")
(list
'(underlay/xy
(underlay/xy
(ellipse 40 40 "solid" "gray")
10
15
(ellipse 10 10 "solid" "forestgreen"))
20
15
(ellipse 10 10 "solid" "forestgreen"))
'image
"201c231dce2.png")
(list
'(underlay/xy
(rectangle 20 20 "solid" "red")
-20
-20
(rectangle 20 20 "solid" "black"))
'image
"42f9f9e4cf.png")
(list
'(underlay/xy
(rectangle 20 20 "solid" "red")
20
20
(rectangle 20 20 "solid" "black"))
'image
"157ab5efca7.png")
(list
'(underlay/xy
(rectangle 20 20 "outline" "black")
20
0
(rectangle 20 20 "outline" "black"))
'image
"26bd803042c.png")
(list
'(underlay/align
"right"
"top"
(rectangle 50 50 "solid" "seagreen")
(rectangle 40 40 "solid" "silver")
(rectangle 30 30 "solid" "seagreen")
(rectangle 20 20 "solid" "silver"))
'image
"ff2fcb7b87.png")
(list
'(underlay/align
"left"
"middle"
(rectangle 30 60 "solid" "orange")
(ellipse 60 30 "solid" "purple"))
'image
"1404e4b2af.png")
(list
'(underlay
(ellipse 10 60 "solid" "red")
(ellipse 20 50 "solid" "black")
(ellipse 30 40 "solid" "red")
(ellipse 40 30 "solid" "black")
(ellipse 50 20 "solid" "red")
(ellipse 60 10 "solid" "black"))
'image
"28253f4c3c.png")
(list
'(underlay
(rectangle 30 60 "solid" "orange")
(ellipse 60 30 "solid" "purple"))
'image
"9858b8d5d.png")
(list
'(overlay/xy
(overlay/xy
(ellipse 40 40 "outline" "black")
10
15
(ellipse 10 10 "solid" "forestgreen"))
20
15
(ellipse 10 10 "solid" "forestgreen"))
'image
"10847861f4b.png")
(list
'(overlay/xy
(rectangle 20 20 "solid" "red")
-20
-20
(rectangle 20 20 "solid" "black"))
'image
"133309751d2.png")
(list
'(overlay/xy
(rectangle 20 20 "solid" "red")
20
20
(rectangle 20 20 "solid" "black"))
'image
"15717b87d30.png")
(list
'(overlay/xy
(rectangle 20 20 "outline" "black")
20
0
(rectangle 20 20 "outline" "black"))
'image
"1f0b671ed7b.png")
(list
'(overlay/align
"right"
"bottom"
(rectangle 20 20 "solid" "silver")
(rectangle 30 30 "solid" "seagreen")
(rectangle 40 40 "solid" "silver")
(rectangle 50 50 "solid" "seagreen"))
'image
"969a9aa483.png")
(list
'(overlay/align
"left"
"middle"
(rectangle 30 60 "solid" "orange")
(ellipse 60 30 "solid" "purple"))
'image
"11b64ab4d3.png")
(list
'(overlay
(regular-polygon 20 5 "solid" (make-color 50 50 255))
(regular-polygon 26 5 "solid" (make-color 100 100 255))
(regular-polygon 32 5 "solid" (make-color 150 150 255))
(regular-polygon 38 5 "solid" (make-color 200 200 255))
(regular-polygon 44 5 "solid" (make-color 250 250 255)))
'image
"1acede17bc6.png")
(list
'(overlay
(ellipse 10 10 "solid" "red")
(ellipse 20 20 "solid" "black")
(ellipse 30 30 "solid" "red")
(ellipse 40 40 "solid" "black")
(ellipse 50 50 "solid" "red")
(ellipse 60 60 "solid" "black"))
'image
"26c4c403875.png")
(list
'(overlay
(rectangle 30 60 "solid" "orange")
(ellipse 60 30 "solid" "purple"))
'image
"4e85791a5.png")
(list
'(underlay
(rectangle 90 80 "solid" "mediumseagreen")
(polygon
(list
(make-posn 0 0)
(make-posn 50 0)
(make-posn 0 50)
(make-posn 50 50))
"outline"
(make-pen "darkslategray" 10 "solid" "projecting" "miter")))
'image
"29b31e5fe3a.png")
(list
'(underlay
(rectangle 80 80 "solid" "mediumseagreen")
(polygon
(list
(make-posn 0 0)
(make-posn 50 0)
(make-posn 0 50)
(make-posn 50 50))
"outline"
(make-pen "darkslategray" 10 "solid" "round" "round")))
'image
"1aaa434b462.png")
(list
'(polygon
(list
(make-posn 0 0)
(make-posn 0 40)
(make-posn 20 40)
(make-posn 20 60)
(make-posn 40 60)
(make-posn 40 20)
(make-posn 20 20)
(make-posn 20 0))
"solid"
"plum")
'image
"150e1d5e9f.png")
(list
'(polygon
(list
(make-posn 0 0)
(make-posn -10 20)
(make-posn 60 0)
(make-posn -10 -20))
"solid"
"burlywood")
'image
"25354f2b84e.png")
(list '(regular-polygon 20 8 "solid" "red") 'image "268c974b9ab.png")
(list '(regular-polygon 40 4 "outline" "blue") 'image "957fe78565.png")
(list '(regular-polygon 50 3 "outline" "red") 'image "1325a6e7bdb.png")
(list '(radial-star 32 30 40 "outline" "black") 'image "1fdee89ec7d.png")
(list
'(radial-star 8 8 64 "solid" "darkslategray")
'image
"296a50fddcd.png")
(list
'(star-polygon 20 10 3 "solid" "cornflowerblue")
'image
"2cc717fb347.png")
(list '(star-polygon 40 7 3 "outline" "darkred") 'image "2330a222ac0.png")
(list '(star-polygon 40 5 2 "solid" "seagreen") 'image "24410dd26db.png")
(list '(star 40 "solid" "gray") 'image "b32ce6fcc5.png")
(list '(rhombus 80 150 "solid" "mediumpurple") 'image "24365c877d4.png")
(list '(rhombus 40 45 "solid" "magenta") 'image "5ec4a0cb1f.png")
(list '(rectangle 20 40 "solid" "blue") 'image "16a631adf1e.png")
(list '(rectangle 40 20 "outline" "black") 'image "10735f73f78.png")
(list '(square 50 "outline" "darkmagenta") 'image "89a0d469a7.png")
(list '(square 40 "solid" "slateblue") 'image "d417a51b4.png")
(list
'(triangle/saa 40 130 40 "solid" "lightseagreen")
'image
"29111c62eed.png")
(list
'(triangle/saa 200 90 40 "solid" "aquamarine")
'image
"2d67c4219ef.png")
(list '(triangle/saa 200 10 40 "solid" "seagreen") 'image "206013002a2.png")
(list
'(triangle/asa 130 40 40 "solid" "lightseagreen")
'image
"13eea8b3b80.png")
(list
'(triangle/asa 90 200 40 "solid" "aquamarine")
'image
"2271196b15b.png")
(list '(triangle/asa 10 200 40 "solid" "seagreen") 'image "22fbf40600e.png")
(list
'(triangle/aas 130 40 40 "solid" "lightseagreen")
'image
"1f26a552687.png")
(list
'(triangle/aas 90 40 200 "solid" "aquamarine")
'image
"3c0f55df6a.png")
(list '(triangle/aas 10 40 200 "solid" "seagreen") 'image "292cf6346d5.png")
(list
'(triangle/ssa 60 100 130 "solid" "lightseagreen")
'image
"12edc94e350.png")
(list
'(triangle/ssa 60 100 90 "solid" "aquamarine")
'image
"2c71196b3ab.png")
(list '(triangle/ssa 60 100 10 "solid" "seagreen") 'image "c8e97cf30.png")
(list
'(triangle/sas 60 130 100 "solid" "lightseagreen")
'image
"a02df8e22.png")
(list
'(triangle/sas 60 90 100 "solid" "aquamarine")
'image
"f233eb8f49.png")
(list '(triangle/sas 60 10 100 "solid" "seagreen") 'image "25525fabc0.png")
(list
'(triangle/ass 130 60 100 "solid" "lightseagreen")
'image
"2a40f482a67.png")
(list
'(triangle/ass 90 60 100 "solid" "aquamarine")
'image
"13d2f555f6a.png")
(list '(triangle/ass 10 60 100 "solid" "seagreen") 'image "11de2af7edc.png")
(list
'(triangle/sss 80 80 40 "solid" "lightseagreen")
'image
"1828ba0c75d.png")
(list '(triangle/sss 80 40 60 "solid" "aquamarine") 'image "1fe0d5def9.png")
(list '(triangle/sss 40 60 80 "solid" "seagreen") 'image "ed23c3c3ed.png")
(list
'(isosceles-triangle 60 330 "solid" "lightseagreen")
'image
"138792ad221.png")
(list
'(isosceles-triangle 60 30 "solid" "aquamarine")
'image
"d47072011e.png")
(list
'(isosceles-triangle 200 170 "solid" "seagreen")
'image
"2dde939d6dc.png")
(list '(right-triangle 36 48 "solid" "black") 'image "1a0088e3819.png")
(list '(triangle 40 "solid" "tan") 'image "aeddf66d5d.png")
(list
'(equal?
(above empty-image (rectangle 10 10 "solid" "red"))
(beside empty-image (rectangle 10 10 "solid" "red")))
'val
'#t)
(list '(image-width empty-image) 'val '0)
(list
'(text/font "not really a link" 18 "blue" #f 'roman 'normal 'normal #t)
'image
"27bbbb6fd64.png")
(list
'(text/font "Goodbye" 18 "indigo" #f 'modern 'italic 'normal #f)
'image
"24e80ea10b4.png")
(list
'(text/font "Hello" 24 "olive" "Gill Sans" 'swiss 'normal 'bold #f)
'image
"169f2ceb45c.png")
(list '(text "Goodbye" 36 "indigo") 'image "169990a635e.png")
(list '(text "Hello" 24 "olive") 'image "1bbeedc0d6.png")
(list
'(add-curve
(rectangle 100 100 "solid" "black")
-20
-20
0
1
120
120
0
1
"red")
'image
"1532990d5cb.png")
(list
'(add-curve
(add-curve
(rectangle 40 100 "solid" "black")
20
10
180
1/2
20
90
180
1/2
(make-pen "white" 4 "solid" "round" "round"))
20
10
0
1/2
20
90
0
1/2
(make-pen "white" 4 "solid" "round" "round"))
'image
"21b080bdda8.png")
(list
'(add-curve
(rectangle 100 100 "solid" "black")
20
20
0
1
80
80
0
1
"white")
'image
"fa1a9f17b6.png")
(list
'(add-curve
(rectangle 100 100 "solid" "black")
20
20
0
1/3
80
80
0
1/3
"white")
'image
"2a1f3988f.png")
(list
'(add-line
(rectangle 100 100 "solid" "darkolivegreen")
25
25
75
75
(make-pen "goldenrod" 30 "solid" "round" "round"))
'image
"7bbcc7cbaa.png")
(list
'(add-line (rectangle 40 40 "solid" "gray") -10 50 50 -10 "maroon")
'image
"12b0447b10c.png")
(list
'(add-line (ellipse 40 40 "outline" "maroon") 0 40 40 0 "maroon")
'image
"89b3a9e462.png")
(list '(line 30 -20 "red") 'image "12948ac080d.png")
(list '(line -30 20 "red") 'image "69aaaa680d.png")
(list '(line 30 30 "black") 'image "8e1ebaaf82.png")
(list '(ellipse 20 40 "solid" "blue") 'image "25451dd2997.png")
(list '(ellipse 40 20 "outline" "black") 'image "8cb34e62d4.png")
(list '(circle 20 "solid" "blue") 'image "54d58bf7f6.png")
(list '(circle 30 "outline" "red") 'image "262a4fa650a.png")
(list
'(let* ((s
(crop
0
0
20
20
(rectangle
20
20
"outline"
(make-pen "black" 2 "solid" "round" "round"))))
(r (beside s s s s s s)))
(above r r r r r r))
'image
"5127be89b4.png")
(list
'(crop
0
0
20
20
(rectangle 20 20 "outline" (make-pen "black" 2 "solid" "round" "round")))
'image
"284a96a769b.png")
(list
'(let* ((s (rectangle 20 20 "outline" "black")) (r (beside s s s s s s)))
(above r r r r r r))
'image
"245380940d6.png")))

View File

@ -1,54 +1,11 @@
#lang racket/base
(require scribble/base
scribble/core
scribble/manual
scribble/racket
(for-syntax racket/base)
"image-toc.ss")
(require scribble/eval)
(provide image-examples)
(define-syntax (image-examples stx)
(syntax-case stx ()
[(_ exp ...)
(when (getenv "PLTSHOWIMAGES")
(for-each (λ (exp) (printf "~s\n" (syntax->datum exp)))
(syntax->list #'(exp ...))))
#'(interleave
(list (racketinput exp) ...)
(list 'exp ...))]))
(define img-eval (make-base-eval))
(interaction-eval #:eval img-eval (require 2htdp/image))
(define (interleave expr-paras val-list+outputs)
(make-table
plain
(map list
(apply append
(list (make-paragraph plain (format "Example~a:"
(if (or (null? expr-paras)
(null? (cdr expr-paras)))
""
"s"))))
(map (λ (x exp)
(list x
(let ([line (exp->line exp)])
(case (car line)
[(val)
(racketblock #,(racketresult #,(cadr line)))]
[(image)
(let ([fn (format "2htdp/scribblings/img/~a" (cadr line))])
(racketblock #,(image fn)))]
[(missing)
(make-paragraph
error-color
"missing result; need to re-run image-gen.ss")]))))
expr-paras
val-list+outputs)))))
(define (exp->line exp)
(let ([fn (assoc exp mapping)])
(cond
[fn (cdr fn)]
[else
(unless (getenv "PLTSHOWIMAGES")
(fprintf (current-error-port) "exp->filename: unknown exp ~s\n" exp))
(list 'missing)])))
(define-syntax-rule
(image-examples exp ...)
(examples #:eval img-eval exp ...))

View File

@ -7,11 +7,20 @@
racket/gui/base
(only-in racket/base path-string?))
lang/posn
"shared.ss"
"image-util.ss"
"shared.rkt"
scribble/decode
scribble/manual)
@(require scribble/eval)
@(define img-eval (make-base-eval))
@(interaction-eval #:eval img-eval (require 2htdp/image))
@(interaction-eval #:eval img-eval (require lang/posn))
@(define-syntax-rule
(image-examples exp ...)
(examples #:eval img-eval exp ...))
@teachpack["image"]{Images}
@(define mode/color-text
@ -669,7 +678,13 @@ the @scheme[point-count] argument determines how many points the star has.
(ellipse 10 10 "solid" "forestgreen"))
20
15
(ellipse 10 10 "solid" "forestgreen"))]
(ellipse 10 10 "solid" "forestgreen"))
(overlay/xy
(overlay/xy (circle 30 'solid (color 0 150 0 127))
26 0
(circle 30 'solid (color 0 0 255 127)))
13 26
(circle 30 'solid (color 200 0 0 127)))]
}
@defproc[(underlay [i1 image?] [i2 image?] [is image?] ...) image?]{
@ -1520,3 +1535,4 @@ or manipulated as cleanly (by any image program).
}
@(close-eval img-eval)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 799 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 590 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 641 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 208 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 430 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1014 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 128 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 709 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 466 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 666 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 803 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 985 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 813 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 165 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 128 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 128 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 778 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 600 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 321 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 494 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 810 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 793 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 745 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 308 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1005 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 369 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 369 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 522 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 358 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 490 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 923 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 332 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 966 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 992 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 686 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 728 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 600 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 788 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 184 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 657 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 128 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 730 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 369 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 369 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 460 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 859 B

Some files were not shown because too many files have changed in this diff Show More