Skip to content

Instantly share code, notes, and snippets.

@wavewave
Last active October 14, 2018 16:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wavewave/5648108 to your computer and use it in GitHub Desktop.
Save wavewave/5648108 to your computer and use it in GitHub Desktop.
ghcjs canvas example
<!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>
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