blank-canvas: HTML5 Canvas Graphics Library

[ bsd3, graphics, library ] [ Propose Tags ] [ Report a vulnerability ]

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.

{-# 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

For more details, read the blank-canvas wiki.


[Skip to Readme]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.2.0, 0.2.0.1, 0.2.2, 0.2.3, 0.2.3.1, 0.2.3.2, 0.3.1, 0.4.0, 0.5, 0.6, 0.6.1, 0.6.2, 0.6.3, 0.7, 0.7.1, 0.7.2, 0.7.3, 0.7.4
Change log Changelog.md
Dependencies aeson (>=1.4.4 && <2.3), base (>=4.9 && <4.21), base-compat-batteries (>=0.10 && <0.15), base64-bytestring (>=1.0 && <1.3), bytestring (>=0.10 && <0.13), colour (>=2.2 && <2.4), containers (>=0.5 && <0.8), data-default-class (>=0.0.1 && <0.3), fail (>=4.9 && <4.10), http-types (>=0.8 && <0.13), kansas-comet (>=0.4 && <0.5), mime-types (>=0.1.0.3 && <0.2), scotty (>=0.10 && <0.23), semigroups (>=0.18 && <1), stm (>=2.2 && <2.6), text (>=1.1 && <2.2), text-show (>=2 && <4), transformers (>=0.3 && <0.7), vector (>=0.10 && <0.14), wai (>=3 && <4), wai-extra (>=3.0.1 && <3.2), warp (>=3 && <4) [details]
Tested with ghc ==8.0.2, ghc ==8.2.2, ghc ==8.4.4, ghc ==8.6.5, ghc ==8.8.4, ghc ==8.10.7, ghc ==9.0.2, ghc ==9.2.7, ghc ==9.4.4, ghc ==9.6.1
License BSD-3-Clause
Copyright Copyright (c) 2014 The University of Kansas
Author Andy Gill and Ryan Scott
Maintainer andygill@ku.edu
Revised Revision 5 made by ryanglscott at 2024-10-26T20:53:30Z
Category Graphics
Home page https://github.com/ku-fpg/blank-canvas/wiki
Bug tracker https://github.com/ku-fpg/blank-canvas/issues
Source repo head: git clone https://github.com/ku-fpg/blank-canvas.git
Uploaded by ryanglscott at 2023-10-05T13:14:14Z
Distributions LTSHaskell:0.7.4, NixOS:0.7.4, Stackage:0.7.4
Reverse Dependencies 5 direct, 26 indirect [details]
Downloads 20748 total (54 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2023-10-05 [all 1 reports]

Readme for blank-canvas-0.7.4

[back to package description]

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.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.

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.