import Haste hiding (eval) import Haste.DOM import Haste.Events import Haste.Graphics.Canvas import Pages --import Expr canWidth, canHeight :: Num a => a canWidth = 300 canHeight = 300 readAndDraw :: Elem -> Canvas -> IO () readAndDraw = undefined main = do -- Elements canvas <- mkCanvas canWidth canHeight -- The drawing area fx <- mkHTML "f(x)=" -- The text "f(x)=" input <- mkInput 20 "x" -- The formula input draw <- mkButton "Draw graph" -- The draw button -- The markup "..." means that the text inside should be rendered -- in italics. -- Layout formula <- mkDiv row formula [fx,input] column documentBody [canvas,formula,draw] -- Styling setStyle documentBody "backgroundColor" "lightblue" setStyle documentBody "textAlign" "center" setStyle input "fontSize" "14pt" focus input select input -- Interaction Just can <- getCanvas canvas onEvent draw Click $ \ _ -> readAndDraw input can onEvent input Change $ \ _ -> readAndDraw input can