Safe Haskell | None |
---|
- blankCanvas :: Int -> (Context -> IO ()) -> IO ()
- data Context
- send :: Context -> Canvas a -> IO a
- events :: Context -> EventName -> IO EventQueue
- data Canvas
- arc :: (Float, Float, Float, Float, Float, Bool) -> Canvas ()
- beginPath :: () -> Canvas ()
- bezierCurveTo :: (Float, Float, Float, Float, Float, Float) -> Canvas ()
- clearRect :: (Float, Float, Float, Float) -> Canvas ()
- closePath :: () -> Canvas ()
- fill :: () -> Canvas ()
- fillRect :: (Float, Float, Float, Float) -> Canvas ()
- fillStyle :: String -> Canvas ()
- fillText :: (String, Float, Float) -> Canvas ()
- font :: String -> Canvas ()
- globalAlpha :: Float -> Canvas ()
- lineCap :: String -> Canvas ()
- lineJoin :: String -> Canvas ()
- lineTo :: (Float, Float) -> Canvas ()
- lineWidth :: Float -> Canvas ()
- miterLimit :: Float -> Canvas ()
- moveTo :: (Float, Float) -> Canvas ()
- restore :: () -> Canvas ()
- rotate :: Float -> Canvas ()
- scale :: (Float, Float) -> Canvas ()
- save :: () -> Canvas ()
- stroke :: () -> Canvas ()
- strokeRect :: (Float, Float, Float, Float) -> Canvas ()
- strokeText :: (String, Float, Float) -> Canvas ()
- strokeStyle :: String -> Canvas ()
- textAlign :: String -> Canvas ()
- textBaseline :: String -> Canvas ()
- transform :: (Float, Float, Float, Float, Float, Float) -> Canvas ()
- translate :: (Float, Float) -> Canvas ()
- readEvent :: EventName -> Canvas Event
- tryReadEvent :: EventName -> Canvas (Maybe Event)
- size :: Canvas (Float, Float)
- data Event = Event {}
- data EventName
- type EventQueue = TChan Event
- readEventQueue :: EventQueue -> IO Event
- tryReadEventQueue :: EventQueue -> IO (Maybe Event)
Starting blank-canvas
blankCanvas :: Int -> (Context -> IO ()) -> IO ()Source
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()
Graphics Context
send :: Context -> Canvas a -> IO aSource
Sends a set of Canvas commands to the canvas. Attempts to common up as many commands as possible.
events :: Context -> EventName -> IO EventQueueSource
events
gets the raw event queue for a specific event type.
Drawing pictures using the Canvas DSL
globalAlpha :: Float -> Canvas ()Source
miterLimit :: Float -> Canvas ()Source
strokeStyle :: String -> Canvas ()Source
textBaseline :: String -> Canvas ()Source
readEvent :: EventName -> Canvas EventSource
read a specific event; wait for it if the event is not in queue.
tryReadEvent :: EventName -> Canvas (Maybe Event)Source
read a specific event; or return Nothing if the event is not in queue.
Events
Basic Event from Browser, the code is event-type specific.
EventName
mirrors event names from jquery, where 'map toLower (show name)' gives
the jquery event name.
type EventQueue = TChan EventSource
EventQueue is a STM channel (TChan
) of Event
s.
Intentionally, EventQueue
is not abstract.
tryReadEventQueue :: EventQueue -> IO (Maybe Event)Source