From 2faca724e3b0670d6577c49efe8feba433055bf6 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Wed, 18 Aug 2010 16:58:27 -0500 Subject: [PATCH] generalized the #:steps argument to play so different phases on an animation can take different amounts of time --- collects/scribblings/slideshow/play.scrbl | 14 ++++++++++++-- collects/slideshow/play.rkt | 7 ++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/collects/scribblings/slideshow/play.scrbl b/collects/scribblings/slideshow/play.scrbl index d997cae29a..5dd69eaf86 100644 --- a/collects/scribblings/slideshow/play.scrbl +++ b/collects/scribblings/slideshow/play.scrbl @@ -66,7 +66,9 @@ slide that would be registered with a timeout is instead skipped.} @defproc[(play-n [gen* (() (listof (real-in 0.0 1.0)) . ->* . pict?)] - [#:steps steps exact-positive-integer? 10] + [#:steps steps (or/c exact-positive-integer? + (improper-listof exact-positive-integer?)) + 10] [#:delay delay-secs real? 0.05] [#:skip-first? skip-first? any/c #f] [#:skip-last? skip-last? any/c #f] @@ -110,7 +112,15 @@ If @racket[skip-first?] is @racket[#t], then the very first slide of the sequence is skipped. Similarly, if @racket[skip-last?] is @racket[#t], then the last slide of the sequence is skipped. -The @racket[steps], @racket[delay-msecs], @racket[title], +The @racket[steps] argument controls how many steps happen in each +phase on the animation. If it is a number, then that number is used for +each phase. If it is a pair of two numbers, then the first number is used +for the first phase, and the second number is used for the rest of the +phases. Similarly, if it is @racket[(cons num_1 (cons num_2 num_3))], +@racket[num_1] and @racket[num_2] are used for the first two phases +and @racket[num_3] is used for the rest. + +The @racket[delay-msecs], @racket[title], @racket[name], and @racket[layout] arguments are passed on to @racket[play] for each of the @math{n} segments of animation.} diff --git a/collects/slideshow/play.rkt b/collects/slideshow/play.rkt index 659ac481ed..906881cc4a 100644 --- a/collects/slideshow/play.rkt +++ b/collects/slideshow/play.rkt @@ -72,7 +72,8 @@ (let ([n (procedure-arity mid)]) (let loop ([post (vector->list (make-vector n))] [pre null] - [skip? skip-first?]) + [skip? skip-first?] + [Ns N]) (if (null? post) (unless skip-last? (slide #:title (if (procedure? title) (apply title pre) title) @@ -89,12 +90,12 @@ (apply name (append pre (list n) (cdr post)))) name) #:layout layout - #:steps N + #:steps (if (pair? Ns) (car Ns) Ns) #:delay secs #:skip-first? skip? (lambda (n) (apply mid (append pre (list n) (cdr post))))) - (loop (cdr post) (cons 1.0 pre) #f)))))) + (loop (cdr post) (cons 1.0 pre) #f (if (pair? Ns) (cdr Ns) Ns))))))) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;