diff --git a/collects/2htdp/image.ss b/collects/2htdp/image.ss index 6fcdd1c1dd..fb81e88b3a 100644 --- a/collects/2htdp/image.ss +++ b/collects/2htdp/image.ss @@ -101,11 +101,14 @@ and they all have good sample contracts. (It is amazing what we can do with kids angle? side-count? image-color? + pen-style? + pen-cap? + pen-join? (rename-out [build-color make-color]) color-red color-blue color-green color? color (rename-out [build-pen make-pen]) - pen-color pen-width pen-style pen-cap pen-join + pen-color pen-width pen-style pen-cap pen-join pen image-width image-height diff --git a/collects/2htdp/private/image-more.ss b/collects/2htdp/private/image-more.ss index 4ce7b08f4b..4af533fb28 100644 --- a/collects/2htdp/private/image-more.ss +++ b/collects/2htdp/private/image-more.ss @@ -59,12 +59,12 @@ (define (save-image pre-image filename) (let* ([image (to-img pre-image)] [bm (make-object bitmap% - (inexact->exact (ceiling (+ 2 (get-right image)))) - (inexact->exact (ceiling (+ 2 (get-bottom image)))))] + (inexact->exact (ceiling (+ 1 (get-right image)))) + (inexact->exact (ceiling (+ 1 (get-bottom image)))))] [bdc (make-object bitmap-dc% bm)]) (send bdc set-smoothing 'aligned) (send bdc clear) - (render-image image bdc 1 1) + (render-image image bdc 0 0) (send bdc set-bitmap #f) (send bm save-file filename 'png))) diff --git a/collects/2htdp/private/img-err.ss b/collects/2htdp/private/img-err.ss index 2903a3bf4e..2b072c8ac7 100644 --- a/collects/2htdp/private/img-err.ss +++ b/collects/2htdp/private/img-err.ss @@ -8,6 +8,9 @@ angle? side-count? image-color? + pen-style? + pen-cap? + pen-join? image-snip->image bitmap->image check-mode/color-combination) diff --git a/collects/2htdp/tests/robby-optimization-gone.ss b/collects/2htdp/tests/robby-optimization-gone.ss index 8da68f8615..528df04b92 100644 --- a/collects/2htdp/tests/robby-optimization-gone.ss +++ b/collects/2htdp/tests/robby-optimization-gone.ss @@ -1,4 +1,4 @@ -#lang scheme +#lang scheme/gui (require 2htdp/universe) (require 2htdp/image) @@ -17,4 +17,4 @@ (set! s (string-append "-" s)) (rectangle 1 1 'solid 'green))))) -(unless (string=? s "---") (error 'world-update-test "failed! ~s" s)) \ No newline at end of file +(unless (string=? s "---") (error 'world-update-test "failed! ~s" s)) diff --git a/collects/2htdp/universe.ss b/collects/2htdp/universe.ss index 4fd00f1823..2d41d5960c 100644 --- a/collects/2htdp/universe.ss +++ b/collects/2htdp/universe.ss @@ -1,6 +1,11 @@ #lang scheme/gui #| TODO: + -- yield instead of sync + -- run callbacks in user eventspace + -- make timer fire just once; restart after on-tick callback finishes + -- take out counting; replace by 0.25 delay + -- make window resizable :: why -- what if clauses are repeated in world and/or universe descriptions? -- what if the initial world or universe state is omitted? the error message is bad then. diff --git a/collects/honu/main.ss b/collects/honu/main.ss index 4f4d51080f..276d7b890a 100644 --- a/collects/honu/main.ss +++ b/collects/honu/main.ss @@ -4,13 +4,18 @@ "private/macro.ss") (provide (rename-out (#%dynamic-honu-module-begin #%module-begin) - (honu-top #%top)) + (honu-top #%top) + (semicolon \;) + (honu-+ +) + (honu-* *) + (honu-/ /) + (honu-- -) + ) #%datum true false display newline - \; else (rename-out (honu-if if) diff --git a/collects/honu/private/honu-typed-scheme.ss b/collects/honu/private/honu-typed-scheme.ss index bf7f30046b..1c767b9618 100644 --- a/collects/honu/private/honu-typed-scheme.ss +++ b/collects/honu/private/honu-typed-scheme.ss @@ -6,6 +6,7 @@ syntax/name syntax/define syntax/parse + scheme/splicing "contexts.ss" "util.ss" "ops.ss" @@ -13,16 +14,25 @@ ;; "typed-utils.ss" ) +(require (for-meta 2 scheme/base "util.ss")) +(require (for-meta 3 scheme/base)) + (provide (all-defined-out)) ;; macro for defining literal tokens that can be used in macros -(define-syntax-rule (define-literal name) - (define-syntax name (lambda (stx) +(define-syntax-rule (define-literal name ...) + (begin + (define-syntax name (lambda (stx) (raise-syntax-error 'name - "this is a literal and cannot be used outside a macro")))) + "this is a literal and cannot be used outside a macro"))) + ...)) (define-literal honu-return) -(define-literal \;) +(define-literal semicolon) +(define-literal honu-+ honu-* honu-/ honu-- honu-|| honu-% + honu-= honu-+= honu--= honu-*= honu-/= honu-%= + honu-&= honu-^= honu-\|= honu-<<= honu->>= honu->>>= + honu->> honu-<< honu->>> honu-< honu-> honu-<= honu->=) ;; (define-syntax (\; stx) (raise-syntax-error '\; "out of context" stx)) @@ -338,6 +348,13 @@ [else (call-values parse-one (extract-until body (list #'\; )))])) +#| +(define-honu-macro (e ... * e ... \;)) + +(foo . bar ()) +x(2) +|# + (define (parse-block-one/2 stx context) (define (parse-one stx context) (define-syntax-class block @@ -349,18 +366,106 @@ body.result)]) (define-syntax-class expr [pattern f]) + (define-splicing-syntax-class call - [pattern (~seq e:expr (#%parens args ...)) - #:with call #'(e args ...)]) - (define-syntax-class expression - #:literals (\;) - [pattern (call:call \; . rest) #:with result #'call.call] - [pattern (x:number \; . rest) #:with result #'x] + [pattern (~seq e:expr (#%parens arg:expression-1)) + #:with call #'(e arg.result)]) + (define-splicing-syntax-class expression-last + [pattern (~seq call:call) #:with result #'call.call] + [pattern (~seq x:number) #:with result #'x] ) + + (define-syntax-rule (define-infix-operator name next [operator reducer] ...) + (define-splicing-syntax-class name + #:literals (operator ...) + [pattern (~seq (~var left next) operator (~var right name)) + #:with result (reducer #'left.result #'right.result)] + ... + [pattern (~seq (~var exp next)) + #:with result #'exp.result] + )) + + ;; TODO: maybe just have a precedence macro that creates all these constructs + ;; (infix-operators ([honu-* ...] + ;; [honu-- ...]) + ;; ([honu-+ ...] + ;; [honu-- ...])) + ;; Where operators defined higher in the table have higher precedence. + (define-syntax (infix-operators stx) + (define (create-stuff names operator-stuff) + (define make (syntax-lambda (expression next-expression operator-stuff) + #; + (printf "Make infix ~a ~a\n" (syntax->datum #'expression) (syntax->datum #'next-expression)) + (with-syntax ([(ops ...) #'operator-stuff]) + #'(define-infix-operator expression next-expression ops ...)))) + (for/list ([name1 (drop-last names)] + [name2 (cdr names)] + [operator operator-stuff]) + (make name1 name2 operator))) + (syntax-case stx () + [(_ first last operator-stuff ...) + (with-syntax ([(name ...) (generate-temporaries #'(operator-stuff ...))]) + (with-syntax ([(result ...) (create-stuff (cons #'first + (append + (drop-last (syntax->list #'(name ...))) + (list #'last))) + + (syntax->list #'(operator-stuff ...)))]) + #'(begin + result ...)))])) + + #; + (infix-operators expression-1 expression-last + ([honu-+ (syntax-lambda (left right) + #'(+ left right))] + [honu-- (syntax-lambda (left right) + #'(- left right))]) + ([honu-* (syntax-lambda (left right) + #'(* left right))] + [honu-/ (syntax-lambda (left right) + #'(/ left right))])) + + + (define-syntax-class expression-top + [pattern (e:expression-1 semicolon . rest) + #:with result #'e.result]) + + + ;; infix operators in the appropriate precedence level + ;; things defined lower in the table have a higher precedence. + ;; the first set of operators is `expression-1' + (splicing-let-syntax ([sl (make-rename-transformer #'syntax-lambda)]) + (infix-operators expression-1 expression-last + ([honu-= (sl (left right) #'(= left right))] + [honu-+= (sl (left right) #'(+ left right))] + [honu--= (sl (left right) #'(- left right))] + [honu-*= (sl (left right) #'(* left right))] + [honu-/= (sl (left right) #'(/ left right))] + [honu-%= (sl (left right) #'(modulo left right))] + [honu-&= (sl (left right) #'(+ left right))] + [honu-^= (sl (left right) #'(+ left right))] + [honu-\|= (sl (left right) #'(+ left right))] + [honu-<<= (sl (left right) #'(+ left right))] + [honu->>= (sl (left right) #'(+ left right))] + [honu->>>= (sl (left right) #'(+ left right))]) + ([honu-|| (sl (left right) #'(+ left right))]) + ([honu->> (sl (left right) #'(+ left right))] + [honu-<< (sl (left right) #'(+ left right))] + [honu->>> (sl (left right) #'(+ left right))] + [honu-< (sl (left right) #'(< left right))] + [honu-> (sl (left right) #'(> left right))] + [honu-<= (sl (left right) #'(<= left right))] + [honu->= (sl (left right) #'(>= left right))]) + ([honu-+ (sl (left right) #'(+ left right))] + [honu-- (sl (left right) #'(- left right))]) + ([honu-* (sl (left right) #'(* left right))] + [honu-% (sl (left right) #'(modulo left right))] + [honu-/ (sl (left right) #'(/ left right))]))) + ;; (printf "~a\n" (syntax-class-parse function stx)) (syntax-parse stx [function:function (values #'function.result #'function.rest)] - [expr:expression (values #'expr.result #'expr.rest)] + [expr:expression-top (values #'expr.result #'expr.rest)] [(x:number . rest) (values #'x #'rest)] )) (cond diff --git a/collects/honu/private/util.ss b/collects/honu/private/util.ss index fe11586a0f..5120dd3cfa 100644 --- a/collects/honu/private/util.ss +++ b/collects/honu/private/util.ss @@ -1,11 +1,14 @@ #lang scheme +(provide (except-out (all-defined-out) test)) +#; (provide delim-identifier=? extract-until call-values) -(require syntax/stx) +(require syntax/stx + scheme/list) (define (delim-identifier=? a b) (eq? (syntax-e a) (syntax-e b))) @@ -33,6 +36,19 @@ (define-syntax-rule (call-values function values-producing) (call-with-values (lambda () values-producing) function)) +;; shortcut for treating arguments as syntax objects +(define-syntax (syntax-lambda stx) + (syntax-case stx () + [(_ (arg ...) body ...) + (with-syntax ([(temp ...) (generate-temporaries #'(arg ...))]) + #'(lambda (temp ...) + (with-syntax ([arg temp] ...) + body ...)))])) + +;; removes the last element of a list +(define (drop-last lst) + (take lst (sub1 (length lst)))) + (define (test) (let* ([original #'(a b c d e)] [delimiter #'c] diff --git a/collects/meta/dist-specs.ss b/collects/meta/dist-specs.ss index da8a2722ab..b96401b67b 100644 --- a/collects/meta/dist-specs.ss +++ b/collects/meta/dist-specs.ss @@ -91,6 +91,7 @@ i386-linux-fc6 :=tag unix i386-linux-f7 :=tag unix x86_64-linux-f7 :=tag unix i386-linux-f9 :=tag unix +i386-linux-f12 :=tag unix i386-linux-debian :=tag unix i386-linux-debian-testing :=tag unix i386-linux-debian-unstable :=tag unix diff --git a/collects/mrlib/image-core.ss b/collects/mrlib/image-core.ss index 29e02a9ae0..ceee10e07c 100644 --- a/collects/mrlib/image-core.ss +++ b/collects/mrlib/image-core.ss @@ -908,7 +908,7 @@ the mask bitmap and the original bitmap are all together in a single bytes! curve-segment-start curve-segment-s-angle curve-segment-s-pull curve-segment-end curve-segment-e-angle curve-segment-e-pull curve-segment-color - make-pen pen? pen-color pen-width pen-style pen-cap pen-join + make-pen pen? pen-color pen-width pen-style pen-cap pen-join pen make-bitmap bitmap? bitmap-raw-bitmap bitmap-raw-mask bitmap-angle bitmap-x-scale bitmap-y-scale bitmap-rendered-bitmap bitmap-rendered-mask diff --git a/collects/repos-time-stamp/stamp.ss b/collects/repos-time-stamp/stamp.ss index 9a66d363f5..df4650e6ca 100644 --- a/collects/repos-time-stamp/stamp.ss +++ b/collects/repos-time-stamp/stamp.ss @@ -1 +1 @@ -#lang scheme/base (provide stamp) (define stamp "16jan2010") +#lang scheme/base (provide stamp) (define stamp "23jan2010") diff --git a/collects/syntax/private/stxparse/rep.ss b/collects/syntax/private/stxparse/rep.ss index e5d993b059..b0a31a43c3 100644 --- a/collects/syntax/private/stxparse/rep.ss +++ b/collects/syntax/private/stxparse/rep.ss @@ -973,7 +973,7 @@ (define (check-sc-expr x) (syntax-case x () [sc (identifier? #'sc) (list #'sc null)] - [(sc arg ...) (identifier? #'sc) (list #'sc #'(arg ...))] + [(sc arg ...) (identifier? #'sc) (list #'sc (syntax->list #'(arg ...)))] [_ (raise-syntax-error #f "expected syntax class use" ctx x)])) (syntax-case stx () [(rx sc) diff --git a/collects/syntax/scribblings/parse-patterns.scrbl b/collects/syntax/scribblings/parse-patterns.scrbl index 17a999542f..81cdceb011 100644 --- a/collects/syntax/scribblings/parse-patterns.scrbl +++ b/collects/syntax/scribblings/parse-patterns.scrbl @@ -104,6 +104,7 @@ means specifically @tech{@Spattern}. (~not S-pattern) #((unsyntax @svar[pattern-part]) ...) #s(prefab-struct-key (unsyntax @svar[pattern-part]) ...) + #&@#,svar[S-pattern] (~rest S-pattern) (@#,ref[~describe s] expr S-pattern) A-pattern] @@ -515,6 +516,17 @@ key and whose sequence of fields, when considered as a list, match the ] } +@specsubform[#&@#,svar[S-pattern]]{ + +Matches a term that is a box whose contents matches the inner +@tech{@Spattern}. + +@myexamples[ +(syntax-parse #'#&5 + [#&n:nat 'ok]) +] +} + @specsubform[(#, @defhere[~rest] S-pattern)]{ Matches just like @scheme[S-pattern]. The @scheme[~rest] pattern form diff --git a/collects/teachpack/2htdp/scribblings/image.scrbl b/collects/teachpack/2htdp/scribblings/image.scrbl index 53026fa901..4a40b50c49 100644 --- a/collects/teachpack/2htdp/scribblings/image.scrbl +++ b/collects/teachpack/2htdp/scribblings/image.scrbl @@ -8,10 +8,18 @@ lang/posn "shared.ss" "image-util.ss" + scribble/decode scribble/manual) @teachpack["image"]{Images} +@(define mode/color-text + (make-splice + @list{If the @scheme[mode] is @scheme['outline] or @scheme["outline"], then the last + argument can be a @scheme[pen] struct or an @scheme[image-color?], but if the @scheme[mode] + is @scheme['solid] or @scheme["solid"], then the last argument must be an + @scheme[image-color?].})) + @defmodule[#:require-form beginner-require 2htdp/image] The image teachpack provides a number of basic image construction functions, along with @@ -27,70 +35,85 @@ Existing images can be rotated, scaled, and overlaid on top of each other. [color image-color?]) image?] [(circle [radius (and/c real? (not/c negative?))] - [mode 'outline] - [color pen?]) + [outline-mode (or/c 'outline "outline")] + [pen-or-color (or/c pen? image-color?)]) image?])]{ Constructs a circle with the given radius, height, mode, and color. - If the @scheme[mode] is @scheme['outline], then the @scheme[color] - can be a @scheme[pen?] struct or an @scheme[image-color?], but if the @scheme[mode] - is @scheme['solid], then the @scheme[color] must be an - @scheme[image-color?]. - - @image-examples[(circle 30 "outline" "red") - (circle 20 "solid" "blue")] + @mode/color-text + + @image-examples[(circle 30 "outline" "red") + (circle 20 "solid" "blue")] } -@defproc[(ellipse [width (and/c real? (not/c negative?))] - [height (and/c real? (not/c negative?))] - [mode mode?] - [color (or/c image-color? pen?)]) - image?]{ +@defproc*[([(ellipse [width (and/c real? (not/c negative?))] + [height (and/c real? (not/c negative?))] + [mode mode?] + [color image-color?]) + image?] + [(ellipse [width (and/c real? (not/c negative?))] + [height (and/c real? (not/c negative?))] + [mode (or/c 'outline "outline")] + [pen-or-color (or/c image-color? pen?)]) + image?])]{ Constructs an ellipsis with the given width, height, mode, and color. - If the @scheme[mode] is @scheme['outline], then the @scheme[color] - can be a @scheme[pen?] struct or an @scheme[image-color?], but if the @scheme[mode] - is @scheme['solid], then the @scheme[color] must be an - @scheme[image-color?]. + @mode/color-text @image-examples[(ellipse 40 20 "outline" "black") (ellipse 20 40 "solid" "blue")] } -@defproc[(triangle [side-length (and/c real? (not/c negative?))] - [mode mode?] - [color (if (or (equal? mode 'outline) - (equal? mode "outline")) - (or/c image-color? pen?) - image-color?)]) - image?]{ +@defproc*[([(triangle [side-length (and/c real? (not/c negative?))] + [mode mode?] + [color image-color?]) + image?] + [(triangle [side-length (and/c real? (not/c negative?))] + [outline-mode (or/c 'outline "outline")] + [pen-or-color (or/c pen? image-color?)]) + image?])]{ + Constructs a upward-pointing equilateral triangle. The @scheme[side-length] argument determines the length of the side of the triangle. -@image-examples[(triangle 40 "solid" "tan")] + @mode/color-text + + @image-examples[(triangle 40 "solid" "tan")] } -@defproc[(right-triangle [side-length1 (and/c real? (not/c negative?))] - [side-length2 (and/c real? (not/c negative?))] - [mode mode?] - [color image-color?]) - image?]{ +@defproc*[([(right-triangle [side-length1 (and/c real? (not/c negative?))] + [side-length2 (and/c real? (not/c negative?))] + [mode mode?] + [color image-color?]) + image?] + [(right-triangle [side-length1 (and/c real? (not/c negative?))] + [side-length2 (and/c real? (not/c negative?))] + [outline-mode (or/c 'outline "outline")] + [pen-or-color (or/c pen? image-color?)]) + image?])]{ Constructs a triangle with a right angle where the two sides adjacent to the right angle have lengths @scheme[side-length1] and @scheme[side-length2]. + @mode/color-text + @image-examples[(right-triangle 36 48 "solid" "black")] } - -@defproc[(isosceles-triangle [side-length (and/c real? (not/c negative?))] - [angle angle?] - [mode mode?] - [color image-color?]) - image?]{ + +@defproc*[([(isosceles-triangle [side-length (and/c real? (not/c negative?))] + [angle angle?] + [mode mode?] + [color image-color?]) + image?] + [(isosceles-triangle [side-length (and/c real? (not/c negative?))] + [angle angle?] + [outline-mode (or/c 'outline "outline")] + [pen-or-color (or/c pen? image-color?)]) + image?])]{ Creates a triangle with two equal-length sides, of length @scheme[side-length] where the angle between those sides is @scheme[angle]. The third @@ -98,72 +121,118 @@ Existing images can be rotated, scaled, and overlaid on top of each other. @scheme[180], then the triangle will point up and if the @scheme[angle] is more, then the triangle will point down. + @mode/color-text + @image-examples[(isosceles-triangle 200 170 "solid" "seagreen") (isosceles-triangle 60 30 "solid" "aquamarine") (isosceles-triangle 60 330 "solid" "lightseagreen")] } -@defproc[(square [side-length (and/c real? (not/c negative?))] - [mode mode?] - [color image-color?]) - image?]{ +@defproc*[([(square [side-len (and/c real? (not/c negative?))] + [mode mode?] + [color image-color?]) + image?] + [(square [side-len (and/c real? (not/c negative?))] + [outline-mode (or/c 'outline "outline")] + [pen-or-color (or/c pen? image-color?)]) + image?])]{ Constructs a square. + @mode/color-text + @image-examples[(square 40 "solid" "slateblue") (square 50 "outline" "darkmagenta")] } -@defproc[(rectangle [width real?] [height real?] [mode mode?] [color image-color?]) image?]{ +@defproc*[([(rectangle [width real?] + [height real?] + [mode mode?] + [color image-color?]) + image?] + [(rectangle [width real?] + [height real?] + [outline-mode (or/c 'outline "outline")] + [pen-or-color (or/c pen? image-color?)]) + image?])]{ Constructs a rectangle with the given width, height, mode, and color. + + @mode/color-text + @image-examples[(rectangle 40 20 "outline" "black") (rectangle 20 40 "solid" "blue")] } -@defproc[(rhombus [side-length (and/c real? (not/c negative?))] - [angle angle?] - [mode mode?] - [color image-color?]) - image?]{ +@defproc*[([(rhombus [side-length (and/c real? (not/c negative?))] + [angle angle?] + [mode mode?] + [color image-color?]) + image?] + [(rhombus [side-length (and/c real? (not/c negative?))] + [angle angle?] + [outline-mode (or/c 'outline "outline")] + [pen-or-color (or/c pen? image-color?)]) + image?])]{ Constructs a four sided polygon with all equal sides and thus where opposite angles are equal to each other. The top and bottom pair of angles is @scheme[angle] and the left and right are @scheme[(- 180 angle)]. +@mode/color-text + @image-examples[(rhombus 40 45 "solid" "magenta") (rhombus 80 150 "solid" "mediumpurple")] } -@defproc[(regular-polygon [side-length (and/c real? (not/c negative?))] - [side-count side-count?] - [mode mode?] - [color image-color?]) - image?]{ +@defproc*[([(regular-polygon [side-length (and/c real? (not/c negative?))] + [side-count side-count?] + [mode mode?] + [color image-color?]) + image?] + [(regular-polygon [side-length (and/c real? (not/c negative?))] + [side-count side-count?] + [outline-mode (or/c 'outline "outline")] + [pen-or-color (or/c pen? image-color?)]) + image?])]{ Constructs a regular polygon with @scheme[side-count] sides. + @mode/color-text + @image-examples[(regular-polygon 50 3 "outline" "red") (regular-polygon 40 4 "outline" "blue") (regular-polygon 20 8 "solid" "red")] } -@defproc[(star [side-length (and/c real? (not/c negative?))] - [mode mode?] - [color image-color?]) - image?]{ +@defproc*[([(star [side-length (and/c real? (not/c negative?))] + [mode mode?] + [color image-color?]) + image?] + [(star [side-length (and/c real? (not/c negative?))] + [outline-mode (or/c 'outline "outline")] + [color (or/c pen? image-color?)]) + image?])]{ Constructs a star with five points. The @scheme[side-length] argument determines the side length of the enclosing pentagon. + @mode/color-text + @image-examples[(star 40 "solid" "gray")] } -@defproc[(star-polygon [side-length (and/c real? (not/c negative?))] - [side-count side-count?] - [step-count step-count?] - [mode mode?] - [color image-color?]) - image?]{ +@defproc*[([(star-polygon [side-length (and/c real? (not/c negative?))] + [side-count side-count?] + [step-count step-count?] + [mode mode?] + [color image-color?]) + image?] + [(star-polygon [side-length (and/c real? (not/c negative?))] + [side-count side-count?] + [step-count step-count?] + [outline-mode (or/c 'outline "outline")] + [pen-or-color (or/c pen? image-color?)]) + image?])]{ Constructs an arbitrary regular star polygon (a generalization of the regular polygons). The polygon is enclosed by a regular polygon with @scheme[side-count] sides each @@ -173,18 +242,26 @@ other. The top and bottom pair of angles is @scheme[angle] and the left and righ For examples, if @scheme[side-count] is @scheme[5] and @scheme[step-count] is @scheme[2], then this function produces a shape just like @scheme[star]. + @mode/color-text + @image-examples[(star-polygon 40 5 2 "solid" "seagreen") (star-polygon 40 7 3 "outline" "darkred") (star-polygon 20 10 3 "solid" "cornflowerblue")] } -@defproc[(polygon [verticies (listof posn?)] - [mode mode?] - [color image-color?]) - image?]{ +@defproc*[([(polygon [verticies (listof posn?)] + [mode mode?] + [color image-color?]) + image?] + [(polygon [verticies (listof posn?)] + [outline-mode (or/c 'outline "outline")] + [pen-or-color (or/c pen? image-color?)]) + image?])]{ Constructs a polygon connecting the given verticies. + @mode/color-text + @image-examples[(polygon (list (make-posn 0 0) (make-posn -10 20) (make-posn 60 0) @@ -692,10 +769,20 @@ the parts that fit onto @scheme[scene]. } @defproc[(scale [factor real?] [image image?]) image?]{ + Scales @scheme[image] by @scheme[factor]. + + The pen sizes are also scaled and thus draw thicker (or thinner) + lines than the original image, unless the pen was size + @scheme[0]. That pen size is treated specially to mean ``the + smallest available line'' and thus it always draws a one pixel + wide line; this is also the case for @scheme['outline] and @scheme["outline"] + shapes that are drawn with an @scheme[image-color?] instead of + a @scheme[pen]. + - @image-examples[(scale 2 (ellipse 20 30 "solid" "blue")) - (ellipse 40 60 "solid" "blue")] + @image-examples[(scale 2 (ellipse 20 30 "solid" "blue")) + (ellipse 40 60 "solid" "blue")] @@ -916,3 +1003,34 @@ The baseline of an image is the place where the bottoms any letters line up, not Two images are equal if they draw exactly the same way, at their current size (not neccessarily at all sizes). +@section[#:tag "nitty-gritty"]{The nitty gritty of pixels, pens, and lines} + +The image library treats coordinates as if they are in the upper-left corner +of each pixel, and infinitesimally small. + +Thus, when drawing a solid @scheme[square] of whose side-length is 10, the image library +colors in all of the pixels enclosed by the @scheme[square] starting at the upper +left corner of (0,0) and going down to the upper left corner of (10,10), +so the pixel whose upper left at (9,9) is colored in, but the pixel +at (10,10) is not. All told, 100 pixels get colored in, just as expected for +a @scheme[square] with a side length of 10. + +When drawing lines, however, things get a bit more complex. Specifically, +imagine drawing the outline of that rectangle. Since the border is +between the pixels, there really isn't a natural pixel to draw to indicate +the border. Accordingly, when drawing an outline @scheme[square] (without a +@scheme[pen] specification, but just a color as the last argument), +the image library uses a pen whose width is 1 pixel, but draws a line +centered at the point (0.5,0.5) that goes down and around to the point (10.5,10.5). +This means that the outline slightly exceeds the bounding box of the shape. +Specifically, the upper and left-hand lines around the square are within +the bounding box, but the lower and right-hand lines are just outside. + +The special case of adding 0.5 to each coordinate when drawing the square +applies to all polygon-based shapes, but does not apply when a @scheme[pen] +is passed as the last argument to create the shape. +In that case, not adjustment of the pixels is performed and using a one +pixel wide pen draws the pixels above and below the line, but each with +a color that is half of the intensity of the given color. Using a +@scheme[pen] with with two, colors the pixels above and below the line +with the full intensity. diff --git a/collects/teachpack/2htdp/scribblings/img/10735f73f78.png b/collects/teachpack/2htdp/scribblings/img/10735f73f78.png index 41d52546c0..74b36d7285 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/10735f73f78.png and b/collects/teachpack/2htdp/scribblings/img/10735f73f78.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/10847861f4b.png b/collects/teachpack/2htdp/scribblings/img/10847861f4b.png index 28209c64d4..93d0e90557 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/10847861f4b.png and b/collects/teachpack/2htdp/scribblings/img/10847861f4b.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/10a0d35fa03.png b/collects/teachpack/2htdp/scribblings/img/10a0d35fa03.png index 37de0d1fa4..d8716f4a65 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/10a0d35fa03.png and b/collects/teachpack/2htdp/scribblings/img/10a0d35fa03.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/1132401ea93.png b/collects/teachpack/2htdp/scribblings/img/1132401ea93.png index 48045cdc4c..76bd236080 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/1132401ea93.png and b/collects/teachpack/2htdp/scribblings/img/1132401ea93.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/11402043018.png b/collects/teachpack/2htdp/scribblings/img/11402043018.png index 4d58aaeb8c..19d80754fd 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/11402043018.png and b/collects/teachpack/2htdp/scribblings/img/11402043018.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/11b64ab4d3.png b/collects/teachpack/2htdp/scribblings/img/11b64ab4d3.png index cd3326d096..db3f38aa1c 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/11b64ab4d3.png and b/collects/teachpack/2htdp/scribblings/img/11b64ab4d3.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/126418b230e.png b/collects/teachpack/2htdp/scribblings/img/126418b230e.png index 042649d335..6d834be9f9 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/126418b230e.png and b/collects/teachpack/2htdp/scribblings/img/126418b230e.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/12948ac080d.png b/collects/teachpack/2htdp/scribblings/img/12948ac080d.png index a61711fd62..2bbf621e91 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/12948ac080d.png and b/collects/teachpack/2htdp/scribblings/img/12948ac080d.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/12b0447b10c.png b/collects/teachpack/2htdp/scribblings/img/12b0447b10c.png index ea65c0a194..646be0ddd1 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/12b0447b10c.png and b/collects/teachpack/2htdp/scribblings/img/12b0447b10c.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/1325a6e7bdb.png b/collects/teachpack/2htdp/scribblings/img/1325a6e7bdb.png index 6debf734d9..4cfccb6111 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/1325a6e7bdb.png and b/collects/teachpack/2htdp/scribblings/img/1325a6e7bdb.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/133309751d2.png b/collects/teachpack/2htdp/scribblings/img/133309751d2.png index 6ab99f4b06..76665a9d69 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/133309751d2.png and b/collects/teachpack/2htdp/scribblings/img/133309751d2.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/138792ad221.png b/collects/teachpack/2htdp/scribblings/img/138792ad221.png index 35474865fa..f7b6c835ff 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/138792ad221.png and b/collects/teachpack/2htdp/scribblings/img/138792ad221.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/13aef4074e9.png b/collects/teachpack/2htdp/scribblings/img/13aef4074e9.png index 2550b83eb3..7220d4363c 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/13aef4074e9.png and b/collects/teachpack/2htdp/scribblings/img/13aef4074e9.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/13b344ed2ff.png b/collects/teachpack/2htdp/scribblings/img/13b344ed2ff.png index c2a1ac2e4d..1e8277f47b 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/13b344ed2ff.png and b/collects/teachpack/2htdp/scribblings/img/13b344ed2ff.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/13e518b230e.png b/collects/teachpack/2htdp/scribblings/img/13e518b230e.png index 2a6171ff5a..1cb973ebd3 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/13e518b230e.png and b/collects/teachpack/2htdp/scribblings/img/13e518b230e.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/1404e4b2af.png b/collects/teachpack/2htdp/scribblings/img/1404e4b2af.png index 4054bff87e..7a77934126 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/1404e4b2af.png and b/collects/teachpack/2htdp/scribblings/img/1404e4b2af.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/150e1d5e9f.png b/collects/teachpack/2htdp/scribblings/img/150e1d5e9f.png index 818f75c8e0..a1b9c64aad 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/150e1d5e9f.png and b/collects/teachpack/2htdp/scribblings/img/150e1d5e9f.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/1532990d5cb.png b/collects/teachpack/2htdp/scribblings/img/1532990d5cb.png index 84f6cd5fc6..2cbd994d51 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/1532990d5cb.png and b/collects/teachpack/2htdp/scribblings/img/1532990d5cb.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/15717b87d30.png b/collects/teachpack/2htdp/scribblings/img/15717b87d30.png index 3290717ca7..8cae7a8f42 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/15717b87d30.png and b/collects/teachpack/2htdp/scribblings/img/15717b87d30.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/157ab5efca7.png b/collects/teachpack/2htdp/scribblings/img/157ab5efca7.png index 3290717ca7..8cae7a8f42 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/157ab5efca7.png and b/collects/teachpack/2htdp/scribblings/img/157ab5efca7.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/164b8da7bf6.png b/collects/teachpack/2htdp/scribblings/img/164b8da7bf6.png index 73e3167594..3f5e957375 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/164b8da7bf6.png and b/collects/teachpack/2htdp/scribblings/img/164b8da7bf6.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/169990a635e.png b/collects/teachpack/2htdp/scribblings/img/169990a635e.png index f812cf671a..b2593ebe1a 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/169990a635e.png and b/collects/teachpack/2htdp/scribblings/img/169990a635e.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/169f2ceb45c.png b/collects/teachpack/2htdp/scribblings/img/169f2ceb45c.png index 89fdbfc52e..d4b7ede7b8 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/169f2ceb45c.png and b/collects/teachpack/2htdp/scribblings/img/169f2ceb45c.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/16a631adf1e.png b/collects/teachpack/2htdp/scribblings/img/16a631adf1e.png index 5bbe9d16d4..ef51f68169 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/16a631adf1e.png and b/collects/teachpack/2htdp/scribblings/img/16a631adf1e.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/196bfa7b9c4.png b/collects/teachpack/2htdp/scribblings/img/196bfa7b9c4.png index e77dceabaf..2a646850aa 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/196bfa7b9c4.png and b/collects/teachpack/2htdp/scribblings/img/196bfa7b9c4.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/1a0088e3819.png b/collects/teachpack/2htdp/scribblings/img/1a0088e3819.png index d23a3b9702..da6a6aaafc 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/1a0088e3819.png and b/collects/teachpack/2htdp/scribblings/img/1a0088e3819.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/1aaa434b462.png b/collects/teachpack/2htdp/scribblings/img/1aaa434b462.png index 77e7adbefe..9e3acbc688 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/1aaa434b462.png and b/collects/teachpack/2htdp/scribblings/img/1aaa434b462.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/1acede17bc6.png b/collects/teachpack/2htdp/scribblings/img/1acede17bc6.png index 99da2170c4..4d047fdaec 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/1acede17bc6.png and b/collects/teachpack/2htdp/scribblings/img/1acede17bc6.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/1bbeedc0d6.png b/collects/teachpack/2htdp/scribblings/img/1bbeedc0d6.png index c2be67c839..cd170b1c51 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/1bbeedc0d6.png and b/collects/teachpack/2htdp/scribblings/img/1bbeedc0d6.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/1f0b671ed7b.png b/collects/teachpack/2htdp/scribblings/img/1f0b671ed7b.png index 14f280af24..2d310ea332 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/1f0b671ed7b.png and b/collects/teachpack/2htdp/scribblings/img/1f0b671ed7b.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/1f5944ec1ed.png b/collects/teachpack/2htdp/scribblings/img/1f5944ec1ed.png index 2b513da234..8c49da86a2 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/1f5944ec1ed.png and b/collects/teachpack/2htdp/scribblings/img/1f5944ec1ed.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/201c231dce2.png b/collects/teachpack/2htdp/scribblings/img/201c231dce2.png index f641cfdd40..582f004f71 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/201c231dce2.png and b/collects/teachpack/2htdp/scribblings/img/201c231dce2.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/2187216ca96.png b/collects/teachpack/2htdp/scribblings/img/2187216ca96.png index 425739ecc5..36949fd2ba 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/2187216ca96.png and b/collects/teachpack/2htdp/scribblings/img/2187216ca96.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/21b080bdda8.png b/collects/teachpack/2htdp/scribblings/img/21b080bdda8.png index 6bf1de68c5..d3e0c455b7 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/21b080bdda8.png and b/collects/teachpack/2htdp/scribblings/img/21b080bdda8.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/2330a222ac0.png b/collects/teachpack/2htdp/scribblings/img/2330a222ac0.png index 9274a7d58d..d039ba6c0b 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/2330a222ac0.png and b/collects/teachpack/2htdp/scribblings/img/2330a222ac0.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/24365c877d4.png b/collects/teachpack/2htdp/scribblings/img/24365c877d4.png index 80925da142..a055c89ab2 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/24365c877d4.png and b/collects/teachpack/2htdp/scribblings/img/24365c877d4.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/24410dd26db.png b/collects/teachpack/2htdp/scribblings/img/24410dd26db.png index 49980a64a9..d42b68d73b 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/24410dd26db.png and b/collects/teachpack/2htdp/scribblings/img/24410dd26db.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/24e80ea10b4.png b/collects/teachpack/2htdp/scribblings/img/24e80ea10b4.png index 3fa98bc587..43659d6e16 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/24e80ea10b4.png and b/collects/teachpack/2htdp/scribblings/img/24e80ea10b4.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/25354f2b84e.png b/collects/teachpack/2htdp/scribblings/img/25354f2b84e.png index ef8f7a061a..03cb70eb74 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/25354f2b84e.png and b/collects/teachpack/2htdp/scribblings/img/25354f2b84e.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/25451dd2997.png b/collects/teachpack/2htdp/scribblings/img/25451dd2997.png index bccea64f92..2833c9b7d5 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/25451dd2997.png and b/collects/teachpack/2htdp/scribblings/img/25451dd2997.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/25dd3e2d97c.png b/collects/teachpack/2htdp/scribblings/img/25dd3e2d97c.png index f5ab17d819..6f31fd2399 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/25dd3e2d97c.png and b/collects/teachpack/2htdp/scribblings/img/25dd3e2d97c.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/262a4fa650a.png b/collects/teachpack/2htdp/scribblings/img/262a4fa650a.png index a6cb9f5584..0dd50084e1 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/262a4fa650a.png and b/collects/teachpack/2htdp/scribblings/img/262a4fa650a.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/268c974b9ab.png b/collects/teachpack/2htdp/scribblings/img/268c974b9ab.png index 6ec37c3a0d..bbc68329a5 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/268c974b9ab.png and b/collects/teachpack/2htdp/scribblings/img/268c974b9ab.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/26bd803042c.png b/collects/teachpack/2htdp/scribblings/img/26bd803042c.png index 14f280af24..2d310ea332 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/26bd803042c.png and b/collects/teachpack/2htdp/scribblings/img/26bd803042c.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/26c4c403875.png b/collects/teachpack/2htdp/scribblings/img/26c4c403875.png index ef6d9ce1c9..7cb0cc0280 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/26c4c403875.png and b/collects/teachpack/2htdp/scribblings/img/26c4c403875.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/2758748ad7f.png b/collects/teachpack/2htdp/scribblings/img/2758748ad7f.png index dddda8f4b6..0814f3ef95 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/2758748ad7f.png and b/collects/teachpack/2htdp/scribblings/img/2758748ad7f.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/27bbbb6fd64.png b/collects/teachpack/2htdp/scribblings/img/27bbbb6fd64.png index 444f8734de..ffe47dc980 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/27bbbb6fd64.png and b/collects/teachpack/2htdp/scribblings/img/27bbbb6fd64.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/28253f4c3c.png b/collects/teachpack/2htdp/scribblings/img/28253f4c3c.png index 4562244049..d2a06d730c 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/28253f4c3c.png and b/collects/teachpack/2htdp/scribblings/img/28253f4c3c.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/28c73238138.png b/collects/teachpack/2htdp/scribblings/img/28c73238138.png index ecaaca4378..27c038dd27 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/28c73238138.png and b/collects/teachpack/2htdp/scribblings/img/28c73238138.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/28daec71a64.png b/collects/teachpack/2htdp/scribblings/img/28daec71a64.png index 0642049e27..886c76044a 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/28daec71a64.png and b/collects/teachpack/2htdp/scribblings/img/28daec71a64.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/29b31e5fe3a.png b/collects/teachpack/2htdp/scribblings/img/29b31e5fe3a.png index 32d27bb051..82647dc886 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/29b31e5fe3a.png and b/collects/teachpack/2htdp/scribblings/img/29b31e5fe3a.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/2a1f3988f.png b/collects/teachpack/2htdp/scribblings/img/2a1f3988f.png index 3856a91e09..ce9a9ae737 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/2a1f3988f.png and b/collects/teachpack/2htdp/scribblings/img/2a1f3988f.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/2b944b7ab91.png b/collects/teachpack/2htdp/scribblings/img/2b944b7ab91.png index c951e4c565..f0777aad1e 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/2b944b7ab91.png and b/collects/teachpack/2htdp/scribblings/img/2b944b7ab91.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/2cc717fb347.png b/collects/teachpack/2htdp/scribblings/img/2cc717fb347.png index de0f691ba8..02e149bfb9 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/2cc717fb347.png and b/collects/teachpack/2htdp/scribblings/img/2cc717fb347.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/2d9ba9032e.png b/collects/teachpack/2htdp/scribblings/img/2d9ba9032e.png index e77dceabaf..2a646850aa 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/2d9ba9032e.png and b/collects/teachpack/2htdp/scribblings/img/2d9ba9032e.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/2dde939d6dc.png b/collects/teachpack/2htdp/scribblings/img/2dde939d6dc.png index 3a952a3d57..db7413ee30 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/2dde939d6dc.png and b/collects/teachpack/2htdp/scribblings/img/2dde939d6dc.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/2e6a31a9033.png b/collects/teachpack/2htdp/scribblings/img/2e6a31a9033.png index 178a528a7b..879569394e 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/2e6a31a9033.png and b/collects/teachpack/2htdp/scribblings/img/2e6a31a9033.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/353ed4578.png b/collects/teachpack/2htdp/scribblings/img/353ed4578.png index 3856a91e09..ce9a9ae737 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/353ed4578.png and b/collects/teachpack/2htdp/scribblings/img/353ed4578.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/42f9f9e4cf.png b/collects/teachpack/2htdp/scribblings/img/42f9f9e4cf.png index 6ab99f4b06..76665a9d69 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/42f9f9e4cf.png and b/collects/teachpack/2htdp/scribblings/img/42f9f9e4cf.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/4e85791a5.png b/collects/teachpack/2htdp/scribblings/img/4e85791a5.png index 0431b81188..e435679667 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/4e85791a5.png and b/collects/teachpack/2htdp/scribblings/img/4e85791a5.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/54a488e1a5.png b/collects/teachpack/2htdp/scribblings/img/54a488e1a5.png index ea08ed9937..c9e9b1a692 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/54a488e1a5.png and b/collects/teachpack/2htdp/scribblings/img/54a488e1a5.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/54d58bf7f6.png b/collects/teachpack/2htdp/scribblings/img/54d58bf7f6.png index 21d9ada3cb..942c2e52bf 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/54d58bf7f6.png and b/collects/teachpack/2htdp/scribblings/img/54d58bf7f6.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/5ec4a0cb1f.png b/collects/teachpack/2htdp/scribblings/img/5ec4a0cb1f.png index ad20f76df3..2d67258f5c 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/5ec4a0cb1f.png and b/collects/teachpack/2htdp/scribblings/img/5ec4a0cb1f.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/69aaaa680d.png b/collects/teachpack/2htdp/scribblings/img/69aaaa680d.png index a61711fd62..2bbf621e91 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/69aaaa680d.png and b/collects/teachpack/2htdp/scribblings/img/69aaaa680d.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/6a5a617f28.png b/collects/teachpack/2htdp/scribblings/img/6a5a617f28.png index 3023e68f76..4bb9e69275 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/6a5a617f28.png and b/collects/teachpack/2htdp/scribblings/img/6a5a617f28.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/6c262f1d24.png b/collects/teachpack/2htdp/scribblings/img/6c262f1d24.png index 3e0b8e3ec2..9c807aa52e 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/6c262f1d24.png and b/collects/teachpack/2htdp/scribblings/img/6c262f1d24.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/6efa12ea15.png b/collects/teachpack/2htdp/scribblings/img/6efa12ea15.png index 3d53897ff0..f8f50625d5 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/6efa12ea15.png and b/collects/teachpack/2htdp/scribblings/img/6efa12ea15.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/72aef3dc67.png b/collects/teachpack/2htdp/scribblings/img/72aef3dc67.png index 980f520e83..f23e71fde1 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/72aef3dc67.png and b/collects/teachpack/2htdp/scribblings/img/72aef3dc67.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/7bbcc7cbaa.png b/collects/teachpack/2htdp/scribblings/img/7bbcc7cbaa.png index e6ad7d2fb0..c4531561ed 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/7bbcc7cbaa.png and b/collects/teachpack/2htdp/scribblings/img/7bbcc7cbaa.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/89a0d469a7.png b/collects/teachpack/2htdp/scribblings/img/89a0d469a7.png index 09f2565b2d..6d8a7de7f8 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/89a0d469a7.png and b/collects/teachpack/2htdp/scribblings/img/89a0d469a7.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/89b3a9e462.png b/collects/teachpack/2htdp/scribblings/img/89b3a9e462.png index 8ac79e505c..bfef7a7524 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/89b3a9e462.png and b/collects/teachpack/2htdp/scribblings/img/89b3a9e462.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/8cb34e62d4.png b/collects/teachpack/2htdp/scribblings/img/8cb34e62d4.png index dc72425512..b7991ba733 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/8cb34e62d4.png and b/collects/teachpack/2htdp/scribblings/img/8cb34e62d4.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/8e1ebaaf82.png b/collects/teachpack/2htdp/scribblings/img/8e1ebaaf82.png index 1958afe988..a121e74837 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/8e1ebaaf82.png and b/collects/teachpack/2htdp/scribblings/img/8e1ebaaf82.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/8e7c1870c7.png b/collects/teachpack/2htdp/scribblings/img/8e7c1870c7.png index f7cfd7faf5..16f3c9ea26 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/8e7c1870c7.png and b/collects/teachpack/2htdp/scribblings/img/8e7c1870c7.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/957fe78565.png b/collects/teachpack/2htdp/scribblings/img/957fe78565.png index ada81569bf..65aa7da8d8 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/957fe78565.png and b/collects/teachpack/2htdp/scribblings/img/957fe78565.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/969a9aa483.png b/collects/teachpack/2htdp/scribblings/img/969a9aa483.png index 2817006b15..91ed7a9037 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/969a9aa483.png and b/collects/teachpack/2htdp/scribblings/img/969a9aa483.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/9858b8d5d.png b/collects/teachpack/2htdp/scribblings/img/9858b8d5d.png index 7f5ee10885..3fda459e1a 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/9858b8d5d.png and b/collects/teachpack/2htdp/scribblings/img/9858b8d5d.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/aac8b78b6e.png b/collects/teachpack/2htdp/scribblings/img/aac8b78b6e.png index f8c1b258af..0a15fd5fb5 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/aac8b78b6e.png and b/collects/teachpack/2htdp/scribblings/img/aac8b78b6e.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/ab1841ea36.png b/collects/teachpack/2htdp/scribblings/img/ab1841ea36.png index 9eca803a59..4aab00dbf3 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/ab1841ea36.png and b/collects/teachpack/2htdp/scribblings/img/ab1841ea36.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/aeddf66d5d.png b/collects/teachpack/2htdp/scribblings/img/aeddf66d5d.png index dfa4c9bb88..0755ac22fc 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/aeddf66d5d.png and b/collects/teachpack/2htdp/scribblings/img/aeddf66d5d.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/b32ce6fcc5.png b/collects/teachpack/2htdp/scribblings/img/b32ce6fcc5.png index 006ee64d24..b0fb28f34f 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/b32ce6fcc5.png and b/collects/teachpack/2htdp/scribblings/img/b32ce6fcc5.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/cf131e14ad.png b/collects/teachpack/2htdp/scribblings/img/cf131e14ad.png index ae707dd226..0778b97421 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/cf131e14ad.png and b/collects/teachpack/2htdp/scribblings/img/cf131e14ad.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/d417a51b4.png b/collects/teachpack/2htdp/scribblings/img/d417a51b4.png index cce3f019b0..6bc68e9390 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/d417a51b4.png and b/collects/teachpack/2htdp/scribblings/img/d417a51b4.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/d47072011e.png b/collects/teachpack/2htdp/scribblings/img/d47072011e.png index 5e715010af..a25d217a3e 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/d47072011e.png and b/collects/teachpack/2htdp/scribblings/img/d47072011e.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/d629961aee.png b/collects/teachpack/2htdp/scribblings/img/d629961aee.png index beb06b3c45..1b5727c941 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/d629961aee.png and b/collects/teachpack/2htdp/scribblings/img/d629961aee.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/d92d6a49f1.png b/collects/teachpack/2htdp/scribblings/img/d92d6a49f1.png index 178a528a7b..879569394e 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/d92d6a49f1.png and b/collects/teachpack/2htdp/scribblings/img/d92d6a49f1.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/eb99639e31.png b/collects/teachpack/2htdp/scribblings/img/eb99639e31.png index 23350d9777..70a9869420 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/eb99639e31.png and b/collects/teachpack/2htdp/scribblings/img/eb99639e31.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/fa1a9f17b6.png b/collects/teachpack/2htdp/scribblings/img/fa1a9f17b6.png index 3d53897ff0..f8f50625d5 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/fa1a9f17b6.png and b/collects/teachpack/2htdp/scribblings/img/fa1a9f17b6.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/fdaad0760b.png b/collects/teachpack/2htdp/scribblings/img/fdaad0760b.png index 5595a95a69..b4d7ceb719 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/fdaad0760b.png and b/collects/teachpack/2htdp/scribblings/img/fdaad0760b.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/ff11314e4e.png b/collects/teachpack/2htdp/scribblings/img/ff11314e4e.png index 243077914a..db0279ff4c 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/ff11314e4e.png and b/collects/teachpack/2htdp/scribblings/img/ff11314e4e.png differ diff --git a/collects/teachpack/2htdp/scribblings/img/ff2fcb7b87.png b/collects/teachpack/2htdp/scribblings/img/ff2fcb7b87.png index 9448fa6c24..69a7750b45 100644 Binary files a/collects/teachpack/2htdp/scribblings/img/ff2fcb7b87.png and b/collects/teachpack/2htdp/scribblings/img/ff2fcb7b87.png differ diff --git a/collects/teachpack/2htdp/scribblings/port.scrbl b/collects/teachpack/2htdp/scribblings/port.scrbl index b000d2c440..2942665eb0 100644 --- a/collects/teachpack/2htdp/scribblings/port.scrbl +++ b/collects/teachpack/2htdp/scribblings/port.scrbl @@ -4,6 +4,7 @@ "port.ss" scribble/manual (for-label scheme + (only-in 2htdp/universe on-tick on-draw) (prefix-in htdp: teachpack/htdp/world) (prefix-in htdp: htdp/image) (prefix-in 2htdp: teachpack/2htdp/universe) @@ -143,8 +144,10 @@ For the image constant we switch from symbols to strings: ;; Scene (define UFO (htdp:overlay - (htdp:circle 10 'solid 'red) - (htdp:rectangle 40 4 'solid 'red))) + (htdp:circle + 10 'solid 'red) + (htdp:rectangle + 40 4 'solid 'red))) )) @; --------------------------------- @(begin @@ -153,8 +156,10 @@ For the image constant we switch from symbols to strings: ;; Scene (define UFO (htdp:overlay - (htdp:circle 10 "solid" "red") - (htdp:rectangle 40 4 "solid" "red"))) + (htdp:circle + 10 "solid" "red") + (htdp:rectangle + 40 4 "solid" "red"))) )) ] Strictly speaking, this isn't necessary, but we intend to replace symbols @@ -180,39 +185,74 @@ The most important change concerns the lines that launch the world program: as there are lines in the old program. As you can see, the @scheme[big-bang] expression from the universe teachpack no longer requires the specification of the size of the scene or the rate at which - the clock ticks (though it is possible to supply these dimensions if the - defaults don't work). Furthermore, the names of the clauses are similar to + the clock ticks (though it is possible to supply the clock rate if the default + is not satisfactory). + Furthermore, the names of the clauses are similar to the old names but shorter. -key events and mouse events are string: use key=? and mouse=? -stuff from Todd: +The other big change concerns key event handling and mouse event + handling. The respective handlers no longer accept symbols and chars but + strings only. Here is the first key event handler from the documentation + of the world teachpack: -I'm not actually worried about me--I try to stay up to date, and I -teach three intro classes, so enough of my time is devoted to the HtDP -languages that I can stay on top of things. I'm worried about people -like Renee Ciezki in Arizona who pushes other teachers in her county -to use HtDP only to discover that the lessons she's given them to use -don't quite work anymore. At least she emails and asks what's going -on--I'm afraid other people just throw up their hands in frustration. +@port[ +@schemeblock[ + (define (change w a-key-event) + (cond + [(key=? a-key-event 'left) + (world-go w -DELTA)] + [(key=? a-key-event 'right) + (world-go w +DELTA)] + [(char? a-key-event) + w] + [(key=? a-key-event 'up) + (world-go w -DELTA)] + [(key=? a-key-event 'down) + (world-go w +DELTA)] + [else + w]))] +@; --------------------------------- +@schemeblock[ + (define (change w a-key-event) + (cond + [(key=? a-key-event "left") + (world-go w -DELTA)] + [(key=? a-key-event "right") + (world-go w +DELTA)] + [(= (string-length a-key-event) 1) + w] + [(key=? a-key-event "up") + (world-go w -DELTA)] + [(key=? a-key-event "down") + (world-go w +DELTA)] + [else + w])) +]] + Note how the @scheme[char?] clause changed. Since all chars are now + represented as strings containing one ``letter'', the program on the right + just checks the length of the string. Otherwise, we simply change all + symbols into strings. -And it's not just that one change to go from world to universe--key -events became strings instead of symbols, for example, and there are a -number of other small changes. Having a checklist that explains how to -get from X to Y would make the transition less complicated. - -Also, being unable to show previous student projects as examples is a -major downer. It's incredibly motivational to current students to see -what previous students have done. Porting five or six old projects to -the new version can eat up a couple of hours if you have to run them -and just correct errors. That's not horrible unless you don't have a -couple of hours to do it. +If you ever recorded your programs' work via an animated gif, you can still + do so. Instead of adding a fifth argument to @scheme[big-bang], however, + you will need to add a clause of the shape @scheme[(record? x)]. +Finally, the universe teachpack implements a richer functionality than the + world teachpack. @; ----------------------------------------------------------------------------- @section{Porting Image Programs} -using the new image library in isolation: +The universe library also comes with a new image library, @schememodname[2htdp/image]. +Using the old image +library still works fine with @schememodname[2htdp/universe], but the +new image library provides a number of improvements, including faster +image comparison (especially useful in @scheme[check-expect] expressions), +rotating images, scaling images, curves, a number of new polygon shapes, +and more control over line drawing. + +To use the new image library in isloation: @port[ @(begin @@ -228,7 +268,7 @@ using the new image library in isolation: )) ] -using the new image library with the universe teachpack +and to use the new image library with the universe teachpack: @port[ @(begin @@ -244,18 +284,85 @@ using the new image library with the universe teachpack (require #,(schememodname 2htdp/image)) ))] +@bold{Overlay vs Underlay} -why switch(?): faster image comparison, added rotate, scale, and curves, plus a bunch of new polygon primitives +The @scheme[htdp:overlay] function places its first argument +under its second (and subsequent) arguments and so in +@schememodname[2htdp/image], we decided to call that +function @scheme[2htdp:underlay]. -@schemeblock[(htdp:rectangle 10 10 "outline" "black") - (2htdp:rectangle 10 10 "outline" "black")] +@port[(schemeblock + (htdp:overlay + (htdp:rectangle + 10 20 "solid" "red") + (htdp:rectangle + 20 10 "solid" "blue"))) + (schemeblock + (2htdp:underlay + (2htdp:rectangle + 10 20 "solid" "red") + (2htdp:rectangle + 20 10 "solid" "blue")))] -changes: +@bold{No more pinholes} -no pinholes (although they will reappear in a different form, eventually) +The concept of pinholes from @schememodname[htdp/image] +has no correspondance in @schememodname[2htdp/image] +(we do expect to bring back pinholes in @schememodname[2htdp/image] +eventually, but they will not be as pervasive as they are +in @scheme[htdp/image]). -overlay arguments reversed (added underlay) +Instead of +a special position in the image that overlay operations +are sensitive to, +@schememodname[2htdp/image] has a family of overlay operations, +that overlay images based on their centers or their edges. -line drawing is slightly different (outlines are the same) (ellipses?) +Since the default position of the pinhole is in the center +for most images and the default for overlaying and underlaying +images in @scheme[2htdp/image] is based on the center, +simple examples (like the one above) behave the same +in both libraries. -star function is different (bring back old star function?) +But, consider this expression that overlays two images on +their upper-left corners, written using both libraries. + +@port[@schemeblock[(htdp:overlay + (htdp:put-pinhole + (htdp:rectangle 10 20 "solid" "red") + 0 0) + (htdp:put-pinhole + (htdp:rectangle 20 10 "solid" "blue") + 0 0))] + @schemeblock[(2htdp:underlay/align + "left" + "top" + (2htdp:rectangle + 10 20 "solid" "red") + (2htdp:rectangle + 20 10 "solid" "blue"))]] + +In the @schememodname[2htdp/image] version, the programmer +uses @scheme[2htdp:underlay/align] to specify where +the images should be lined up, instead of using the pinhole. + +@bold{Outlines in different places} + +The outline style shapes are now shifted by one pixel for @schememodname[2htdp/image] +images as compared to @schememodname[htdp/image]. +This means that these two rectangles draw the same sets of pixels. + +@port[@schemeblock[(htdp:rectangle + 11 11 "outline" "black")] + @schemeblock[(2htdp:rectangle + 10 10 "outline" "black")]] + +See also @secref["nitty-gritty"]. + +@bold{Star changed} + +The @scheme[2htdp:star] function is a completely different +function from @scheme[htdp:star]. Both produce stars based, +on polygons, but @scheme[2htdp:star] always produces a five-pointed +star. See also @scheme[2htdp:star-polygon] for more general star +shapes. diff --git a/collects/teachpack/2htdp/scribblings/port.ss b/collects/teachpack/2htdp/scribblings/port.ss index ea741da500..d6da930454 100644 --- a/collects/teachpack/2htdp/scribblings/port.ss +++ b/collects/teachpack/2htdp/scribblings/port.ss @@ -2,8 +2,7 @@ (require scribble/core) -(define-syntax-rule - (port old new) +(define (port old new) (make-table (make-style 'boxed '()) (list diff --git a/collects/teachpack/2htdp/scribblings/universe.scrbl b/collects/teachpack/2htdp/scribblings/universe.scrbl index 1c410660a4..a5d0d4d615 100644 --- a/collects/teachpack/2htdp/scribblings/universe.scrbl +++ b/collects/teachpack/2htdp/scribblings/universe.scrbl @@ -430,11 +430,11 @@ All @tech{MouseEvent}s are represented via strings: @item{ -@defproc[(stop-with [w (unsyntax @tech{WorldState})]) (stop-with (unsyntax @tech{WorldState}))]{signals to -DrScheme that the current world program should shut down. That is, any +@defstruct[stop-with ([w (unsyntax @tech{WorldState})])]{signals to +DrScheme that the world program should shut down. That is, any handler may return @scheme[(stop-with w)] provided @scheme[w] is a @tech{WorldState}. If it does, the state of the world becomes @scheme[w] -but @scheme[big-bang] will close down all event handling.} +and @scheme[big-bang] will close down all event handling.} } diff --git a/collects/tests/drscheme/README.ss b/collects/tests/drscheme/README.ss index 6b7ff39f55..004199c8a5 100644 --- a/collects/tests/drscheme/README.ss +++ b/collects/tests/drscheme/README.ss @@ -8,11 +8,12 @@ load run-test.ss. It will return a function that accepts the names of tests. Those names must be listed here. If no arguments are passed to the function, all tests will be run. -|# stepper-test.ss #| + stepper-test.ss runs the stepper on the sample solutions and checks the results. - + (this test suite is not being maintained) + |# io.ss #| This tests the drscheme's io implementation. diff --git a/collects/tests/stxparse/stxclass.ss b/collects/tests/stxparse/stxclass.ss index d88d7fc9d5..7f93ec1260 100644 --- a/collects/tests/stxparse/stxclass.ss +++ b/collects/tests/stxparse/stxclass.ss @@ -182,13 +182,31 @@ (syntax-parse #'(+) #:literals ([plus +]) [(plus) (void)]) -(define-syntax-class (nat> n) - #:description (format "nat > ~s" n) +(define-syntax-class (Nat> n) + #:description (format "Nat > ~s" n) (pattern x:nat #:fail-unless (> (syntax-e #'x) n) #f)) (syntax-parse #'(1 2 3) [(a:nat b0:nat c0:nat) #:with b #'b0 - #:declare b (nat> (syntax-e #'a)) + #:declare b (Nat> (syntax-e #'a)) #:with c #'c0 - #:declare c (nat> (syntax-e #'b0)) + #:declare c (Nat> (syntax-e #'b0)) (void)]) + +(define-syntax-class (nat> bound) + #:opaque + #:description (format "natural number greater than ~s" bound) + (pattern n:nat + #:when (> (syntax-e #'n) bound))) + +(define-conventions nat-convs + [N (nat> 0)]) + +(syntax-parse #'(5 4) #:conventions (nat-convs) + [(N ...) (void)]) + +(let/ec escape + (with-handlers ([exn? (compose escape void)]) + (syntax-parse #'(4 -1) #:conventions (nat-convs) + [(N ...) (void)])) + (error 'test-conv1 "didn't work")) diff --git a/collects/web-server/scribblings/stateless-usage.scrbl b/collects/web-server/scribblings/stateless-usage.scrbl index 85df06777f..5f8f1d9e04 100644 --- a/collects/web-server/scribblings/stateless-usage.scrbl +++ b/collects/web-server/scribblings/stateless-usage.scrbl @@ -51,7 +51,9 @@ because parameterizations are not serializable. Fourth, and related, this process only runs on your code, not on the code you @scheme[require]. Thus, your continuations---to be serializable---must not -be in the context of another module. For example, the following will not work: +be in the context of another module. For example, the following will fail with an @as-index{"unsafe context"} +exception: + @schemeblock[ (define requests (map (lambda (rg) (send/suspend/url rg))