Last active
October 14, 2018 16:47
-
-
Save wavewave/5648108 to your computer and use it in GitHub Desktop.
ghcjs canvas example
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script language="javascript" src="lib.js"></script> | |
| <script language="javascript" src="rts.js"></script> | |
| <script language="javascript" src="lib1.js"></script> | |
| <script language="javascript" src="out.js"></script> | |
| </head> | |
| <body> | |
| <canvas id="mycanvas" width="600" height="400"></canvas> | |
| </body> | |
| <script language="javascript"> | |
| var c = document.getElementById("mycanvas"); | |
| window.ctxt = c.getContext("2d"); | |
| h$main(h$mainZCMainzimain); | |
| </script> | |
| </html> |
This file contains hidden or 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
| import Control.Concurrent | |
| import JavaScript.Canvas | |
| import System.Random | |
| main = do | |
| putStrLn "test" | |
| let go = do | |
| x1 <- randomIO :: IO Double | |
| y1 <- randomIO :: IO Double | |
| x2 <- randomIO :: IO Double | |
| y2 <- randomIO :: IO Double | |
| moveTo (500*x1) (500*y1) | |
| lineTo (500*x2) (500*y2) | |
| stroke | |
| threadDelay 200000 | |
| go | |
| go |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment