Skip to content

Commit

Permalink
make the interaction even more "play"ful
Browse files Browse the repository at this point in the history
  • Loading branch information
Dierk Koenig committed Aug 13, 2015
1 parent 5b27e7d commit f2ecb49
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions Stairs.fr
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,15 @@ connect ctx (nextHead,head,_,_) = withUI $ ctx.strokeLine head.x head.y nextHead
doodle :: GraphicsContext -> [IO ()]
doodle ctx = map (connect ctx) trails

--- Play any function _f_ that returns a list of IO actions
play f = paint $ sequence_ . f

--- Sample usage: paint the doodle at once.
fast = paint $ sequence_ . take 300 . doodle
fast = play $ take 300 . doodle

--- Sample usage: make every second action a sleep.
slow = paint $ sequence_ . intersperse (Thread.sleep 100) . take 300 . doodle
slow = play $ intersperse (Thread.sleep 100) . take 300 . doodle




4 changes: 2 additions & 2 deletions client/src/main/frege/org/frege/Application.fr
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ showUI mConsole stage = do
items.add "mapM println [1..100]"
items.add "fib = 1n : 1n : zipWith (+) fib (tail fib)"
items.add ":l https://raw.githubusercontent.com/Dierk/frepl-gui/master/Stairs.fr"
items.add "import Stairs;import org.frege.SketchBook;import Data.List"
items.add "paint $ sequence_ . take 300 . doodle"
items.add "import Stairs;import Data.List"
items.add "play $ take 300 . doodle"

sm <- historyLV.getSelectionModel
sip <- sm.selectedItemProperty
Expand Down

0 comments on commit f2ecb49

Please sign in to comment.