Skip to content

Instantly share code, notes, and snippets.

@danidiaz
Last active July 3, 2019 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danidiaz/c58c817d4f37e951600b248fa6582b89 to your computer and use it in GitHub Desktop.
Save danidiaz/c58c817d4f37e951600b248fa6582b89 to your computer and use it in GitHub Desktop.
Codeworld-Reflex experiments
{-# 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