Last active
July 3, 2019 19:16
-
-
Save danidiaz/c58c817d4f37e951600b248fa6582b89 to your computer and use it in GitHub Desktop.
Codeworld-Reflex experiments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE BlockArguments #-} | |
import CodeWorld.Reflex | |
import Reflex | |
-- Move mouse to rotate squares. | |
-- Click to add squares. | |
positions :: [(Color,(Double,Double))] | |
positions = zip assortedColors [(0,0),(2,2),(-2,2),(-2,-2),(2,-2)] | |
main :: IO () | |
main = reflexOf \input -> do | |
clicks <- count (pointerPress input) | |
return do | |
currentClicks <- clicks | |
angle <- vectorDirection <$> pointerPosition input | |
let currentPositions = take (succ currentClicks) positions | |
makeRectangle (c,(x,y)) = | |
colored c | |
. translated x y | |
. rotated angle | |
$ solidRectangle 2 2 | |
constDyn (pictures (map makeRectangle currentPositions)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment