static-canvas (empty) → 0.1.0.0
raw patch · 9 files changed
+1588/−0 lines, 9 filesdep +basedep +double-conversiondep +freesetup-changed
Dependencies added: base, double-conversion, free, mtl, text
Files
- LICENSE +30/−0
- README.md +55/−0
- Setup.hs +2/−0
- src/Graphics/Static.hs +324/−0
- src/Graphics/Static/ColorNames.hs +608/−0
- src/Graphics/Static/Interpreter.hs +283/−0
- src/Graphics/Static/Javascript.hs +112/−0
- src/Graphics/Static/Types.hs +137/−0
- static-canvas.cabal +37/−0
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2015, Jeffrey Rosenbluth++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Jeffrey Rosenbluth nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,55 @@+# static-canvas+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.++++```haskell+{-# 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](https://github.com/jeffreyrosenbluth/static-canvas/tree/master/examples).+Here is one more showing how to use pattern to fill a rectangle.+++```haskell+{-# 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+```
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ src/Graphics/Static.hs view
@@ -0,0 +1,324 @@+{-# LANGUAGE OverloadedStrings #-}++-------------------------------------------------------------------------------+-- |+-- Module : Graphics.Static+-- Copyright : (c) 2015 Jeffrey Rosenbluth+-- License : BSD-style (see LICENSE)+-- Maintainer : jeffrey.rosenbluth@gmail.com+--+-- A simple DSL for creating HTML5 Canvas with haskell.+--+-- <<http://i.imgur.com/HGjSpJ6.png>>+--+-- > 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" 25 100 +-- > fillText "Hello static-canvas!" 25 100+-- > +-- > main :: IO ()+-- > main = writeCanvasDoc "example.html" 650 300 text+--+-- The static-canvas API shadows the actual Javascript API, and thus the+-- best place to look for a more detailed definition of the canvas functions+-- including the definitions of it's aruments see <http://www.w3.org/TR/2dcontext/>.+-- Javascript functions tranliterate readily e.g. @moveTo(x, y);@ becomes @moveTo x y@.+-------------------------------------------------------------------------------++module Graphics.Static+ (+ -- * Building and Writing+ evalScript+ , buildScript+ , buildDoc+ , writeCanvasScript+ , writeCanvasDoc+ -- * HTML5 Canvas API+ , CanvasFree+ -- ** Paths+ , beginPath+ , closePath+ , fill+ , stroke+ , clip+ , moveTo+ , lineTo+ , quadraticCurveTo+ , bezierCurveTo+ , arcTo+ , arc+ , rect+ -- ** Line styles+ , lineWidth+ , lineCap+ , lineJoin+ , miterLimit+ , LineCapStyle(..)+ , LineJoinStyle(..)+ -- ** Colors, styles and shadows+ , strokeStyle+ , fillStyle+ , shadowOffsetX+ , shadowOffsetY+ , shadowBlur+ , shadowColor+ , createLinearGradient+ , createRadialGradient+ , addColorStop+ , Gradient(..)+ , createPattern+ , RepeatStyle(..)+ , Color(..)+ , Style(..)+ -- ** Color utilities+ , rgb+ , rgba+ -- ** Text+ , font+ , textAlign+ , textBaseline+ , fillText+ , strokeText+ , TextAlignStyle(..)+ , TextBaselineStyle(..)+ -- ** Rectangles+ , clearRect+ , fillRect+ , strokeRect+ -- ** Context+ , save+ , restore+ -- ** Transformations+ , scale+ , rotate+ , translate+ , transform+ , setTransform+ -- ** Images+ , drawImageAt+ , drawImageSize+ , drawImageCrop+ , newImage+ , onImageLoad+ -- ** Compositing+ , globalAlpha+ , globalCompositeOperation+ , CompositeOperation(..)+ ) where++import Control.Monad.Free (liftF)+import Data.Monoid+import Prelude hiding (writeFile)+import Data.Text (Text)+import Data.Text.Lazy.Builder (Builder, toLazyText)+import Data.Text.Lazy.IO (writeFile) +import Graphics.Static.Interpreter+import Graphics.Static.Javascript+import Graphics.Static.Types++-------------------------------------------------------------------------------+-- Building and writing+-------------------------------------------------------------------------------++writeCanvasDoc :: FilePath -> Int -> Int -> CanvasFree () -> IO ()+writeCanvasDoc path w h canvas = writeFile path (toLazyText $ buildDoc w h canvas)++writeCanvasScript :: FilePath -> Int -> Int -> CanvasFree () -> IO ()+writeCanvasScript path w h canvas = writeFile path (toLazyText $ buildScript w h canvas)++buildDoc :: Int -> Int -> CanvasFree () -> Builder+buildDoc w h canvas+ = "<!DOCTYPE HTML><html><body>"+ <> (buildScript w h canvas)+ <> "</body></html>"++buildScript :: Int -> Int -> CanvasFree () -> Builder+buildScript w h canvas+ = "<canvas id=\"theStaticCanvas\" width=\"" <> jsInt w+ <> "\" height=\"" <> jsInt h <> "\"></canvas>"+ <> "<script>"+ <> "var canvas = document.getElementById('theStaticCanvas');"+ <> "var ctx = canvas.getContext('2d');"+ <> (evalScript canvas)+ <> "</script>"++-------------------------------------------------------------------------------+-- Color utilities+-------------------------------------------------------------------------------++rgb :: Int -> Int -> Int -> Style+rgb r g b = ColorStyle (RGB r g b)++rgba :: Int -> Int -> Int -> Double -> Style+rgba r g b a = ColorStyle (RGBA r g b a)++-------------------------------------------------------------------------------+-- The DSL+-------------------------------------------------------------------------------++addColorStop :: Double -> Color -> Style -> CanvasFree ()+addColorStop a1 a2 a3 = liftF $ AddColorStop a1 a2 a3 ()++arc :: Double -> Double -> Double -> Double -> Double -> Bool -> CanvasFree ()+arc a1 a2 a3 a4 a5 a6 = liftF $ Arc a1 a2 a3 a4 a5 a6 ()++arcTo :: Double -> Double -> Double -> Double -> Double -> CanvasFree ()+arcTo a1 a2 a3 a4 a5 = liftF $ ArcTo a1 a2 a3 a4 a5 ()++beginPath :: CanvasFree ()+beginPath = liftF $ BeginPath ()++-- | Cubic Bezier curve.+bezierCurveTo :: Double -> Double -> Double -> Double -> Double -> Double -> CanvasFree ()+bezierCurveTo a1 a2 a3 a4 a5 a6 = liftF $ BezierCurveTo a1 a2 a3 a4 a5 a6 ()++clearRect :: Double -> Double -> Double -> Double -> CanvasFree ()+clearRect a1 a2 a3 a4 = liftF $ ClearRect a1 a2 a3 a4 ()++clip :: CanvasFree ()+clip = liftF $ Clip ()++closePath :: CanvasFree ()+closePath = liftF $ ClosePath ()++createLinearGradient :: Double -> Double -> Double -> Double -> CanvasFree Style+createLinearGradient a1 a2 a3 a4 = liftF $ CreateLinearGradient a1 a2 a3 a4 id++createPattern :: Int -> RepeatStyle -> CanvasFree Style+createPattern a1 a2 = liftF $ CreatePattern a1 a2 id++createRadialGradient :: Double -> Double -> Double -> Double -> Double -> Double -> CanvasFree Style+createRadialGradient a1 a2 a3 a4 a5 a6 = liftF $ CreateRadialGradient a1 a2 a3 a4 a5 a6 id++drawImageAt :: Int -> Double -> Double -> CanvasFree ()+drawImageAt a1 a2 a3 = liftF $ DrawImageAt a1 a2 a3 ()++drawImageSize :: Int -> Double -> Double -> Double -> Double -> CanvasFree ()+drawImageSize a1 a2 a3 a4 a5 = liftF $ DrawImageSize a1 a2 a3 a4 a5 ()++drawImageCrop :: Int -> Double -> Double -> Double -> Double -> Double+ -> Double -> Double -> Double -> CanvasFree ()+drawImageCrop a1 a2 a3 a4 a5 a6 a7 a8 a9+ = liftF $ DrawImageCrop a1 a2 a3 a4 a5 a6 a7 a8 a9 ()++fill :: CanvasFree ()+fill = liftF $ Fill ()++fillRect :: Double -> Double -> Double -> Double -> CanvasFree ()+fillRect a1 a2 a3 a4 = liftF $ FillRect a1 a2 a3 a4 ()++fillStyle :: Style -> CanvasFree ()+fillStyle a1 = liftF $ FillStyle a1 ()++fillText :: Text -> Double -> Double -> CanvasFree ()+fillText a1 a2 a3 = liftF $ FillText a1 a2 a3 ()++font :: Text -> CanvasFree ()+font a1 = liftF $ Font a1 ()++globalAlpha :: Double -> CanvasFree ()+globalAlpha a1 = liftF $ GlobalAlpha a1 ()++globalCompositeOperation :: CompositeOperation -> CanvasFree ()+globalCompositeOperation a1 = liftF $ GlobalCompositeOperation a1 ()++lineCap :: LineCapStyle -> CanvasFree ()+lineCap a1 = liftF $ LineCap a1 ()++lineJoin :: LineJoinStyle -> CanvasFree ()+lineJoin a1 = liftF $ LineJoin a1 ()++lineTo :: Double -> Double -> CanvasFree ()+lineTo a1 a2 = liftF $ LineTo a1 a2 ()++-- | Set the line width.+lineWidth :: Double -> CanvasFree ()+lineWidth a1 = liftF $ LineWidth a1 ()++miterLimit :: Double -> CanvasFree ()+miterLimit a1 = liftF $ MiterLimit a1 ()++moveTo :: Double -> Double -> CanvasFree ()+moveTo a1 a2 = liftF $ MoveTo a1 a2 ()++newImage :: Text -> CanvasFree Int+newImage a1 = liftF $ NewImage a1 id++-- | Useful for commands that need to wait for an image to load before+-- being called. For example+--+-- > image = do+-- > img <- newImage "http://www.staticcanvas.com/picture.png"+-- > onImageLoad img (drawImageAt img 0 0)+onImageLoad :: Int -> CanvasFree () -> CanvasFree ()+onImageLoad a1 a2 = liftF $ OnImageLoad a1 a2 ()++-- | A quadratic bezier curve.+quadraticCurveTo :: Double -> Double -> Double -> Double -> CanvasFree ()+quadraticCurveTo a1 a2 a3 a4 = liftF $ QuadraticCurveTo a1 a2 a3 a4 ()++rect :: Double -> Double -> Double -> Double -> CanvasFree ()+rect a1 a2 a3 a4 = liftF $ Rect a1 a2 a3 a4 ()++-- | Pop the top state of the stack.+restore :: CanvasFree ()+restore = liftF $ Restore ()++rotate :: Double -> CanvasFree ()+rotate a1 = liftF $ Rotate a1 ()++-- | Push the current state onto the stack.+save :: CanvasFree ()+save = liftF $ Save ()++scale :: Double -> Double -> CanvasFree ()+scale a1 a2 = liftF $ Scale a1 a2 ()++setTransform :: Double -> Double -> Double -> Double -> Double -> Double -> CanvasFree ()+setTransform a1 a2 a3 a4 a5 a6 = liftF $ SetTransform a1 a2 a3 a4 a5 a6 ()++shadowBlur :: Double -> CanvasFree ()+shadowBlur a1 = liftF $ ShadowBlur a1 ()++shadowColor :: Color -> CanvasFree ()+shadowColor a1 = liftF $ ShadowColor a1 ()++shadowOffsetX :: Double -> CanvasFree ()+shadowOffsetX a1 = liftF $ ShadowOffsetX a1 ()++shadowOffsetY :: Double -> CanvasFree ()+shadowOffsetY a1 = liftF $ ShadowOffsetY a1 ()++stroke :: CanvasFree ()+stroke = liftF $ Stroke ()++strokeRect :: Double -> Double -> Double -> Double -> CanvasFree ()+strokeRect a1 a2 a3 a4 = liftF $ StrokeRect a1 a2 a3 a4 ()++strokeStyle :: Style -> CanvasFree ()+strokeStyle a1 = liftF $ StrokeStyle a1 ()++strokeText :: Text -> Double -> Double -> CanvasFree ()+strokeText a1 a2 a3 = liftF $ StrokeText a1 a2 a3 ()++textAlign :: TextAlignStyle -> CanvasFree ()+textAlign a1 = liftF $ TextAlign a1 ()+ +textBaseline :: TextBaselineStyle -> CanvasFree ()+textBaseline a1 = liftF $ TextBaseline a1 ()++transform :: Double -> Double -> Double -> Double -> Double -> Double -> CanvasFree ()+transform a1 a2 a3 a4 a5 a6 = liftF $ Transform a1 a2 a3 a4 a5 a6 ()++translate :: Double -> Double -> CanvasFree ()+translate a1 a2 = liftF $ Translate a1 a2 ()
+ src/Graphics/Static/ColorNames.hs view
@@ -0,0 +1,608 @@+{-# LANGUAGE OverloadedStrings #-}++-------------------------------------------------------------------------------+-- |+-- Module : Graphics.Static.ColorNames+-- Copyright : (c) 2015 Jeffrey Rosenbluth+-- License : BSD-style (see LICENSE)+-- Maintainer : jeffrey.rosenbluth@gmail.com+--+-- Functions to create color styles.+--+-------------------------------------------------------------------------------++module Graphics.Static.ColorNames+ (+ aliceblue+ , antiquewhite+ , aqua+ , aquamarine+ , azure+ , beige+ , bisque+ , black+ , blanchedalmond+ , blue+ , blueviolet+ , brown+ , burlywood+ , cadetblue+ , chartreuse+ , chocolate+ , coral+ , cornflowerblue+ , cornsilk+ , crimson+ , cyan+ , darkblue+ , darkcyan+ , darkgoldenrod+ , darkgray+ , darkgreen+ , darkgrey+ , darkkhaki+ , darkmagenta+ , darkolivegreen+ , darkorange+ , darkorchid+ , darkred+ , darksalmon+ , darkseagreen+ , darkslateblue+ , darkslategray+ , darkslategrey+ , darkturquoise+ , darkviolet+ , deeppink+ , deepskyblue+ , dimgray+ , dimgrey+ , dodgerblue+ , firebrick+ , floralwhite+ , forestgreen+ , fuchsia+ , gainsboro+ , ghostwhite+ , gold+ , goldenrod+ , gray+ , grey+ , green+ , greenyellow+ , honeydew+ , hotpink+ , indianred+ , indigo+ , ivory+ , khaki+ , lavender+ , lavenderblush+ , lawngreen+ , lemonchiffon+ , lightblue+ , lightcoral+ , lightcyan+ , lightgoldenrodyellow+ , lightgray+ , lightgreen+ , lightgrey+ , lightpink+ , lightsalmon+ , lightseagreen+ , lightskyblue+ , lightslategray+ , lightslategrey+ , lightsteelblue+ , lightyellow+ , lime+ , limegreen+ , linen+ , magenta+ , maroon+ , mediumaquamarine+ , mediumblue+ , mediumorchid+ , mediumpurple+ , mediumseagreen+ , mediumslateblue+ , mediumspringgreen+ , mediumturquoise+ , mediumvioletred+ , midnightblue+ , mintcream+ , mistyrose+ , moccasin+ , navajowhite+ , navy+ , oldlace+ , olive+ , olivedrab+ , orange+ , orangered+ , orchid+ , palegoldenrod+ , palegreen+ , paleturquoise+ , palevioletred+ , papayawhip+ , peachpuff+ , peru+ , pink+ , plum+ , powderblue+ , purple+ , red+ , rosybrown+ , royalblue+ , saddlebrown+ , salmon+ , sandybrown+ , seagreen+ , seashell+ , sienna+ , silver+ , skyblue+ , slateblue+ , slategray+ , slategrey+ , snow+ , springgreen+ , steelblue+ , tan+ , teal+ , thistle+ , tomato+ , turquoise+ , violet+ , wheat+ , white+ , whitesmoke+ , yellow+ , yellowgreen+ )+where++import Graphics.Static.Types+import Prelude hiding (tan)++aliceblue :: Style+aliceblue = ColorStyle $ RGB 240 248 255++antiquewhite :: Style+antiquewhite = ColorStyle $ RGB 250 235 215++aqua :: Style+aqua = ColorStyle $ RGB 0 255 255++aquamarine :: Style+aquamarine = ColorStyle $ RGB 127 255 212++azure :: Style+azure = ColorStyle $ RGB 240 255 255++beige :: Style+beige = ColorStyle $ RGB 245 245 220++bisque :: Style+bisque = ColorStyle $ RGB 255 228 196++black :: Style+black = ColorStyle $ RGB 0 0 0++blanchedalmond :: Style+blanchedalmond = ColorStyle $ RGB 255 235 205++blue :: Style+blue = ColorStyle $ RGB 0 0 255++blueviolet :: Style+blueviolet = ColorStyle $ RGB 138 43 226++brown :: Style+brown = ColorStyle $ RGB 165 42 42++burlywood :: Style+burlywood = ColorStyle $ RGB 222 184 135++cadetblue :: Style+cadetblue = ColorStyle $ RGB 95 158 160++chartreuse :: Style+chartreuse = ColorStyle $ RGB 127 255 0++chocolate :: Style+chocolate = ColorStyle $ RGB 210 105 30++coral :: Style+coral = ColorStyle $ RGB 255 127 80++cornflowerblue :: Style+cornflowerblue = ColorStyle $ RGB 100 149 237++cornsilk :: Style+cornsilk = ColorStyle $ RGB 255 248 220++crimson :: Style+crimson = ColorStyle $ RGB 220 20 60++cyan :: Style+cyan = ColorStyle $ RGB 0 255 255++darkblue :: Style+darkblue = ColorStyle $ RGB 0 0 139++darkcyan :: Style+darkcyan = ColorStyle $ RGB 0 139 139++darkgoldenrod :: Style+darkgoldenrod = ColorStyle $ RGB 184 134 11++darkgray :: Style+darkgray = ColorStyle $ RGB 169 169 169++darkgreen :: Style+darkgreen = ColorStyle $ RGB 0 100 0++darkgrey :: Style+darkgrey = ColorStyle $ RGB 169 169 169++darkkhaki :: Style+darkkhaki = ColorStyle $ RGB 189 183 107++darkmagenta :: Style+darkmagenta = ColorStyle $ RGB 139 0 139++darkolivegreen :: Style+darkolivegreen = ColorStyle $ RGB 85 107 47++darkorange :: Style+darkorange = ColorStyle $ RGB 255 140 0++darkorchid :: Style+darkorchid = ColorStyle $ RGB 153 50 204++darkred :: Style+darkred = ColorStyle $ RGB 139 0 0++darksalmon :: Style+darksalmon = ColorStyle $ RGB 233 150 122++darkseagreen :: Style+darkseagreen = ColorStyle $ RGB 143 188 143++darkslateblue :: Style+darkslateblue = ColorStyle $ RGB 72 61 139++darkslategray :: Style+darkslategray = ColorStyle $ RGB 47 79 79++darkslategrey :: Style+darkslategrey = ColorStyle $ RGB 47 79 79++darkturquoise :: Style+darkturquoise = ColorStyle $ RGB 0 206 209++darkviolet :: Style+darkviolet = ColorStyle $ RGB 148 0 211++deeppink :: Style+deeppink = ColorStyle $ RGB 255 20 147++deepskyblue :: Style+deepskyblue = ColorStyle $ RGB 0 191 255++dimgray :: Style+dimgray = ColorStyle $ RGB 105 105 105++dimgrey :: Style+dimgrey = ColorStyle $ RGB 105 105 105++dodgerblue :: Style+dodgerblue = ColorStyle $ RGB 30 144 255++firebrick :: Style+firebrick = ColorStyle $ RGB 178 34 34++floralwhite :: Style+floralwhite = ColorStyle $ RGB 255 250 240++forestgreen :: Style+forestgreen = ColorStyle $ RGB 34 139 34++fuchsia :: Style+fuchsia = ColorStyle $ RGB 255 0 255++gainsboro :: Style+gainsboro = ColorStyle $ RGB 220 220 220++ghostwhite :: Style+ghostwhite = ColorStyle $ RGB 248 248 255++gold :: Style+gold = ColorStyle $ RGB 255 215 0++goldenrod :: Style+goldenrod = ColorStyle $ RGB 218 165 32++gray :: Style+gray = ColorStyle $ RGB 128 128 128++grey :: Style+grey = ColorStyle $ RGB 128 128 128++green :: Style+green = ColorStyle $ RGB 0 128 0++greenyellow :: Style+greenyellow = ColorStyle $ RGB 173 255 47++honeydew :: Style+honeydew = ColorStyle $ RGB 240 255 240++hotpink :: Style+hotpink = ColorStyle $ RGB 255 105 180++indianred :: Style+indianred = ColorStyle $ RGB 205 92 92++indigo :: Style+indigo = ColorStyle $ RGB 75 0 130++ivory :: Style+ivory = ColorStyle $ RGB 255 255 240++khaki :: Style+khaki = ColorStyle $ RGB 240 230 140++lavender :: Style+lavender = ColorStyle $ RGB 230 230 250++lavenderblush :: Style+lavenderblush = ColorStyle $ RGB 255 240 245++lawngreen :: Style+lawngreen = ColorStyle $ RGB 124 252 0++lemonchiffon :: Style+lemonchiffon = ColorStyle $ RGB 255 250 205++lightblue :: Style+lightblue = ColorStyle $ RGB 173 216 230++lightcoral :: Style+lightcoral = ColorStyle $ RGB 240 128 128++lightcyan :: Style+lightcyan = ColorStyle $ RGB 224 255 255++lightgoldenrodyellow :: Style+lightgoldenrodyellow = ColorStyle $ RGB 250 250 210++lightgray :: Style+lightgray = ColorStyle $ RGB 211 211 211++lightgreen :: Style+lightgreen = ColorStyle $ RGB 144 238 144++lightgrey :: Style+lightgrey = ColorStyle $ RGB 211 211 211++lightpink :: Style+lightpink = ColorStyle $ RGB 255 182 193++lightsalmon :: Style+lightsalmon = ColorStyle $ RGB 255 160 122++lightseagreen :: Style+lightseagreen = ColorStyle $ RGB 32 178 170++lightskyblue :: Style+lightskyblue = ColorStyle $ RGB 135 206 250++lightslategray :: Style+lightslategray = ColorStyle $ RGB 119 136 153++lightslategrey :: Style+lightslategrey = ColorStyle $ RGB 119 136 153++lightsteelblue :: Style+lightsteelblue = ColorStyle $ RGB 176 196 222++lightyellow :: Style+lightyellow = ColorStyle $ RGB 255 255 224++lime :: Style+lime = ColorStyle $ RGB 0 255 0++limegreen :: Style+limegreen = ColorStyle $ RGB 50 205 50++linen :: Style+linen = ColorStyle $ RGB 250 240 230++magenta :: Style+magenta = ColorStyle $ RGB 255 0 255++maroon :: Style+maroon = ColorStyle $ RGB 128 0 0++mediumaquamarine :: Style+mediumaquamarine = ColorStyle $ RGB 102 205 170++mediumblue :: Style+mediumblue = ColorStyle $ RGB 0 0 205++mediumorchid :: Style+mediumorchid = ColorStyle $ RGB 186 85 211++mediumpurple :: Style+mediumpurple = ColorStyle $ RGB 147 112 219++mediumseagreen :: Style+mediumseagreen = ColorStyle $ RGB 60 179 113++mediumslateblue :: Style+mediumslateblue = ColorStyle $ RGB 123 104 238++mediumspringgreen :: Style+mediumspringgreen = ColorStyle $ RGB 0 250 154++mediumturquoise :: Style+mediumturquoise = ColorStyle $ RGB 72 209 204++mediumvioletred :: Style+mediumvioletred = ColorStyle $ RGB 199 21 133++midnightblue :: Style+midnightblue = ColorStyle $ RGB 25 25 112++mintcream :: Style+mintcream = ColorStyle $ RGB 245 255 250++mistyrose :: Style+mistyrose = ColorStyle $ RGB 255 228 225++moccasin :: Style+moccasin = ColorStyle $ RGB 255 228 181++navajowhite :: Style+navajowhite = ColorStyle $ RGB 255 222 173++navy :: Style+navy = ColorStyle $ RGB 0 0 128++oldlace :: Style+oldlace = ColorStyle $ RGB 253 245 230++olive :: Style+olive = ColorStyle $ RGB 128 128 0++olivedrab :: Style+olivedrab = ColorStyle $ RGB 107 142 35++orange :: Style+orange = ColorStyle $ RGB 255 165 0++orangered :: Style+orangered = ColorStyle $ RGB 255 69 0++orchid :: Style+orchid = ColorStyle $ RGB 218 112 214++palegoldenrod :: Style+palegoldenrod = ColorStyle $ RGB 238 232 170++palegreen :: Style+palegreen = ColorStyle $ RGB 152 251 152++paleturquoise :: Style+paleturquoise = ColorStyle $ RGB 175 238 238++palevioletred :: Style+palevioletred = ColorStyle $ RGB 219 112 147++papayawhip :: Style+papayawhip = ColorStyle $ RGB 255 239 213++peachpuff :: Style+peachpuff = ColorStyle $ RGB 255 218 185++peru :: Style+peru = ColorStyle $ RGB 205 133 63++pink :: Style+pink = ColorStyle $ RGB 255 192 203++plum :: Style+plum = ColorStyle $ RGB 221 160 221++powderblue :: Style+powderblue = ColorStyle $ RGB 176 224 230++purple :: Style+purple = ColorStyle $ RGB 128 0 128++red :: Style+red = ColorStyle $ RGB 255 0 0++rosybrown :: Style+rosybrown = ColorStyle $ RGB 188 143 143++royalblue :: Style+royalblue = ColorStyle $ RGB 65 105 225++saddlebrown :: Style+saddlebrown = ColorStyle $ RGB 139 69 19++salmon :: Style+salmon = ColorStyle $ RGB 250 128 114++sandybrown :: Style+sandybrown = ColorStyle $ RGB 244 164 96++seagreen :: Style+seagreen = ColorStyle $ RGB 46 139 87++seashell :: Style+seashell = ColorStyle $ RGB 255 245 238++sienna :: Style+sienna = ColorStyle $ RGB 160 82 45++silver :: Style+silver = ColorStyle $ RGB 192 192 192++skyblue :: Style+skyblue = ColorStyle $ RGB 135 206 235++slateblue :: Style+slateblue = ColorStyle $ RGB 106 90 205++slategray :: Style+slategray = ColorStyle $ RGB 112 128 144++slategrey :: Style+slategrey = ColorStyle $ RGB 112 128 144++snow :: Style+snow = ColorStyle $ RGB 255 250 250++springgreen :: Style+springgreen = ColorStyle $ RGB 0 255 127++steelblue :: Style+steelblue = ColorStyle $ RGB 70 130 180++tan :: Style+tan = ColorStyle $ RGB 210 180 140++teal :: Style+teal = ColorStyle $ RGB 0 128 128++thistle :: Style+thistle = ColorStyle $ RGB 216 191 216++tomato :: Style+tomato = ColorStyle $ RGB 255 99 71++turquoise :: Style+turquoise = ColorStyle $ RGB 64 224 208++violet :: Style+violet = ColorStyle $ RGB 238 130 238++wheat :: Style+wheat = ColorStyle $ RGB 245 222 179++white :: Style+white = ColorStyle $ RGB 255 255 255++whitesmoke :: Style+whitesmoke = ColorStyle $ RGB 245 245 245++yellow :: Style+yellow = ColorStyle $ RGB 255 255 0++yellowgreen :: Style+yellowgreen = ColorStyle $ RGB 154 205 50
+ src/Graphics/Static/Interpreter.hs view
@@ -0,0 +1,283 @@+{-# LANGUAGE OverloadedStrings #-}++-------------------------------------------------------------------------------+-- |+-- Module : Graphics.Static.Interpreter+-- Copyright : (c) 2015 Jeffrey Rosenbluth+-- License : BSD-style (see LICENSE)+-- Maintainer : jeffrey.rosenbluth@gmail.com+--+-- Interpreter to convert a static-canvas representation to js.+--+-------------------------------------------------------------------------------++module Graphics.Static.Interpreter+ ( evalScript+ ) where++import Control.Monad.Free (Free(..))+import Control.Monad.Free.Church (fromF)+import Control.Monad.State+import Control.Monad.Writer+import Data.Text.Lazy.Builder (Builder, fromText, singleton)+import Graphics.Static.Javascript+import Graphics.Static.Types++-- | Evaluate a static-canvas program and return the javascript code in a 'Builder'.+evalScript :: CanvasFree a -> Builder+evalScript c = (evalState . execWriterT . runScript . eval . fromF) c 0++record :: [Builder] -> Script ()+record = tell . mconcat++inc :: Script Int+inc = do+ n <- get+ put (n + 1)+ return n++--------------------------------------------------------------------------------++eval :: Free Canvas a -> Script a++eval (Free (AddColorStop a1 a2 a3 c)) = do+ record [jsStyle a3, ".addColorStop("+ , jsDouble a1, comma, jsColor a2, ");"]+ eval c++eval (Free (Arc a1 a2 a3 a4 a5 a6 c)) = do+ record ["ctx.arc("+ , jsDouble a1, comma, jsDouble a2, comma+ , jsDouble a3, comma, jsDouble a4, comma+ , jsDouble a5, comma, jsBool a6 , ");"]+ eval c++eval (Free (ArcTo a1 a2 a3 a4 a5 c)) = do+ record ["ctx.arcTo("+ , jsDouble a1, comma, jsDouble a2, comma+ , jsDouble a3, comma, jsDouble a4, comma+ , jsDouble a5, comma, ");"]+ eval c++eval (Free (BeginPath c)) = do+ tell "ctx.beginPath();"+ eval c++eval (Free (BezierCurveTo a1 a2 a3 a4 a5 a6 c)) = do+ record ["ctx.bezierCurveTo("+ , jsDouble a1, comma, jsDouble a2, comma+ , jsDouble a3, comma, jsDouble a4, comma+ , jsDouble a5, comma, jsDouble a6, ");"]+ eval c++eval (Free (ClearRect a1 a2 a3 a4 c)) = do+ record ["ctx.clearRect("+ , jsDouble a1, comma, jsDouble a2, comma+ , jsDouble a3, comma, jsDouble a4, ");"]+ eval c++eval (Free (Clip c)) = do+ tell "ctx.clip();"+ eval c++eval (Free (ClosePath c)) = do+ tell "ctx.closePath();"+ eval c++eval (Free (CreateLinearGradient a1 a2 a3 a4 k)) = do+ i <- inc+ record ["var gradient_", jsInt i, " = ctx.createLinearGradient("+ , jsDouble a1, comma, jsDouble a2, comma+ , jsDouble a3, comma, jsDouble a4, ");"]+ eval (k (GradientStyle (LG i)))++eval (Free (CreatePattern a1 a2 k)) = do+ i <- inc+ record ["var pattern_", jsInt i, " = ctx.createPattern(image_"+ , jsInt a1, comma, jsRepeat a2, ");"]+ eval (k (PatternStyle i))++eval (Free (CreateRadialGradient a1 a2 a3 a4 a5 a6 k)) = do+ i <- inc+ record ["var gradient_", jsInt i, " = ctx.createRadialGradient("+ , jsDouble a1, comma, jsDouble a2, comma+ , jsDouble a3, comma, jsDouble a4, comma+ , jsDouble a5, comma, jsDouble a6, ");"]+ eval (k (GradientStyle (RG i)))++eval (Free (DrawImageAt a1 a2 a3 c)) = do+ record ["ctx.drawImage(image_", jsInt a1, comma+ , jsDouble a2, comma, jsDouble a3, ");"]+ eval c++eval (Free (DrawImageSize a1 a2 a3 a4 a5 c)) = do+ record ["ctx.drawImage(image_", jsInt a1, comma+ , jsDouble a2, comma, jsDouble a3, comma+ , jsDouble a4, comma, jsDouble a5, ");"]+ eval c++eval (Free (DrawImageCrop a1 a2 a3 a4 a5 a6 a7 a8 a9 c)) = do+ record ["ctx.drawImage(image_", jsInt a1, comma+ , jsDouble a2, comma, jsDouble a3, comma+ , jsDouble a4, comma, jsDouble a5, comma+ , jsDouble a6, comma, jsDouble a7, comma+ , jsDouble a8, comma, jsDouble a9, ");"]+ eval c++eval (Free (Fill c)) = do+ tell "ctx.fill();"+ eval c++eval (Free (FillRect a1 a2 a3 a4 c)) = do+ record ["ctx.fillRect("+ , jsDouble a1, comma, jsDouble a2, comma+ , jsDouble a3, comma, jsDouble a4, ");"]+ eval c++eval (Free (FillStyle a1 c)) = do+ record ["ctx.fillStyle = (", jsStyle a1, ");"]+ eval c++eval (Free (FillText a1 a2 a3 c)) = do+ record ["ctx.fillText('", fromText a1, singleton '\'', comma+ , jsDouble a2, comma+ , jsDouble a3, ");"]+ eval c++eval (Free (Font a1 c)) = do+ record ["ctx.font = ('", fromText a1, "');"]+ eval c++eval (Free (GlobalAlpha a1 c)) = do+ record ["ctx.globalAlpha = (", jsDouble a1, ");"]+ eval c+ +eval (Free (GlobalCompositeOperation a1 c)) = do+ record ["ctx.globalCompositeOperation = ('", jsComposite a1, "');"]+ eval c++eval (Free (LineCap a1 c)) = do+ record ["ctx.lineCap = ('", jsLineCap a1, "');"]+ eval c++eval (Free (LineJoin a1 c)) = do+ record ["ctx.lineJoin = ('", jsLineJoin a1, "');"]+ eval c++eval (Free (LineTo a1 a2 c)) = do+ record ["ctx.lineTo(", jsDouble a1, comma, jsDouble a2, ");"]+ eval c++eval (Free (LineWidth a1 c)) = do+ record ["ctx.lineWidth = (", jsDouble a1, ");"]+ eval c++eval (Free (MiterLimit a1 c)) = do+ record ["ctx.miterLimit = (", jsDouble a1, ");"]+ eval c++eval (Free (MoveTo a1 a2 c)) = do+ record ["ctx.moveTo(", jsDouble a1, comma, jsDouble a2, ");"]+ eval c++eval (Free (NewImage a1 k)) = do+ i <- inc+ record ["var image_", jsInt i, " = new Image(); image_"+ , jsInt i, ".src = ('", fromText a1, "');"]+ eval (k i)+ +eval (Free (OnImageLoad a1 a2 c)) = do+ record ["image_", jsInt a1, ".onload = function() {", evalScript a2, "};"]+ eval c++eval (Free (QuadraticCurveTo a1 a2 a3 a4 c)) = do+ record ["ctx.quadraticCurveTo("+ , jsDouble a1, comma, jsDouble a2, comma+ , jsDouble a3, comma, jsDouble a4, ");"]+ eval c++eval (Free (Rect a1 a2 a3 a4 c)) = do+ record ["ctx.rect(", jsDouble a1, comma+ , jsDouble a2, comma+ , jsDouble a3, comma+ , jsDouble a4, ");"]+ eval c++eval (Free (Restore c)) = do+ tell "ctx.restore();"+ eval c++eval (Free (Rotate a1 c)) = do+ record ["ctx.rotate(", jsDouble a1, ");"]+ eval c++eval (Free (Save c)) = do+ tell "ctx.save();"+ eval c++eval (Free (Scale a1 a2 c)) = do+ record ["ctx.scale(", jsDouble a1, comma, jsDouble a2, ");"]+ eval c++eval (Free (SetTransform a1 a2 a3 a4 a5 a6 c)) = do+ record ["ctx.setTransform("+ , jsDouble a1, comma, jsDouble a2, comma+ , jsDouble a3, comma, jsDouble a4, comma+ , jsDouble a5, comma, jsDouble a6, ");"]+ eval c++eval (Free (ShadowColor a1 c)) = do+ record ["ctx.shadowColor = ('", jsColor a1, "');"]+ eval c++eval (Free (ShadowBlur a1 c)) = do+ record ["ctx.shadowBlur = (", jsDouble a1, ");"]+ eval c++eval (Free (ShadowOffsetX a1 c)) = do+ record ["ctx.shadowOffsetX = (", jsDouble a1, ");"]+ eval c++eval (Free (ShadowOffsetY a1 c)) = do+ record ["ctx.shadowOffsetY = (", jsDouble a1, ");"]+ eval c++eval (Free (Stroke c)) = do+ tell "ctx.stroke();"+ eval c++eval (Free (StrokeRect a1 a2 a3 a4 c)) = do+ record ["ctx.strokeRect("+ , jsDouble a1, comma, jsDouble a2, comma+ , jsDouble a3, comma, jsDouble a4, ");"]+ eval c++eval (Free (StrokeStyle a1 c)) = do+ record ["ctx.strokeStyle = (", jsStyle a1, ");"]+ eval c++eval (Free (StrokeText a1 a2 a3 c)) = do+ record ["ctx.strokeText('", fromText a1, singleton '\''+ , comma, jsDouble a2, comma, jsDouble a3, ");"]+ eval c++eval (Free (TextAlign a1 c)) = do+ record ["ctx.textAlign = ('", jsTextAlign a1, "');"]+ eval c++eval (Free (TextBaseline a1 c)) = do+ record ["ctx.textBaseline = ('", jsTextBaseline a1, "');"]+ eval c++eval (Free (Transform a1 a2 a3 a4 a5 a6 c)) = do+ record ["ctx.transform("+ , jsDouble a1, comma, jsDouble a2, comma+ , jsDouble a3, comma, jsDouble a4, comma+ , jsDouble a5, comma, jsDouble a6, ");"]+ eval c++eval (Free (Translate a1 a2 c)) = do+ record ["translate(", jsDouble a1, comma, jsDouble a2, ");"]+ eval c++eval (Pure x) = return x
+ src/Graphics/Static/Javascript.hs view
@@ -0,0 +1,112 @@+{-# LANGUAGE OverloadedStrings #-}++-------------------------------------------------------------------------------+-- |+-- Module : Graphics.Static.Javascript+-- Copyright : (c) 2015 Jeffrey Rosenbluth+-- License : BSD-style (see LICENSE)+-- Maintainer : jeffrey.rosenbluth@gmail.com+--+-- DSL for creating HTML5 Canvas.+--+-------------------------------------------------------------------------------++module Graphics.Static.Javascript+ (+ jsBool+ , jsInt+ , jsDouble+ , jsColor+ , jsStyle+ , jsLineCap+ , jsLineJoin+ , jsTextAlign+ , jsTextBaseline+ , jsRepeat+ , jsComposite+ , comma+ ) where++import Control.Monad.Writer+import Data.Double.Conversion.Text (toFixed)+import Data.Text (pack)+import Data.Text.Lazy.Builder (Builder, fromText, singleton)+import Graphics.Static.Types++build :: Show a => a -> Builder+build = fromText .pack . show+ +comma :: Builder+comma = singleton ','++quote :: Builder -> Builder+quote b = singleton '\'' <> b <> singleton '\''++jsBool :: Bool -> Builder+jsBool True = "true"+jsBool False = "false"++jsInt :: Int -> Builder+jsInt = fromText . pack . show++jsDouble :: Double -> Builder+jsDouble = fromText . toFixed 4++jsColor :: Color -> Builder+jsColor (Hex t) = quote . fromText $ t+jsColor (RGB r g b) = quote $ "rgb(" <> (build r)+ <> comma <> (build g)+ <> comma <> (build b) <> singleton ')'+jsColor (RGBA r g b a) = quote $ "rgba(" <> (build r)+ <> comma <> (build g)+ <> comma <> (build b)+ <> comma <> (jsDouble a) <> singleton ')'++jsStyle :: Style -> Builder+jsStyle (ColorStyle c) = jsColor c+jsStyle (GradientStyle (LG n)) = "gradient_" <> (build n)+jsStyle (GradientStyle (RG n)) = "gradient_" <> (build n)+jsStyle (PatternStyle n) = "pattern_" <> (build n)++jsLineCap :: LineCapStyle -> Builder+jsLineCap LineCapButt = "butt"+jsLineCap LineCapRound = "round"+jsLineCap LineCapSquare = "square"++jsLineJoin :: LineJoinStyle -> Builder+jsLineJoin LineJoinMiter = "miter"+jsLineJoin LineJoinRound = "round"+jsLineJoin LineJoinBevel = "bevel"++jsTextAlign :: TextAlignStyle -> Builder+jsTextAlign TextAlignStart = "start"+jsTextAlign TextAlignEnd = "end"+jsTextAlign TextAlignCenter = "center"+jsTextAlign TextAlignLeft = "left"+jsTextAlign TextAlignRight = "right"++jsTextBaseline :: TextBaselineStyle -> Builder+jsTextBaseline TextBaselineTop = "top"+jsTextBaseline TextBaselineHanging = "hanging"+jsTextBaseline TextBaselineMiddle = "middle"+jsTextBaseline TextBaselineIdeographic = "ideographic"+jsTextBaseline TextBaselineBottom = "bottom"++jsRepeat :: RepeatStyle -> Builder+jsRepeat Repeat = quote "repeat"+jsRepeat RepeatX = quote "repeat-x"+jsRepeat RepeatY = quote "repeat-y"+jsRepeat NoRepeat = quote "no-repeat"++jsComposite :: CompositeOperation -> Builder+jsComposite SourceAtop = "source-atop"+jsComposite SourceIn = "source-in"+jsComposite SourceOut = "source-out"+jsComposite SourceOver = "source-over"+jsComposite DestinationAtop = "destination-atop"+jsComposite DestinationIn = "destination-in"+jsComposite DestinationOut = "destination-out"+jsComposite DestinationOver = "destination-over"+jsComposite Darker = "darker"+jsComposite Xor = "xor"+jsComposite Copy = "copy"
+ src/Graphics/Static/Types.hs view
@@ -0,0 +1,137 @@+{-# LANGUAGE DeriveFunctor #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE OverloadedStrings #-}++-------------------------------------------------------------------------------+-- |+-- Module : Graphics.Static.Types+-- Copyright : (c) 2015 Jeffrey Rosenbluth+-- License : BSD-style (see LICENSE)+-- Maintainer : jeffrey.rosenbluth@gmail.com+--+-- A simple DSL for creating HTML5 Canvas.+--+-------------------------------------------------------------------------------++module Graphics.Static.Types where++import Control.Applicative+import Control.Monad.Free.Church (F)+import Control.Monad.State+import Control.Monad.Writer+import Data.Text (Text)+import Data.Text.Lazy.Builder (Builder)++newtype Script a = Script {runScript :: (WriterT Builder (State Int) a)}+ deriving (Functor, Applicative, Monad, MonadWriter Builder, MonadState Int)++type CanvasFree = F Canvas++data Canvas r+ = AddColorStop !Double Color Style r+ | Arc !Double !Double !Double !Double !Double !Bool r+ | ArcTo !Double !Double !Double !Double !Double r+ | BeginPath r+ | BezierCurveTo !Double !Double !Double !Double !Double !Double r+ | ClearRect !Double !Double !Double !Double r+ | Clip r+ | ClosePath r+ | CreateLinearGradient !Double !Double !Double !Double (Style -> r)+ | CreatePattern !Int RepeatStyle (Style -> r)+ | CreateRadialGradient !Double !Double !Double !Double !Double !Double (Style -> r)+ | DrawImageAt !Int !Double !Double r+ | DrawImageSize !Int !Double !Double !Double !Double r+ | DrawImageCrop !Int !Double !Double !Double !Double !Double !Double !Double !Double r+ | Fill r+ | FillRect !Double !Double !Double !Double r+ | FillStyle Style r+ | FillText Text !Double !Double r+ | Font Text r+ | GlobalAlpha !Double r+ | GlobalCompositeOperation CompositeOperation r+ | LineCap LineCapStyle r+ | LineJoin LineJoinStyle r+ | LineTo !Double !Double r+ | LineWidth !Double r+ | MiterLimit !Double r+ | MoveTo !Double !Double r+ | NewImage Text (Int -> r)+ | OnImageLoad !Int (CanvasFree ()) r+ | QuadraticCurveTo !Double !Double !Double !Double r+ | Rect !Double !Double !Double !Double r+ | Restore r+ | Rotate !Double r+ | Save r+ | Scale !Double !Double r+ | SetTransform !Double !Double !Double !Double !Double !Double r+ | ShadowBlur !Double r+ | ShadowColor Color r+ | ShadowOffsetX !Double r+ | ShadowOffsetY !Double r+ | Stroke r+ | StrokeRect !Double !Double !Double !Double r+ | StrokeStyle Style r+ | StrokeText Text !Double !Double r+ | TextAlign TextAlignStyle r+ | TextBaseline TextBaselineStyle r+ | Transform !Double !Double !Double !Double !Double !Double r+ | Translate !Double !Double r+ deriving Functor++data Color+ = Hex Text+ | RGB !Int !Int !Int+ | RGBA !Int !Int !Int !Double++data Gradient+ = LG !Int+ | RG !Int++data Style+ = ColorStyle Color+ | GradientStyle Gradient+ | PatternStyle !Int++data LineCapStyle+ = LineCapButt+ | LineCapRound+ | LineCapSquare++data LineJoinStyle+ = LineJoinMiter+ | LineJoinRound+ | LineJoinBevel+ +data TextAlignStyle+ = TextAlignStart+ | TextAlignEnd+ | TextAlignCenter+ | TextAlignLeft+ | TextAlignRight+ +data TextBaselineStyle+ = TextBaselineTop+ | TextBaselineHanging+ | TextBaselineMiddle+ | TextBaselineIdeographic+ | TextBaselineBottom++-- | For use with @createPattern@+data RepeatStyle+ = Repeat+ | RepeatX+ | RepeatY+ | NoRepeat++data CompositeOperation+ = SourceAtop+ | SourceIn+ | SourceOut+ | SourceOver+ | DestinationAtop+ | DestinationIn+ | DestinationOut+ | DestinationOver+ | Darker+ | Xor+ | Copy
+ static-canvas.cabal view
@@ -0,0 +1,37 @@+name: static-canvas+version: 0.1.0.0+synopsis: DSL to generate HTML5 Canvas javascript.+description:+ 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.++homepage: https://github.com/jeffreyrosenbluth/static-canvas+bug-reports: https://github.com/jeffreyrosenbluth/static-canvas/issues+license: BSD3+license-file: LICENSE+author: Jeffrey Rosenbluth+maintainer: jeffrey.rosenbluth@gmail.com+copyright: 2015 Jeffrey Rosenbluth+category: Graphics+stability: Experimental+build-type: Simple+extra-source-files: README.md+cabal-version: >=1.10++library+ ghc-options: -Wall -rtsopts -O2+ exposed-modules: Graphics.Static+ Graphics.Static.ColorNames+ other-modules: Graphics.Static.Types+ Graphics.Static.Interpreter+ Graphics.Static.Javascript+ build-depends: base >=4.5 && < 4.9,+ mtl >= 2.2 && < 2.3,+ free >= 4.10 && < 4.11,+ text >=0.11 && < 1.3,+ double-conversion >= 2.0 && < 2.1+ hs-source-dirs: src+ default-language: Haskell2010