diff --git a/ease/main.scrbl b/ease/main.scrbl index cb949eb..e23f198 100644 --- a/ease/main.scrbl +++ b/ease/main.scrbl @@ -14,3 +14,4 @@ from one state into another gradually. source code: @url["https://github.com/jackfirth/racket-ease"] @scribble-include/no-subsection["private/base.scrbl"] +@scribble-include/no-subsection["private/invert.scrbl"] diff --git a/ease/private/base.rkt b/ease/private/base.rkt index eaa8dd2..0aef445 100644 --- a/ease/private/base.rkt +++ b/ease/private/base.rkt @@ -25,7 +25,7 @@ module+ test (define (range-n start stop num-steps) (define step (/ (- stop start) num-steps)) - (range start stop step)) + (range start (+ stop step) step)) (define (ease-real easing start stop num-steps) @@ -41,4 +41,4 @@ module+ test module+ test (check-equal? (ease-real linear-ease 0 5 5) - '(0 1 2 3 4)) + '(0 1 2 3 4 5)) diff --git a/ease/private/base.scrbl b/ease/private/base.scrbl index 75cfaf1..22443ca 100644 --- a/ease/private/base.scrbl +++ b/ease/private/base.scrbl @@ -9,8 +9,8 @@ [num-steps real?]) (listof real?)]{ Returns a list of intermediate values between @racket[start] and @racket[stop]. - The number of values is equal to @racket[num-steps], and the a difference between - successive values is determined by @racket[easing]. + The number of values is equal to @racket[num-steps] plus one, and the difference + between successive values is determined by @racket[easing]. @ease-examples[ (ease-real linear-ease 0 100 5) ]} diff --git a/ease/private/invert.rkt b/ease/private/invert.rkt new file mode 100644 index 0000000..37f857e --- /dev/null +++ b/ease/private/invert.rkt @@ -0,0 +1,36 @@ +#lang sweet-exp racket/base + +require racket/contract/base + +provide + contract-out + ease-invert (case-> (-> proper-ease/c proper-ease/c) + (-> ease/c ease/c)) + ease-reverse (case-> (-> proper-ease/c proper-ease/c) + (-> ease/c ease/c)) + +require "base.rkt" + +module+ test + require fancy-app + rackunit + + +module+ test + (define (quadratic-ease-in x) (* x x)) + + +(define ((ease-invert easing) x) + (- 1 (easing (- 1 x)))) + +module+ test + (check-equal? (ease-real (ease-invert quadratic-ease-in) 0 100 5) + (reverse (map (- 100 _) (ease-real quadratic-ease-in 0 100 5)))) + + +(define ((ease-reverse easing) x) + (easing (- 1 x))) + +module+ test + (check-equal? (ease-real (ease-reverse quadratic-ease-in) 0 100 5) + (reverse (ease-real quadratic-ease-in 0 100 5))) diff --git a/ease/private/invert.scrbl b/ease/private/invert.scrbl new file mode 100644 index 0000000..920d7c8 --- /dev/null +++ b/ease/private/invert.scrbl @@ -0,0 +1,21 @@ +#lang scribble/manual + +@(require "util/doc.rkt") + + +@defproc[(ease-invert [easing ease/c]) ease/c]{ + Returns an easing that is like @racket[easing], but + with proportional changes inverted from @racket[easing]. + @ease-examples[ + (define (quadratic-ease x) (* x x)) + (ease-real quadratic-ease 0 100 5) + (ease-real (ease-invert quadratic-ease) 0 100 5) +]} + +@defproc[(ease-reverse [easing ease/c]) ease/c]{ + Returns an easing that is like @racket[easing], but + with it's steps reversed. + @ease-examples[ + (ease-real linear-ease 0 100 5) + (ease-real (ease-reverse linear-ease) 0 100 5) +]} diff --git a/ease/private/main.rkt b/ease/private/main.rkt index 7ae4ba3..f2f909d 100644 --- a/ease/private/main.rkt +++ b/ease/private/main.rkt @@ -3,8 +3,10 @@ require "base.rkt" + "invert.rkt" provide all-from-out "base.rkt" + "invert.rkt" diff --git a/info.rkt b/info.rkt index f012b69..42d6d23 100644 --- a/info.rkt +++ b/info.rkt @@ -18,3 +18,11 @@ "racket-doc" "scribble-lib" "doc-coverage")) + + +(define test-omit-paths + '("info.rkt" + "ease/info.rkt" + "ease/main.scrbl" + "private/base.scrbl" + "private/invert.scrbl"))