{-# OPTIONS_GHC -fno-warn-orphans #-} module Graphics.Blank.Generated where import Graphics.Blank.Canvas instance Show Command where show (Arc (a1,a2,a3,a4,a5,a6)) = "c.arc(" ++ showJ a1 ++ "," ++ showJ a2 ++ "," ++ showJ a3 ++ "," ++ showJ a4 ++ "," ++ showJ a5 ++ "," ++ showB a6 ++ ");" show BeginPath = "c.beginPath();" show (BezierCurveTo (a1,a2,a3,a4,a5,a6)) = "c.bezierCurveTo(" ++ showJ a1 ++ "," ++ showJ a2 ++ "," ++ showJ a3 ++ "," ++ showJ a4 ++ "," ++ showJ a5 ++ "," ++ showJ a6 ++ ");" show (ClearRect (a1,a2,a3,a4)) = "c.clearRect(" ++ showJ a1 ++ "," ++ showJ a2 ++ "," ++ showJ a3 ++ "," ++ showJ a4 ++ ");" show ClosePath = "c.closePath();" show (Custom str) = str show Fill = "c.fill();" show (FillRect (a1,a2,a3,a4)) = "c.fillRect(" ++ showJ a1 ++ "," ++ showJ a2 ++ "," ++ showJ a3 ++ "," ++ showJ a4 ++ ");" show (FillStyle (a1)) = "c.fillStyle = (" ++ show a1 ++ ");" show (FillText (a1,a2,a3)) = "c.fillText(" ++ show a1 ++ "," ++ showJ a2 ++ "," ++ showJ a3 ++ ");" show (Font (a1)) = "c.font = (" ++ show a1 ++ ");" show (GlobalAlpha (a1)) = "c.globalAlpha = (" ++ showJ a1 ++ ");" show (LineCap (a1)) = "c.lineCap = (" ++ show a1 ++ ");" show (LineJoin (a1)) = "c.lineJoin = (" ++ show a1 ++ ");" show (LineTo (a1,a2)) = "c.lineTo(" ++ showJ a1 ++ "," ++ showJ a2 ++ ");" show (LineWidth (a1)) = "c.lineWidth = (" ++ showJ a1 ++ ");" show (MiterLimit (a1)) = "c.miterLimit = (" ++ showJ a1 ++ ");" show (MoveTo (a1,a2)) = "c.moveTo(" ++ showJ a1 ++ "," ++ showJ a2 ++ ");" show Restore = "c.restore();" show (Rotate (a1)) = "c.rotate(" ++ showJ a1 ++ ");" show (Scale (a1,a2)) = "c.scale(" ++ showJ a1 ++ "," ++ showJ a2 ++ ");" show Save = "c.save();" show Stroke = "c.stroke();" show (StrokeRect (a1,a2,a3,a4)) = "c.strokeRect(" ++ showJ a1 ++ "," ++ showJ a2 ++ "," ++ showJ a3 ++ "," ++ showJ a4 ++ ");" show (StrokeText (a1,a2,a3)) = "c.strokeText(" ++ show a1 ++ "," ++ showJ a2 ++ "," ++ showJ a3 ++ ");" show (StrokeStyle (a1)) = "c.strokeStyle = (" ++ show a1 ++ ");" show (TextAlign (a1)) = "c.textAlign = (" ++ show a1 ++ ");" show (TextBaseline (a1)) = "c.textBaseline = (" ++ show a1 ++ ");" show (Transform (a1,a2,a3,a4,a5,a6)) = "c.transform(" ++ showJ a1 ++ "," ++ showJ a2 ++ "," ++ showJ a3 ++ "," ++ showJ a4 ++ "," ++ showJ a5 ++ "," ++ showJ a6 ++ ");" show (Translate (a1,a2)) = "c.translate(" ++ showJ a1 ++ "," ++ showJ a2 ++ ");" -- DSL -- | see arc :: (Float,Float,Float,Float,Float,Bool) -> Canvas () arc = Command . Arc -- | see beginPath :: Canvas () beginPath = Command BeginPath -- | see bezierCurveTo :: (Float,Float,Float,Float,Float,Float) -> Canvas () bezierCurveTo = Command . BezierCurveTo -- | see clearRect :: (Float,Float,Float,Float) -> Canvas () clearRect = Command . ClearRect -- | see closePath :: Canvas () closePath = Command ClosePath -- | sends command (JS) unchanged. useful for extending this library with functionality it doesn't currently have. example: -- -- > custom $ unlines $ [ -- > "var grd=c.createRadialGradient(0,0,3,20,20,10); " -- > ,"grd.addColorStop(0,\"white\");" -- > ,"grd.addColorStop(1,\"red\");" -- > ,"c.fillStyle=grd;"] custom :: String -> Canvas () custom = Command . Custom -- | see fill :: Canvas () fill = Command Fill -- | see fillRect :: (Float,Float,Float,Float) -> Canvas () fillRect = Command . FillRect -- | see fillStyle :: String -> Canvas () fillStyle = Command . FillStyle -- | see fillText :: (String,Float,Float) -> Canvas () fillText = Command . FillText -- | see font :: String -> Canvas () font = Command . Font -- | see globalAlpha :: Float -> Canvas () globalAlpha = Command . GlobalAlpha -- | see lineCap :: String -> Canvas () lineCap = Command . LineCap -- | see lineJoin :: String -> Canvas () lineJoin = Command . LineJoin -- | see lineTo :: (Float,Float) -> Canvas () lineTo = Command . LineTo -- | see lineWidth :: Float -> Canvas () lineWidth = Command . LineWidth -- | see miterLimit :: Float -> Canvas () miterLimit = Command . MiterLimit -- | see moveTo :: (Float,Float) -> Canvas () moveTo = Command . MoveTo -- | see bottom of restore :: Canvas () restore = Command Restore -- | see rotate :: Float -> Canvas () rotate = Command . Rotate -- | scale :: (Float,Float) -> Canvas () scale = Command . Scale -- | see bottom of save :: Canvas () save = Command Save -- | see stroke :: Canvas () stroke = Command Stroke -- | see strokeRect :: (Float,Float,Float,Float) -> Canvas () strokeRect = Command . StrokeRect -- | see strokeText :: (String,Float,Float) -> Canvas () strokeText = Command . StrokeText -- | see strokeStyle :: String -> Canvas () strokeStyle = Command . StrokeStyle -- | see textAlign :: String -> Canvas () textAlign = Command . TextAlign -- | see textBaseline :: String -> Canvas () textBaseline = Command . TextBaseline -- | see transform :: (Float,Float,Float,Float,Float,Float) -> Canvas () transform = Command . Transform -- | see translate :: (Float,Float) -> Canvas () translate = Command . Translate