BSD-3-Clause licensed by Andy Gill and Ryan Scott
Maintained by [email protected]
This version can be pinned in stack with:blank-canvas-0.5@sha256:a9d9c32056144a2e5b84e96dfb3a5334aa89dc616c759e523c538a6b950d5084,3995

Module documentation for 0.5

Background

blank-canvas is a Haskell binding to the complete HTML5 Canvas API. blank-canvas allows Haskell users to write, in Haskell, interactive images onto their web browsers. blank-canvas gives the user a single full-window canvas, and provides many well-documented functions for rendering images.

First Example

{-# LANGUAGE OverloadedStrings #-}
module Main where

import Graphics.Blank                     -- import the blank canvas

main = blankCanvas 3000 $ \ context -> do -- start blank canvas on port 3000
        send context $ do                 -- send commands to this specific context
                moveTo(50,50)
                lineTo(200,100)
                lineWidth 10
                strokeStyle "red"
                stroke()                  -- this draws the ink into the canvas

Running this program, and going to http://localhost:3000/ gives

images/Red_Line.png

For more details about this example, see Red Line.

Documentation

Link Notes
Examples Various complete examples of using blank-canvas
Installation How to install blank-canvas
Hackage Current release is 0.4.0
API Discussion of API, compared with the original JavaScript API
Canvas Examples Transliterated from http://www.html5canvastutorials.com/ into Haskell and blank-canvas, with kind permission of Eric Rowell, author of the JavaScript HTML5 Canvas Tutorial.
FAQ F.A.Q.

Other Links

Credits

Thank you to Eric Rowell, for allowing blank-canvas to base our Canvas examples on his JavaScript Canvas examples.

The “Haskell” picture is taken by Mandy Lackey, from link <http://www.flickr.com/photos/77649176@N00/3776224595/.> This picture allows sharing, under the creative commons license.

Changes

0.5

API changes

  • Using Double rather than Float
  • Generalized saveRestore to be polymorphic

API additions

  • Added sync for forcing synchronization between the server and client
  • Added argument specific variants of drawImage and putImageData.
  • Added ADTs for RepeatDirection, Alignment, Baseline, LineEnds, Corner (previous used Text)
  • Use of the colour(sic) package (Text is still allowed)

Bug fixes:

  • Fixed unicode escapes in strings

Additions:

  • Allow Images to access client-side filesystem