Skip to content

Commit

Permalink
Add ease invert and reverse and fix cover
Browse files Browse the repository at this point in the history
  • Loading branch information
jackfirth committed Aug 24, 2015
1 parent c3b43bd commit 5de84ec
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 4 deletions.
1 change: 1 addition & 0 deletions ease/main.scrbl
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
4 changes: 2 additions & 2 deletions ease/private/base.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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))
4 changes: 2 additions & 2 deletions ease/private/base.scrbl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
]}
Expand Down
36 changes: 36 additions & 0 deletions ease/private/invert.rkt
Original file line number Diff line number Diff line change
@@ -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)))
21 changes: 21 additions & 0 deletions ease/private/invert.scrbl
Original file line number Diff line number Diff line change
@@ -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)
]}
2 changes: 2 additions & 0 deletions ease/private/main.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

require
"base.rkt"
"invert.rkt"


provide
all-from-out
"base.rkt"
"invert.rkt"
8 changes: 8 additions & 0 deletions info.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -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"))

0 comments on commit 5de84ec

Please sign in to comment.