-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | HTML5 Canvas Graphics Library - forked Blank Canvas -- -- A Haskell port of the HTML5 Canvas API. blank-canvas works by -- providing a web service that displays the users' Haskell commands -- inside a browser. @package null-canvas @version 0.2.7 module Graphics.Blank -- | blankCanvas is the main entry point into blank-canvas. A typical -- invocation would be -- --
-- module Main where -- -- import Graphics.Blank -- -- main = blankCanvas 3000 $ \ context -> do -- send context $ do -- moveTo(50,50) -- lineTo(200,100) -- lineWidth 10 -- strokeStyle "red" -- stroke() ---- -- launch single-canvas app on specified port blankCanvas :: Int -> (Context -> IO ()) -> IO () -- | launch multiple canvas apps, each with a prefix, like -- `/myprefix/foo/bar` blankCanvasMany :: Int -> [(String, Context -> IO ())] -> IO () -- | as blankCanvasMany but takes customization parameters dataDir and -- performLogging blankCanvasManyParams :: Int -> [(String, Context -> IO ())] -> FilePath -> Bool -> IO () -- | as blankCanvas but takes customization parameters dataDir and -- performLogging blankCanvasParams :: Int -> (Context -> IO ()) -> FilePath -> Bool -> String -> IO () -- | parametrised version of blankCanvas, also returns ScottyM application -- instead of running a server. use scotty to run it. blankCanvasParamsScotty :: (Context -> IO ()) -> FilePath -> Bool -> String -> IO (ScottyM ()) -- | Context is our abstact handle into a specific 2d-context inside -- a browser. data Context -- | Sends a set of Canvas commands to the canvas. Attempts to common up as -- many commands as possible. send :: Context -> Canvas a -> IO a -- | events gets the raw event queue for a specific event type. events :: Context -> EventName -> IO EventQueue data Canvas :: * -> * -- | see http://www.w3schools.com/tags/canvas_arc.asp arc :: (Float, Float, Float, Float, Float, Bool) -> Canvas () -- | see http://www.w3schools.com/tags/canvas_beginpath.asp beginPath :: Canvas () -- | see http://www.w3schools.com/tags/canvas_beziercurveto.asp bezierCurveTo :: (Float, Float, Float, Float, Float, Float) -> Canvas () -- | see http://www.w3schools.com/tags/canvas_clearrect.asp clearRect :: (Float, Float, Float, Float) -> Canvas () -- | see http://www.w3schools.com/tags/canvas_closepath.asp closePath :: Canvas () -- | sends command (JS) unchanged. useful for extending this library with -- functionality it doesn't currently have. example: -- --
-- custom $ unlines $ [ -- "var grd=c.createRadialGradient(0,0,3,20,20,10); " -- ,"grd.addColorStop(0,\"white\");" -- ,"grd.addColorStop(1,\"red\");" -- ,"c.fillStyle=grd;"] --custom :: String -> Canvas () -- | see http://www.w3schools.com/tags/canvas_fill.asp fill :: Canvas () -- | see http://www.w3schools.com/tags/canvas_fillrect.asp fillRect :: (Float, Float, Float, Float) -> Canvas () -- | see http://www.w3schools.com/tags/canvas_fillstyle.asp fillStyle :: String -> Canvas () -- | see http://www.w3schools.com/tags/canvas_filltext.asp fillText :: (String, Float, Float) -> Canvas () -- | see http://www.w3schools.com/tags/canvas_font.asp font :: String -> Canvas () -- | see http://www.w3schools.com/tags/canvas_globalalpha.asp globalAlpha :: Float -> Canvas () -- | see http://www.w3schools.com/tags/canvas_linecap.asp lineCap :: String -> Canvas () -- | see http://www.w3schools.com/tags/canvas_linejoin.asp lineJoin :: String -> Canvas () -- | see http://www.w3schools.com/tags/canvas_lineto.asp lineTo :: (Float, Float) -> Canvas () -- | see http://www.w3schools.com/tags/canvas_linewidth.asp lineWidth :: Float -> Canvas () -- | see http://www.w3schools.com/tags/canvas_miterlimit.asp miterLimit :: Float -> Canvas () -- | see http://www.w3schools.com/tags/canvas_moveto.asp moveTo :: (Float, Float) -> Canvas () -- | see bottom of http://www.w3schools.com/tags/ref_canvas.asp restore :: Canvas () -- | see http://www.w3schools.com/tags/canvas_rotate.asp rotate :: Float -> Canvas () -- | http://www.w3schools.com/tags/canvas_scale.asp scale :: (Float, Float) -> Canvas () -- | see bottom of http://www.w3schools.com/tags/ref_canvas.asp save :: Canvas () -- | see http://www.w3schools.com/tags/canvas_stroke.asp stroke :: Canvas () -- | see http://www.w3schools.com/tags/canvas_strokerect.asp strokeRect :: (Float, Float, Float, Float) -> Canvas () -- | see http://www.w3schools.com/tags/canvas_stroketext.asp strokeText :: (String, Float, Float) -> Canvas () -- | see http://www.w3schools.com/tags/canvas_strokestyle.asp strokeStyle :: String -> Canvas () -- | see http://www.w3schools.com/tags/canvas_textalign.asp textAlign :: String -> Canvas () -- | see http://www.w3schools.com/tags/canvas_textbaseline.asp textBaseline :: String -> Canvas () -- | see http://www.w3schools.com/tags/canvas_transform.asp transform :: (Float, Float, Float, Float, Float, Float) -> Canvas () -- | see http://www.w3schools.com/tags/canvas_translate.asp translate :: (Float, Float) -> Canvas () -- | read a specific event; wait for it if the event is not in queue. readEvent :: EventName -> Canvas Event -- | read a specific event; or return Nothing if the event is not in queue. tryReadEvent :: EventName -> Canvas (Maybe Event) -- | size of the canvas size :: Canvas (Float, Float) -- | Basic Event from Browser, the code is event-type specific. data Event Event :: Int -> Maybe (Int, Int) -> Event jsCode :: Event -> Int jsMouse :: Event -> Maybe (Int, Int) -- | EventName mirrors event names from jquery, where 'map toLower -- (show name)' gives the jquery event name. data EventName KeyPress :: EventName KeyDown :: EventName KeyUp :: EventName MouseDown :: EventName MouseEnter :: EventName MouseMove :: EventName MouseOut :: EventName MouseOver :: EventName MouseUp :: EventName -- | EventQueue is a STM channel (TChan) of Events. -- Intentionally, EventQueue is not abstract. type EventQueue = TChan Event readEventQueue :: EventQueue -> IO Event tryReadEventQueue :: EventQueue -> IO (Maybe Event)