blank-canvas
HTML5 Canvas Graphics Library
https://github.com/ku-fpg/blank-canvas/wiki
| LTS Haskell 24.33: | 0.7.5@rev:1 |
| Stackage Nightly 2026-03-13: | 0.7.5@rev:1 |
| Latest on Hackage: | 0.7.5@rev:1 |
blank-canvas-0.7.5@sha256:d72bacf7dfa9f88994078553c3b88f50b9ca9a3fe751744244d39af58e9b3b0e,5391Module documentation for 0.7.5
- Graphics
- Graphics.Blank
- Graphics.Blank.Cursor
- Graphics.Blank.Font
- Graphics.Blank.GHCi
- Graphics.Blank.Style
- Graphics.Blank
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

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.5 |
| 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.7.5 [2026.01.10]
- Allow building with GHC 9.14.
- Allow building with
scotty-0.30.*. - Remove unused
fail,semigroups, andtransformersdependencies. - Fix broken cursor image links in Haddocks.
0.7.4 [2023.10.05]
- Support building with
scotty-0.20.
0.7.3
- Allow building with GHC 9.0.
0.7.2
- Render Unicode codepoints beyond
0xFFFFproperly.
0.7.1
- Remove the
wiki-suitetest suite fromblank-canvas.cabal, as it was never intended to work as a traditional test suite. The functionality ofwiki-suitehas moved to a subdirectory of the upstreamblank-canvasrepository.
0.7
- Strengthen the
Monadconstraint onreadColourNametoMonadFail.
0.6.3
- Use
base-compat-batteries.
0.6.2
Additions
- Add
Semigroupinstance forCanvas
0.6.1
- Fix building with
aeson-1.2.2.0.
0.6
API changes
- The
(#)function had its type generalized froma -> (a -> Canvas b) -> Canvas btoa -> (a -> b) -> b. This allows it to be used with font length units. - Added more type synonyms (
Interval,Degrees,Radians, etc.) to more clearly indicate what functions expect constrained values. showbJS(formerlyshowJS) andjsStylenow return a textBuilderinstead of aString. This change was introduced as part of a largerblank-canvasrefactoring to increase performance. See theData.Text.Lazy.Buildermodule from thetextpackage for more details on how to useBuilders.
API additions
- A new ADT for
Fonts has been added inGraphics.Blank.Fontthat can be used in place ofText. For example,"30pt Calibri"is equivalent to(defFont "Calibri") { fontSize = 30 # pt }. - A generalized
fontfunction of typeCanvasFont canvasFont => canvasFont -> Canvas ()was added toGraphics.Blank.Fontthat can accept aTextorFontargument. Thefontfunction inGraphics.Blankremains of typeText -> Canvas (). - Added a
cursorfunction to change the browser cursor. Also added theGraphics.Blank.Cursormodule containing a generalizedcursorfunction that uses aCursorADT instead ofText. - Added
Bounded,Enum,Eq,Ix,Ord, andShowinstances for more data types - Added support for more MIME types via the
mime-typeslibrary
Additions
- Allowed building with
base-4.8.0.0
Other
- Require
scotty>= 0.10 andkansas-comet>= 0.4
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