BSD-3-Clause licensed by Jeffrey Rosenbluth
Maintained by [email protected]
This version can be pinned in stack with:static-canvas-0.2.0.3@sha256:3ad170c6efbd26b981fe66f4c4a85e515c200c675e3f2c6603da7d64e84bc8f5,1768

Module documentation for 0.2.0.3

Used by 1 package in lts-22.6(full list with versions):

static-canvas Hackage

A simple DSL for writing HTML5 Canvas in haskell and converting it to Javascript. By static we mean non-interactive, so the parts of the Canvas API that need to query the browser for run time information like isPointInPath(x, y) are not included. This turns out to be a surprisingly small part of HTML5 Canvas.

Here is Hello static-canvas with fancy text.

Text

{-# LANGUAGE OverloadedStrings #-}

module Main where

import Graphics.Static
import Graphics.Static.ColorNames

text :: CanvasFree ()
text = do
  font "italic 60pt Calibri"
  lineWidth 6
  strokeStyle blue
  fillStyle goldenrod
  textBaseline TextBaselineMiddle
  strokeText "Hello" 150 100 
  fillText "Hello World!" 150 100

main :: IO ()
main = writeCanvasDoc "Text.html" 600 400 text

There are plenty of examples in Examples. Here is one more showing how to use pattern to fill a rectangle.

line

{-# LANGUAGE OverloadedStrings #-}

module Main where

import Graphics.Static

pattern :: CanvasFree ()
pattern = do
  img <- newImage "tile.png"
  onImageLoad img $ do
    ptn <- createPattern img Repeat
    rect 0 0 400 400
    fillStyle ptn
    fill

main :: IO ()
main = writeCanvasDoc "Pattern.html" 400 400 pattern