From fc70c424ebe6124054b1111b31bdd7e39bbf83b9 Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 25 Jun 2017 14:42:31 -0700 Subject: [PATCH 01/35] return unit instead of canvas --- psc-package.json | 2 +- src/Graphics/Canvas.js | 4 ++-- src/Graphics/Canvas.purs | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/psc-package.json b/psc-package.json index 0e565ee..baa0c60 100644 --- a/psc-package.json +++ b/psc-package.json @@ -1,7 +1,7 @@ { "name": "canvas", "source": "https://github.com/purescript/package-sets.git", - "set": "psc-0.10.1", + "set": "psc-0.11.5", "depends": [ "arraybuffer-types", "bifunctors", diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index 2d4e36b..4a673e7 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -57,7 +57,7 @@ exports.setCanvasWidth = function(width) { return function(canvas) { return function() { canvas.width = width; - return canvas; + return {}; }; }; }; @@ -66,7 +66,7 @@ exports.setCanvasHeight = function(height) { return function(canvas) { return function() { canvas.height = height; - return canvas; + return {}; }; }; }; diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index 835b9bb..10f3a0e 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -177,10 +177,10 @@ foreign import getCanvasWidth :: forall eff. CanvasElement -> Eff (canvas :: CAN foreign import getCanvasHeight :: forall eff. CanvasElement -> Eff (canvas :: CANVAS | eff) Number -- | Set the canvas width in pixels. -foreign import setCanvasWidth :: forall eff. Number -> CanvasElement -> Eff (canvas :: CANVAS | eff) CanvasElement +foreign import setCanvasWidth :: forall eff. Number -> CanvasElement -> Eff (canvas :: CANVAS | eff) Unit -- | Set the canvas height in pixels. -foreign import setCanvasHeight :: forall eff. Number -> CanvasElement -> Eff (canvas :: CANVAS | eff) CanvasElement +foreign import setCanvasHeight :: forall eff. Number -> CanvasElement -> Eff (canvas :: CANVAS | eff) Unit -- | Canvas dimensions (width and height) in pixels. type Dimensions = { width :: Number, height :: Number } @@ -193,8 +193,8 @@ getCanvasDimensions ce = do pure {width : w, height : h} -- | Set the canvas dimensions in pixels. -setCanvasDimensions :: forall eff. Dimensions -> CanvasElement -> Eff (canvas :: CANVAS | eff) CanvasElement -setCanvasDimensions d ce = setCanvasHeight d.height ce >>= setCanvasWidth d.width +setCanvasDimensions :: forall eff. Dimensions -> CanvasElement -> Eff (canvas :: CANVAS | eff) Unit +setCanvasDimensions d ce = setCanvasHeight d.height ce *> setCanvasWidth d.width ce -- | Create a data URL for the current canvas contents foreign import canvasToDataURL :: forall eff. CanvasElement -> Eff (canvas :: CANVAS | eff) String From a1d2529a5f0008d6ac72e7727f034563870a7584 Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 25 Jun 2017 15:16:39 -0700 Subject: [PATCH 02/35] return unit instead of context --- src/Graphics/Canvas.js | 102 +++++++++++++++++++-------------------- src/Graphics/Canvas.purs | 94 ++++++++++++++++++------------------ 2 files changed, 98 insertions(+), 98 deletions(-) diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index 4a673e7..bec88df 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -81,7 +81,7 @@ exports.setLineWidth = function(width) { return function(ctx) { return function() { ctx.lineWidth = width; - return ctx; + return {}; }; }; }; @@ -90,7 +90,7 @@ exports.setFillStyle = function(style) { return function(ctx) { return function() { ctx.fillStyle = style; - return ctx; + return {}; }; }; }; @@ -99,7 +99,7 @@ exports.setStrokeStyle = function(style) { return function(ctx) { return function() { ctx.strokeStyle = style; - return ctx; + return {}; }; }; }; @@ -108,7 +108,7 @@ exports.setShadowColor = function(color) { return function(ctx) { return function() { ctx.shadowColor = color; - return ctx; + return {}; }; }; }; @@ -117,7 +117,7 @@ exports.setShadowBlur = function(blur) { return function(ctx) { return function() { ctx.shadowBlur = blur; - return ctx; + return {}; }; }; }; @@ -126,7 +126,7 @@ exports.setShadowOffsetX = function(offsetX) { return function(ctx) { return function() { ctx.shadowOffsetX = offsetX; - return ctx; + return {}; }; }; }; @@ -135,7 +135,7 @@ exports.setShadowOffsetY = function(offsetY) { return function(ctx) { return function() { ctx.shadowOffsetY = offsetY; - return ctx; + return {}; }; }; }; @@ -144,7 +144,7 @@ exports.setMiterLimit = function(limit) { return function(ctx) { return function() { ctx.miterLimit = limit; - return ctx; + return {}; }; }; }; @@ -153,7 +153,7 @@ exports.setLineCapImpl = function(cap) { return function(ctx) { return function() { ctx.lineCap = cap; - return ctx; + return {}; }; }; }; @@ -162,7 +162,7 @@ exports.setLineJoinImpl = function(join) { return function(ctx) { return function() { ctx.lineJoin = join; - return ctx; + return {}; }; }; }; @@ -171,7 +171,7 @@ exports.setGlobalCompositeOperationImpl = function(ctx) { return function(op) { return function() { ctx.globalCompositeOperation = op; - return ctx; + return {}; }; }; }; @@ -180,7 +180,7 @@ exports.setGlobalAlpha = function(ctx) { return function(alpha) { return function() { ctx.globalAlpha = alpha; - return ctx; + return {}; }; }; }; @@ -188,28 +188,28 @@ exports.setGlobalAlpha = function(ctx) { exports.beginPath = function(ctx) { return function() { ctx.beginPath(); - return ctx; + return {}; }; }; exports.stroke = function(ctx) { return function() { ctx.stroke(); - return ctx; + return {}; }; }; exports.fill = function(ctx) { return function() { ctx.fill(); - return ctx; + return {}; }; }; exports.clip = function(ctx) { return function() { ctx.clip(); - return ctx; + return {}; }; }; @@ -218,7 +218,7 @@ exports.lineTo = function(ctx) { return function(y) { return function() { ctx.lineTo(x, y); - return ctx; + return {}; }; }; }; @@ -229,7 +229,7 @@ exports.moveTo = function(ctx) { return function(y) { return function() { ctx.moveTo(x, y); - return ctx; + return {}; }; }; }; @@ -238,7 +238,7 @@ exports.moveTo = function(ctx) { exports.closePath = function(ctx) { return function() { ctx.closePath(); - return ctx; + return {}; }; }; @@ -246,7 +246,7 @@ exports.arc = function(ctx) { return function(a) { return function() { ctx.arc(a.x, a.y, a.r, a.start, a.end); - return ctx; + return {}; }; }; }; @@ -255,7 +255,7 @@ exports.rect = function(ctx) { return function(r) { return function() { ctx.rect(r.x, r.y, r.w, r.h); - return ctx; + return {}; }; }; }; @@ -264,7 +264,7 @@ exports.fillRect = function(ctx) { return function(r) { return function() { ctx.fillRect(r.x, r.y, r.w, r.h); - return ctx; + return {}; }; }; }; @@ -273,7 +273,16 @@ exports.strokeRect = function(ctx) { return function(r) { return function() { ctx.strokeRect(r.x, r.y, r.w, r.h); - return ctx; + return {}; + }; + }; +}; + +exports.clearRect = function(ctx) { + return function(r) { + return function() { + ctx.clearRect(r.x, r.y, r.w, r.h); + return {}; }; }; }; @@ -282,7 +291,7 @@ exports.scale = function(t) { return function(ctx) { return function() { ctx.scale(t.scaleX, t.scaleY); - return ctx; + return {}; }; }; }; @@ -291,7 +300,7 @@ exports.rotate = function(angle) { return function(ctx) { return function() { ctx.rotate(angle); - return ctx; + return {}; }; }; }; @@ -300,7 +309,7 @@ exports.translate = function(t) { return function(ctx) { return function() { ctx.translate(t.translateX, t.translateY); - return ctx; + return {}; }; }; }; @@ -309,16 +318,7 @@ exports.transform = function(t) { return function(ctx) { return function() { ctx.transform(t.m11, t.m12, t.m21, t.m22, t.m31, t.m32); - return ctx; - }; - }; -}; - -exports.clearRect = function(ctx) { - return function(r) { - return function() { - ctx.clearRect(r.x, r.y, r.w, r.h); - return ctx; + return {}; }; }; }; @@ -333,7 +333,7 @@ exports.setTextAlignImpl = function(ctx) { return function(textAlign) { return function() { ctx.textAlign = textAlign; - return ctx; + return {}; } } }; @@ -348,7 +348,7 @@ exports.setFont = function(fontspec) { return function(ctx) { return function() { ctx.font = fontspec; - return ctx; + return {}; }; }; }; @@ -359,7 +359,7 @@ exports.fillText = function(ctx) { return function(y) { return function() { ctx.fillText(text, x, y); - return ctx; + return {}; }; }; }; @@ -372,7 +372,7 @@ exports.strokeText = function(ctx) { return function(y) { return function() { ctx.strokeText(text, x, y); - return ctx; + return {}; }; }; }; @@ -390,14 +390,14 @@ exports.measureText = function(ctx) { exports.save = function(ctx) { return function() { ctx.save(); - return ctx; + return {}; }; }; exports.restore = function(ctx) { return function() { ctx.restore(); - return ctx; + return {}; }; }; @@ -437,7 +437,7 @@ exports.putImageDataFull = function(ctx) { return function(dh) { return function() { ctx.putImageData(image_data, x, y, dx, dy, dw, dh); - return ctx; + return {}; }; }; }; @@ -454,7 +454,7 @@ exports.putImageData = function(ctx) { return function(y) { return function() { ctx.putImageData(image_data, x, y); - return ctx; + return {}; }; }; }; @@ -485,7 +485,7 @@ exports.drawImage = function(ctx) { return function(dy) { return function() { ctx.drawImage(image_source, dx, dy); - return ctx; + return {}; }; }; }; @@ -500,7 +500,7 @@ exports.drawImageScale = function(ctx) { return function(dHeight) { return function() { ctx.drawImage(image_source, dx, dy, dWidth, dHeight); - return ctx; + return {}; }; }; }; @@ -521,7 +521,7 @@ exports.drawImageFull = function(ctx) { return function(dHeight) { return function() { ctx.drawImage(image_source, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight); - return ctx; + return {}; }; }; }; @@ -548,7 +548,7 @@ exports.setPatternFillStyle = function(pattern) { return function(ctx) { return function() { ctx.fillStyle = pattern; - return ctx; + return {}; }; }; }; @@ -584,7 +584,7 @@ exports.setGradientFillStyle = function(gradient) { return function(ctx) { return function() { ctx.fillStyle = gradient; - return ctx; + return {}; }; }; }; @@ -593,7 +593,7 @@ exports.quadraticCurveTo = function(qCurve) { return function(ctx) { return function() { ctx.quadraticCurveTo(qCurve.cpx, qCurve.cpy, qCurve.x, qCurve.y); - return ctx; + return {}; }; }; }; @@ -602,7 +602,7 @@ exports.bezierCurveTo = function(bCurve) { return function(ctx) { return function() { ctx.bezierCurveTo(bCurve.cp1x, bCurve.cp1y, bCurve.cp2x, bCurve.cp2y, bCurve.x, bCurve.y); - return ctx; + return {}; }; }; }; diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index 10f3a0e..644f111 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -200,38 +200,38 @@ setCanvasDimensions d ce = setCanvasHeight d.height ce *> setCanvasWidth d.width foreign import canvasToDataURL :: forall eff. CanvasElement -> Eff (canvas :: CANVAS | eff) String -- | Set the current line width. -foreign import setLineWidth :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +foreign import setLineWidth :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Unit -- | Set the current fill style/color. -foreign import setFillStyle :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +foreign import setFillStyle :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Unit -- | Set the current stroke style/color. -foreign import setStrokeStyle :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +foreign import setStrokeStyle :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Unit -- | Set the current shadow color. -foreign import setShadowColor :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +foreign import setShadowColor :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Unit -- | Set the current shadow blur radius. -foreign import setShadowBlur :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +foreign import setShadowBlur :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Unit -- | Set the current shadow x-offset. -foreign import setShadowOffsetX :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +foreign import setShadowOffsetX :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Unit -- | Set the current shadow y-offset. -foreign import setShadowOffsetY :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +foreign import setShadowOffsetY :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Unit -- | Set the current miter limit. -foreign import setMiterLimit :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +foreign import setMiterLimit :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Unit -- | Enumerates the different types of line cap. data LineCap = Round | Square | Butt derive instance eqLineCap :: Eq LineCap -foreign import setLineCapImpl :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +foreign import setLineCapImpl :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Unit -- | Set the current line cap type. -setLineCap :: forall eff. LineCap -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +setLineCap :: forall eff. LineCap -> Context2D -> Eff (canvas :: CANVAS | eff) Unit setLineCap Round = setLineCapImpl "round" setLineCap Square = setLineCapImpl "square" setLineCap Butt = setLineCapImpl "butt" @@ -241,10 +241,10 @@ setLineCap Butt = setLineCapImpl "butt" -- | Enumerates the different types of line join data LineJoin = BevelJoin | RoundJoin | MiterJoin -foreign import setLineJoinImpl :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +foreign import setLineJoinImpl :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Unit -- | Set the current line join type. -setLineJoin :: forall eff. LineJoin -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +setLineJoin :: forall eff. LineJoin -> Context2D -> Eff (canvas :: CANVAS | eff) Unit setLineJoin BevelJoin = setLineJoinImpl "bevel" setLineJoin RoundJoin = setLineJoinImpl "round" setLineJoin MiterJoin = setLineJoinImpl "miter" @@ -309,10 +309,10 @@ instance showComposite :: Show Composite where show Color = "Color" show Luminosity = "Luminosity" -foreign import setGlobalCompositeOperationImpl :: forall eff. Context2D -> String -> Eff (canvas :: CANVAS | eff) Context2D +foreign import setGlobalCompositeOperationImpl :: forall eff. Context2D -> String -> Eff (canvas :: CANVAS | eff) Unit -- | Set the current composite operation. -setGlobalCompositeOperation :: forall eff. Context2D -> Composite -> Eff (canvas :: CANVAS | eff) Context2D +setGlobalCompositeOperation :: forall eff. Context2D -> Composite -> Eff (canvas :: CANVAS | eff) Unit setGlobalCompositeOperation ctx composite = setGlobalCompositeOperationImpl ctx (toString composite) where toString SourceOver = "source-over" @@ -343,28 +343,28 @@ setGlobalCompositeOperation ctx composite = setGlobalCompositeOperationImpl ctx toString Luminosity = "luminosity" -- | Set the current global alpha level. -foreign import setGlobalAlpha :: forall eff. Context2D -> Number -> Eff (canvas :: CANVAS | eff) Context2D +foreign import setGlobalAlpha :: forall eff. Context2D -> Number -> Eff (canvas :: CANVAS | eff) Unit -- | Begin a path object. -foreign import beginPath :: forall eff. Context2D -> Eff (canvas :: CANVAS | eff) Context2D +foreign import beginPath :: forall eff. Context2D -> Eff (canvas :: CANVAS | eff) Unit -- | Stroke the current object. -foreign import stroke :: forall eff. Context2D -> Eff (canvas :: CANVAS | eff) Context2D +foreign import stroke :: forall eff. Context2D -> Eff (canvas :: CANVAS | eff) Unit -- | Fill the current object. -foreign import fill :: forall eff. Context2D -> Eff (canvas :: CANVAS | eff) Context2D +foreign import fill :: forall eff. Context2D -> Eff (canvas :: CANVAS | eff) Unit -- | Clip to the current object. -foreign import clip :: forall eff. Context2D -> Eff (canvas :: CANVAS | eff) Context2D +foreign import clip :: forall eff. Context2D -> Eff (canvas :: CANVAS | eff) Unit -- | Move the path to the specified coordinates, drawing a line segment. -foreign import lineTo :: forall eff. Context2D -> Number -> Number -> Eff (canvas :: CANVAS | eff) Context2D +foreign import lineTo :: forall eff. Context2D -> Number -> Number -> Eff (canvas :: CANVAS | eff) Unit -- | Move the path to the specified coordinates, without drawing a line segment. -foreign import moveTo :: forall eff. Context2D -> Number -> Number -> Eff (canvas :: CANVAS | eff) Context2D +foreign import moveTo :: forall eff. Context2D -> Number -> Number -> Eff (canvas :: CANVAS | eff) Unit -- | Close the current path. -foreign import closePath :: forall eff. Context2D -> Eff (canvas :: CANVAS | eff) Context2D +foreign import closePath :: forall eff. Context2D -> Eff (canvas :: CANVAS | eff) Unit -- | A convenience function for drawing a stroked path. -- | @@ -416,7 +416,7 @@ type Arc = } -- | Render an arc object. -foreign import arc :: forall eff. Context2D -> Arc -> Eff (canvas :: CANVAS | eff) Context2D +foreign import arc :: forall eff. Context2D -> Arc -> Eff (canvas :: CANVAS | eff) Unit -- | A type representing a rectangle object: -- | @@ -430,16 +430,16 @@ type Rectangle = } -- | Render a rectangle. -foreign import rect :: forall eff. Context2D -> Rectangle -> Eff (canvas :: CANVAS | eff) Context2D +foreign import rect :: forall eff. Context2D -> Rectangle -> Eff (canvas :: CANVAS | eff) Unit -- | Fill a rectangle. -foreign import fillRect :: forall eff. Context2D -> Rectangle -> Eff (canvas :: CANVAS | eff) Context2D +foreign import fillRect :: forall eff. Context2D -> Rectangle -> Eff (canvas :: CANVAS | eff) Unit -- | Stroke a rectangle. -foreign import strokeRect :: forall eff. Context2D -> Rectangle -> Eff (canvas :: CANVAS | eff) Context2D +foreign import strokeRect :: forall eff. Context2D -> Rectangle -> Eff (canvas :: CANVAS | eff) Unit -- | Clear a rectangle. -foreign import clearRect :: forall eff. Context2D -> Rectangle -> Eff (canvas :: CANVAS | eff) Context2D +foreign import clearRect :: forall eff. Context2D -> Rectangle -> Eff (canvas :: CANVAS | eff) Unit -- | An object representing a scaling transform: -- | @@ -450,10 +450,10 @@ type ScaleTransform = } -- | Apply a scaling transform. -foreign import scale :: forall eff. ScaleTransform -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +foreign import scale :: forall eff. ScaleTransform -> Context2D -> Eff (canvas :: CANVAS | eff) Unit -- | Apply a rotation. -foreign import rotate :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +foreign import rotate :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Unit -- | An object representing a translation: -- | @@ -464,7 +464,7 @@ type TranslateTransform = } -- | Apply a translation -foreign import translate :: forall eff. TranslateTransform -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +foreign import translate :: forall eff. TranslateTransform -> Context2D -> Eff (canvas :: CANVAS | eff) Unit -- | An object representing a general transformation as a homogeneous matrix. type Transform = @@ -477,7 +477,7 @@ type Transform = } -- | Apply a general transformation. -foreign import transform :: forall eff. Transform -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +foreign import transform :: forall eff. Transform -> Context2D -> Eff (canvas :: CANVAS | eff) Unit -- | Enumerates types of text alignment. data TextAlign @@ -505,10 +505,10 @@ textAlign ctx = unsafeParseTextAlign <$> textAlignImpl ctx unsafeParseTextAlign align = unsafeThrow $ "invalid TextAlign: " <> align -- ^ dummy to silence compiler warnings -foreign import setTextAlignImpl :: forall eff. Context2D -> String -> (Eff (canvas :: CANVAS | eff) Context2D) +foreign import setTextAlignImpl :: forall eff. Context2D -> String -> Eff (canvas :: CANVAS | eff) Unit -- | Set the current text alignment. -setTextAlign :: forall eff. Context2D -> TextAlign -> Eff (canvas :: CANVAS | eff) Context2D +setTextAlign :: forall eff. Context2D -> TextAlign -> Eff (canvas :: CANVAS | eff) Unit setTextAlign ctx textalign = setTextAlignImpl ctx (toString textalign) where @@ -527,22 +527,22 @@ type TextMetrics = { width :: Number } foreign import font :: forall eff. Context2D -> Eff (canvas :: CANVAS | eff) String -- | Set the current font. -foreign import setFont :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +foreign import setFont :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Unit -- | Fill some text. -foreign import fillText :: forall eff. Context2D -> String -> Number -> Number -> Eff (canvas :: CANVAS | eff) Context2D +foreign import fillText :: forall eff. Context2D -> String -> Number -> Number -> Eff (canvas :: CANVAS | eff) Unit -- | Stroke some text. -foreign import strokeText :: forall eff. Context2D -> String -> Number -> Number -> Eff (canvas :: CANVAS | eff) Context2D +foreign import strokeText :: forall eff. Context2D -> String -> Number -> Number -> Eff (canvas :: CANVAS | eff) Unit -- | Measure some text. foreign import measureText :: forall eff. Context2D -> String -> Eff (canvas :: CANVAS | eff) TextMetrics -- | Save the current context. -foreign import save :: forall eff. Context2D -> Eff (canvas :: CANVAS | eff) Context2D +foreign import save :: forall eff. Context2D -> Eff (canvas :: CANVAS | eff) Unit -- | Restore the previous context. -foreign import restore :: forall eff. Context2D -> Eff (canvas :: CANVAS | eff) Context2D +foreign import restore :: forall eff. Context2D -> Eff (canvas :: CANVAS | eff) Unit -- | A convenience function: run the action, preserving the existing context. -- | @@ -564,10 +564,10 @@ withContext ctx action = do foreign import getImageData :: forall eff. Context2D -> Number -> Number -> Number -> Number -> Eff (canvas :: CANVAS | eff) ImageData -- | Set image data for a portion of the canvas. -foreign import putImageDataFull :: forall eff. Context2D -> ImageData -> Number -> Number -> Number -> Number -> Number -> Number -> Eff (canvas :: CANVAS | eff) Context2D +foreign import putImageDataFull :: forall eff. Context2D -> ImageData -> Number -> Number -> Number -> Number -> Number -> Number -> Eff (canvas :: CANVAS | eff) Unit -- | Set image data for a portion of the canvas. -foreign import putImageData :: forall eff. Context2D -> ImageData -> Number -> Number -> Eff (canvas :: CANVAS | eff) Context2D +foreign import putImageData :: forall eff. Context2D -> ImageData -> Number -> Number -> Eff (canvas :: CANVAS | eff) Unit -- | Create an image data object. foreign import createImageData :: forall eff. Context2D -> Number -> Number -> Eff (canvas :: CANVAS | eff) ImageData @@ -584,11 +584,11 @@ foreign import imageDataHeight :: ImageData -> Int -- | Get the underlying buffer from an `ImageData` object. foreign import imageDataBuffer :: ImageData -> Uint8ClampedArray -foreign import drawImage :: forall eff. Context2D -> CanvasImageSource -> Number -> Number -> Eff (canvas :: CANVAS | eff) Context2D +foreign import drawImage :: forall eff. Context2D -> CanvasImageSource -> Number -> Number -> Eff (canvas :: CANVAS | eff) Unit -foreign import drawImageScale :: forall eff. Context2D -> CanvasImageSource -> Number -> Number -> Number -> Number -> Eff (canvas :: CANVAS | eff) Context2D +foreign import drawImageScale :: forall eff. Context2D -> CanvasImageSource -> Number -> Number -> Number -> Number -> Eff (canvas :: CANVAS | eff) Unit -foreign import drawImageFull :: forall eff. Context2D -> CanvasImageSource -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Eff (canvas :: CANVAS | eff) Context2D +foreign import drawImageFull :: forall eff. Context2D -> CanvasImageSource -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Eff (canvas :: CANVAS | eff) Unit -- | Enumerates the different types of pattern repetitions. data PatternRepeat = Repeat | RepeatX | RepeatY | NoRepeat @@ -611,7 +611,7 @@ createPattern img repeat = createPatternImpl img (toString repeat) toString NoRepeat = "no-repeat" -- | Set the Context2D fillstyle to the CanvasPattern. -foreign import setPatternFillStyle :: forall eff. CanvasPattern -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +foreign import setPatternFillStyle :: forall eff. CanvasPattern -> Context2D -> Eff (canvas :: CANVAS | eff) Unit -- | A type representing a linear gradient. -- | - Starting point coordinates: (`x0`, `y0`) @@ -649,7 +649,7 @@ foreign import createRadialGradient :: forall eff. RadialGradient -> Context2D - foreign import addColorStop :: forall eff. Number -> String -> CanvasGradient -> Eff (canvas :: CANVAS | eff) CanvasGradient -- | Set the Context2D fillstyle to the CanvasGradient. -foreign import setGradientFillStyle :: forall eff. CanvasGradient -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +foreign import setGradientFillStyle :: forall eff. CanvasGradient -> Context2D -> Eff (canvas :: CANVAS | eff) Unit -- | A type representing a quadratic Bézier curve. -- | - Bézier control point: (`cpx`, `cpy`) @@ -663,7 +663,7 @@ type QuadraticCurve = } -- | Draw a quadratic Bézier curve. -foreign import quadraticCurveTo :: forall eff. QuadraticCurve -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +foreign import quadraticCurveTo :: forall eff. QuadraticCurve -> Context2D -> Eff (canvas :: CANVAS | eff) Unit -- | A type representing a cubic Bézier curve. -- | - First Bézier control point: (`cp1x`, `cp1y`) @@ -680,4 +680,4 @@ type BezierCurve = } -- | Draw a cubic Bézier curve. -foreign import bezierCurveTo :: forall eff. BezierCurve -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +foreign import bezierCurveTo :: forall eff. BezierCurve -> Context2D -> Eff (canvas :: CANVAS | eff) Unit From 42f0732cccafada0ab6993ad993824b47ca1e6be Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 25 Jun 2017 17:49:38 -0700 Subject: [PATCH 03/35] generate docs --- generated-docs/Graphics/Canvas.md | 92 +++++++++++++++---------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/generated-docs/Graphics/Canvas.md b/generated-docs/Graphics/Canvas.md index f1381f0..455b5ff 100644 --- a/generated-docs/Graphics/Canvas.md +++ b/generated-docs/Graphics/Canvas.md @@ -108,7 +108,7 @@ Get the canvas height in pixels. #### `setCanvasWidth` ``` purescript -setCanvasWidth :: forall eff. Number -> CanvasElement -> Eff (canvas :: CANVAS | eff) CanvasElement +setCanvasWidth :: forall eff. Number -> CanvasElement -> Eff (canvas :: CANVAS | eff) Unit ``` Set the canvas width in pixels. @@ -116,7 +116,7 @@ Set the canvas width in pixels. #### `setCanvasHeight` ``` purescript -setCanvasHeight :: forall eff. Number -> CanvasElement -> Eff (canvas :: CANVAS | eff) CanvasElement +setCanvasHeight :: forall eff. Number -> CanvasElement -> Eff (canvas :: CANVAS | eff) Unit ``` Set the canvas height in pixels. @@ -140,7 +140,7 @@ Get the canvas dimensions in pixels. #### `setCanvasDimensions` ``` purescript -setCanvasDimensions :: forall eff. Dimensions -> CanvasElement -> Eff (canvas :: CANVAS | eff) CanvasElement +setCanvasDimensions :: forall eff. Dimensions -> CanvasElement -> Eff (canvas :: CANVAS | eff) Unit ``` Set the canvas dimensions in pixels. @@ -156,7 +156,7 @@ Create a data URL for the current canvas contents #### `setLineWidth` ``` purescript -setLineWidth :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +setLineWidth :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Unit ``` Set the current line width. @@ -164,7 +164,7 @@ Set the current line width. #### `setFillStyle` ``` purescript -setFillStyle :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +setFillStyle :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Unit ``` Set the current fill style/color. @@ -172,7 +172,7 @@ Set the current fill style/color. #### `setStrokeStyle` ``` purescript -setStrokeStyle :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +setStrokeStyle :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Unit ``` Set the current stroke style/color. @@ -180,7 +180,7 @@ Set the current stroke style/color. #### `setShadowColor` ``` purescript -setShadowColor :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +setShadowColor :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Unit ``` Set the current shadow color. @@ -188,7 +188,7 @@ Set the current shadow color. #### `setShadowBlur` ``` purescript -setShadowBlur :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +setShadowBlur :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Unit ``` Set the current shadow blur radius. @@ -196,7 +196,7 @@ Set the current shadow blur radius. #### `setShadowOffsetX` ``` purescript -setShadowOffsetX :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +setShadowOffsetX :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Unit ``` Set the current shadow x-offset. @@ -204,7 +204,7 @@ Set the current shadow x-offset. #### `setShadowOffsetY` ``` purescript -setShadowOffsetY :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +setShadowOffsetY :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Unit ``` Set the current shadow y-offset. @@ -212,7 +212,7 @@ Set the current shadow y-offset. #### `setMiterLimit` ``` purescript -setMiterLimit :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +setMiterLimit :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Unit ``` Set the current miter limit. @@ -231,7 +231,7 @@ Enumerates the different types of line cap. #### `setLineCap` ``` purescript -setLineCap :: forall eff. LineCap -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +setLineCap :: forall eff. LineCap -> Context2D -> Eff (canvas :: CANVAS | eff) Unit ``` Set the current line cap type. @@ -250,7 +250,7 @@ Enumerates the different types of line join #### `setLineJoin` ``` purescript -setLineJoin :: forall eff. LineJoin -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +setLineJoin :: forall eff. LineJoin -> Context2D -> Eff (canvas :: CANVAS | eff) Unit ``` Set the current line join type. @@ -297,7 +297,7 @@ Show Composite #### `setGlobalCompositeOperation` ``` purescript -setGlobalCompositeOperation :: forall eff. Context2D -> Composite -> Eff (canvas :: CANVAS | eff) Context2D +setGlobalCompositeOperation :: forall eff. Context2D -> Composite -> Eff (canvas :: CANVAS | eff) Unit ``` Set the current composite operation. @@ -305,7 +305,7 @@ Set the current composite operation. #### `setGlobalAlpha` ``` purescript -setGlobalAlpha :: forall eff. Context2D -> Number -> Eff (canvas :: CANVAS | eff) Context2D +setGlobalAlpha :: forall eff. Context2D -> Number -> Eff (canvas :: CANVAS | eff) Unit ``` Set the current global alpha level. @@ -313,7 +313,7 @@ Set the current global alpha level. #### `beginPath` ``` purescript -beginPath :: forall eff. Context2D -> Eff (canvas :: CANVAS | eff) Context2D +beginPath :: forall eff. Context2D -> Eff (canvas :: CANVAS | eff) Unit ``` Begin a path object. @@ -321,7 +321,7 @@ Begin a path object. #### `stroke` ``` purescript -stroke :: forall eff. Context2D -> Eff (canvas :: CANVAS | eff) Context2D +stroke :: forall eff. Context2D -> Eff (canvas :: CANVAS | eff) Unit ``` Stroke the current object. @@ -329,7 +329,7 @@ Stroke the current object. #### `fill` ``` purescript -fill :: forall eff. Context2D -> Eff (canvas :: CANVAS | eff) Context2D +fill :: forall eff. Context2D -> Eff (canvas :: CANVAS | eff) Unit ``` Fill the current object. @@ -337,7 +337,7 @@ Fill the current object. #### `clip` ``` purescript -clip :: forall eff. Context2D -> Eff (canvas :: CANVAS | eff) Context2D +clip :: forall eff. Context2D -> Eff (canvas :: CANVAS | eff) Unit ``` Clip to the current object. @@ -345,7 +345,7 @@ Clip to the current object. #### `lineTo` ``` purescript -lineTo :: forall eff. Context2D -> Number -> Number -> Eff (canvas :: CANVAS | eff) Context2D +lineTo :: forall eff. Context2D -> Number -> Number -> Eff (canvas :: CANVAS | eff) Unit ``` Move the path to the specified coordinates, drawing a line segment. @@ -353,7 +353,7 @@ Move the path to the specified coordinates, drawing a line segment. #### `moveTo` ``` purescript -moveTo :: forall eff. Context2D -> Number -> Number -> Eff (canvas :: CANVAS | eff) Context2D +moveTo :: forall eff. Context2D -> Number -> Number -> Eff (canvas :: CANVAS | eff) Unit ``` Move the path to the specified coordinates, without drawing a line segment. @@ -361,7 +361,7 @@ Move the path to the specified coordinates, without drawing a line segment. #### `closePath` ``` purescript -closePath :: forall eff. Context2D -> Eff (canvas :: CANVAS | eff) Context2D +closePath :: forall eff. Context2D -> Eff (canvas :: CANVAS | eff) Unit ``` Close the current path. @@ -417,7 +417,7 @@ A type representing an arc object: #### `arc` ``` purescript -arc :: forall eff. Context2D -> Arc -> Eff (canvas :: CANVAS | eff) Context2D +arc :: forall eff. Context2D -> Arc -> Eff (canvas :: CANVAS | eff) Unit ``` Render an arc object. @@ -436,7 +436,7 @@ A type representing a rectangle object: #### `rect` ``` purescript -rect :: forall eff. Context2D -> Rectangle -> Eff (canvas :: CANVAS | eff) Context2D +rect :: forall eff. Context2D -> Rectangle -> Eff (canvas :: CANVAS | eff) Unit ``` Render a rectangle. @@ -444,7 +444,7 @@ Render a rectangle. #### `fillRect` ``` purescript -fillRect :: forall eff. Context2D -> Rectangle -> Eff (canvas :: CANVAS | eff) Context2D +fillRect :: forall eff. Context2D -> Rectangle -> Eff (canvas :: CANVAS | eff) Unit ``` Fill a rectangle. @@ -452,7 +452,7 @@ Fill a rectangle. #### `strokeRect` ``` purescript -strokeRect :: forall eff. Context2D -> Rectangle -> Eff (canvas :: CANVAS | eff) Context2D +strokeRect :: forall eff. Context2D -> Rectangle -> Eff (canvas :: CANVAS | eff) Unit ``` Stroke a rectangle. @@ -460,7 +460,7 @@ Stroke a rectangle. #### `clearRect` ``` purescript -clearRect :: forall eff. Context2D -> Rectangle -> Eff (canvas :: CANVAS | eff) Context2D +clearRect :: forall eff. Context2D -> Rectangle -> Eff (canvas :: CANVAS | eff) Unit ``` Clear a rectangle. @@ -478,7 +478,7 @@ An object representing a scaling transform: #### `scale` ``` purescript -scale :: forall eff. ScaleTransform -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +scale :: forall eff. ScaleTransform -> Context2D -> Eff (canvas :: CANVAS | eff) Unit ``` Apply a scaling transform. @@ -486,7 +486,7 @@ Apply a scaling transform. #### `rotate` ``` purescript -rotate :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +rotate :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Unit ``` Apply a rotation. @@ -504,7 +504,7 @@ An object representing a translation: #### `translate` ``` purescript -translate :: forall eff. TranslateTransform -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +translate :: forall eff. TranslateTransform -> Context2D -> Eff (canvas :: CANVAS | eff) Unit ``` Apply a translation @@ -520,7 +520,7 @@ An object representing a general transformation as a homogeneous matrix. #### `transform` ``` purescript -transform :: forall eff. Transform -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +transform :: forall eff. Transform -> Context2D -> Eff (canvas :: CANVAS | eff) Unit ``` Apply a general transformation. @@ -554,7 +554,7 @@ Get the current text alignment. #### `setTextAlign` ``` purescript -setTextAlign :: forall eff. Context2D -> TextAlign -> Eff (canvas :: CANVAS | eff) Context2D +setTextAlign :: forall eff. Context2D -> TextAlign -> Eff (canvas :: CANVAS | eff) Unit ``` Set the current text alignment. @@ -580,7 +580,7 @@ Get the current font. #### `setFont` ``` purescript -setFont :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +setFont :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Unit ``` Set the current font. @@ -588,7 +588,7 @@ Set the current font. #### `fillText` ``` purescript -fillText :: forall eff. Context2D -> String -> Number -> Number -> Eff (canvas :: CANVAS | eff) Context2D +fillText :: forall eff. Context2D -> String -> Number -> Number -> Eff (canvas :: CANVAS | eff) Unit ``` Fill some text. @@ -596,7 +596,7 @@ Fill some text. #### `strokeText` ``` purescript -strokeText :: forall eff. Context2D -> String -> Number -> Number -> Eff (canvas :: CANVAS | eff) Context2D +strokeText :: forall eff. Context2D -> String -> Number -> Number -> Eff (canvas :: CANVAS | eff) Unit ``` Stroke some text. @@ -612,7 +612,7 @@ Measure some text. #### `save` ``` purescript -save :: forall eff. Context2D -> Eff (canvas :: CANVAS | eff) Context2D +save :: forall eff. Context2D -> Eff (canvas :: CANVAS | eff) Unit ``` Save the current context. @@ -620,7 +620,7 @@ Save the current context. #### `restore` ``` purescript -restore :: forall eff. Context2D -> Eff (canvas :: CANVAS | eff) Context2D +restore :: forall eff. Context2D -> Eff (canvas :: CANVAS | eff) Unit ``` Restore the previous context. @@ -652,7 +652,7 @@ Get image data for a portion of the canvas. #### `putImageDataFull` ``` purescript -putImageDataFull :: forall eff. Context2D -> ImageData -> Number -> Number -> Number -> Number -> Number -> Number -> Eff (canvas :: CANVAS | eff) Context2D +putImageDataFull :: forall eff. Context2D -> ImageData -> Number -> Number -> Number -> Number -> Number -> Number -> Eff (canvas :: CANVAS | eff) Unit ``` Set image data for a portion of the canvas. @@ -660,7 +660,7 @@ Set image data for a portion of the canvas. #### `putImageData` ``` purescript -putImageData :: forall eff. Context2D -> ImageData -> Number -> Number -> Eff (canvas :: CANVAS | eff) Context2D +putImageData :: forall eff. Context2D -> ImageData -> Number -> Number -> Eff (canvas :: CANVAS | eff) Unit ``` Set image data for a portion of the canvas. @@ -708,19 +708,19 @@ Get the underlying buffer from an `ImageData` object. #### `drawImage` ``` purescript -drawImage :: forall eff. Context2D -> CanvasImageSource -> Number -> Number -> Eff (canvas :: CANVAS | eff) Context2D +drawImage :: forall eff. Context2D -> CanvasImageSource -> Number -> Number -> Eff (canvas :: CANVAS | eff) Unit ``` #### `drawImageScale` ``` purescript -drawImageScale :: forall eff. Context2D -> CanvasImageSource -> Number -> Number -> Number -> Number -> Eff (canvas :: CANVAS | eff) Context2D +drawImageScale :: forall eff. Context2D -> CanvasImageSource -> Number -> Number -> Number -> Number -> Eff (canvas :: CANVAS | eff) Unit ``` #### `drawImageFull` ``` purescript -drawImageFull :: forall eff. Context2D -> CanvasImageSource -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Eff (canvas :: CANVAS | eff) Context2D +drawImageFull :: forall eff. Context2D -> CanvasImageSource -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Eff (canvas :: CANVAS | eff) Unit ``` #### `PatternRepeat` @@ -751,7 +751,7 @@ Create a new canvas pattern (repeatable image). #### `setPatternFillStyle` ``` purescript -setPatternFillStyle :: forall eff. CanvasPattern -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +setPatternFillStyle :: forall eff. CanvasPattern -> Context2D -> Eff (canvas :: CANVAS | eff) Unit ``` Set the Context2D fillstyle to the CanvasPattern. @@ -805,7 +805,7 @@ Add a single color stop to a CanvasGradient. #### `setGradientFillStyle` ``` purescript -setGradientFillStyle :: forall eff. CanvasGradient -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +setGradientFillStyle :: forall eff. CanvasGradient -> Context2D -> Eff (canvas :: CANVAS | eff) Unit ``` Set the Context2D fillstyle to the CanvasGradient. @@ -823,7 +823,7 @@ A type representing a quadratic Bézier curve. #### `quadraticCurveTo` ``` purescript -quadraticCurveTo :: forall eff. QuadraticCurve -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +quadraticCurveTo :: forall eff. QuadraticCurve -> Context2D -> Eff (canvas :: CANVAS | eff) Unit ``` Draw a quadratic Bézier curve. @@ -842,7 +842,7 @@ A type representing a cubic Bézier curve. #### `bezierCurveTo` ``` purescript -bezierCurveTo :: forall eff. BezierCurve -> Context2D -> Eff (canvas :: CANVAS | eff) Context2D +bezierCurveTo :: forall eff. BezierCurve -> Context2D -> Eff (canvas :: CANVAS | eff) Unit ``` Draw a cubic Bézier curve. From 8e939e68c72e5aa07459a5a8b5236ae6c3d460f6 Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 3 Dec 2017 12:23:23 -0800 Subject: [PATCH 04/35] context first in setLineWidth --- src/Graphics/Canvas.js | 4 ++-- src/Graphics/Canvas.purs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index 3e162ec..a0d2b7b 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -77,8 +77,8 @@ exports.canvasToDataURL = function(canvas) { }; }; -exports.setLineWidth = function(width) { - return function(ctx) { +exports.setLineWidth = function(ctx) { + return function(width) { return function() { ctx.lineWidth = width; return {}; diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index 6230c8e..69e3d94 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -71,7 +71,7 @@ module Graphics.Canvas , rotate , translate , transform - , setTransform + , setTransform , textAlign , setTextAlign @@ -201,7 +201,7 @@ setCanvasDimensions d ce = setCanvasHeight d.height ce *> setCanvasWidth d.width foreign import canvasToDataURL :: forall eff. CanvasElement -> Eff (canvas :: CANVAS | eff) String -- | Set the current line width. -foreign import setLineWidth :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +foreign import setLineWidth :: forall eff. Context2D -> Number -> Eff (canvas :: CANVAS | eff) Unit -- | Set the current fill style/color. foreign import setFillStyle :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Unit From c7db5e960ff19798b97ac2d3b2cc61d00e23e09a Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 3 Dec 2017 12:24:36 -0800 Subject: [PATCH 05/35] context first in setFillStyle --- src/Graphics/Canvas.js | 4 ++-- src/Graphics/Canvas.purs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index a0d2b7b..f9c2557 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -86,8 +86,8 @@ exports.setLineWidth = function(ctx) { }; }; -exports.setFillStyle = function(style) { - return function(ctx) { +exports.setFillStyle = function(ctx) { + return function(style) { return function() { ctx.fillStyle = style; return {}; diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index 69e3d94..9b3de17 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -204,7 +204,7 @@ foreign import canvasToDataURL :: forall eff. CanvasElement -> Eff (canvas :: CA foreign import setLineWidth :: forall eff. Context2D -> Number -> Eff (canvas :: CANVAS | eff) Unit -- | Set the current fill style/color. -foreign import setFillStyle :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +foreign import setFillStyle :: forall eff. Context2D -> String -> Eff (canvas :: CANVAS | eff) Unit -- | Set the current stroke style/color. foreign import setStrokeStyle :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Unit From be177838ddde971252869da7b6f947516096ddc3 Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 3 Dec 2017 12:26:23 -0800 Subject: [PATCH 06/35] context first in setStrokeStyle --- src/Graphics/Canvas.js | 4 ++-- src/Graphics/Canvas.purs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index f9c2557..b07064e 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -95,8 +95,8 @@ exports.setFillStyle = function(ctx) { }; }; -exports.setStrokeStyle = function(style) { - return function(ctx) { +exports.setStrokeStyle = function(ctx) { + return function(style) { return function() { ctx.strokeStyle = style; return {}; diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index 9b3de17..c297028 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -207,7 +207,7 @@ foreign import setLineWidth :: forall eff. Context2D -> Number -> Eff (canvas :: foreign import setFillStyle :: forall eff. Context2D -> String -> Eff (canvas :: CANVAS | eff) Unit -- | Set the current stroke style/color. -foreign import setStrokeStyle :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +foreign import setStrokeStyle :: forall eff. Context2D -> String -> Eff (canvas :: CANVAS | eff) Unit -- | Set the current shadow color. foreign import setShadowColor :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Unit From ac6d42abe0efe91a949c0874ababb32930a3dba1 Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 3 Dec 2017 12:27:20 -0800 Subject: [PATCH 07/35] context first in setShadowColor --- src/Graphics/Canvas.js | 4 ++-- src/Graphics/Canvas.purs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index b07064e..da38893 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -104,8 +104,8 @@ exports.setStrokeStyle = function(ctx) { }; }; -exports.setShadowColor = function(color) { - return function(ctx) { +exports.setShadowColor = function(ctx) { + return function(color) { return function() { ctx.shadowColor = color; return {}; diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index c297028..4635ee6 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -210,7 +210,7 @@ foreign import setFillStyle :: forall eff. Context2D -> String -> Eff (canvas :: foreign import setStrokeStyle :: forall eff. Context2D -> String -> Eff (canvas :: CANVAS | eff) Unit -- | Set the current shadow color. -foreign import setShadowColor :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +foreign import setShadowColor :: forall eff. Context2D -> String -> Eff (canvas :: CANVAS | eff) Unit -- | Set the current shadow blur radius. foreign import setShadowBlur :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Unit From 1657257ba8a0b96bfd744ebf0be56916a758e1d8 Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 3 Dec 2017 12:28:38 -0800 Subject: [PATCH 08/35] context first in setShadowBlur --- src/Graphics/Canvas.js | 4 ++-- src/Graphics/Canvas.purs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index da38893..80a83c3 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -113,8 +113,8 @@ exports.setShadowColor = function(ctx) { }; }; -exports.setShadowBlur = function(blur) { - return function(ctx) { +exports.setShadowBlur = function(ctx) { + return function(blur) { return function() { ctx.shadowBlur = blur; return {}; diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index 4635ee6..a55196d 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -213,7 +213,7 @@ foreign import setStrokeStyle :: forall eff. Context2D -> String -> Eff (canvas foreign import setShadowColor :: forall eff. Context2D -> String -> Eff (canvas :: CANVAS | eff) Unit -- | Set the current shadow blur radius. -foreign import setShadowBlur :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +foreign import setShadowBlur :: forall eff. Context2D -> Number -> Eff (canvas :: CANVAS | eff) Unit -- | Set the current shadow x-offset. foreign import setShadowOffsetX :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Unit From 9b2283cace47f2e99395783025fd2c9f89f3d457 Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 3 Dec 2017 12:29:28 -0800 Subject: [PATCH 09/35] context first in setShadowOffsetX --- src/Graphics/Canvas.js | 4 ++-- src/Graphics/Canvas.purs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index 80a83c3..00a103a 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -122,8 +122,8 @@ exports.setShadowBlur = function(ctx) { }; }; -exports.setShadowOffsetX = function(offsetX) { - return function(ctx) { +exports.setShadowOffsetX = function(ctx) { + return function(offsetX) { return function() { ctx.shadowOffsetX = offsetX; return {}; diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index a55196d..ebd444e 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -216,7 +216,7 @@ foreign import setShadowColor :: forall eff. Context2D -> String -> Eff (canvas foreign import setShadowBlur :: forall eff. Context2D -> Number -> Eff (canvas :: CANVAS | eff) Unit -- | Set the current shadow x-offset. -foreign import setShadowOffsetX :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +foreign import setShadowOffsetX :: forall eff. Context2D -> Number -> Eff (canvas :: CANVAS | eff) Unit -- | Set the current shadow y-offset. foreign import setShadowOffsetY :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Unit From 18488af6a51c80332be9c367f1527c5b7b05b3b9 Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 3 Dec 2017 12:30:29 -0800 Subject: [PATCH 10/35] context first in setShadowOffsetY --- src/Graphics/Canvas.js | 4 ++-- src/Graphics/Canvas.purs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index 00a103a..c21a772 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -131,8 +131,8 @@ exports.setShadowOffsetX = function(ctx) { }; }; -exports.setShadowOffsetY = function(offsetY) { - return function(ctx) { +exports.setShadowOffsetY = function(ctx) { + return function(offsetY) { return function() { ctx.shadowOffsetY = offsetY; return {}; diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index ebd444e..9b562d6 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -219,7 +219,7 @@ foreign import setShadowBlur :: forall eff. Context2D -> Number -> Eff (canvas : foreign import setShadowOffsetX :: forall eff. Context2D -> Number -> Eff (canvas :: CANVAS | eff) Unit -- | Set the current shadow y-offset. -foreign import setShadowOffsetY :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +foreign import setShadowOffsetY :: forall eff. Context2D -> Number -> Eff (canvas :: CANVAS | eff) Unit -- | Set the current miter limit. foreign import setMiterLimit :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Unit From e115cb83fe55f053c3b4fd2195e944b6ebc5f1e8 Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 3 Dec 2017 12:31:40 -0800 Subject: [PATCH 11/35] context first in setMiterLimit --- src/Graphics/Canvas.js | 4 ++-- src/Graphics/Canvas.purs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index c21a772..0c9bfcb 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -140,8 +140,8 @@ exports.setShadowOffsetY = function(ctx) { }; }; -exports.setMiterLimit = function(limit) { - return function(ctx) { +exports.setMiterLimit = function(ctx) { + return function(limit) { return function() { ctx.miterLimit = limit; return {}; diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index 9b562d6..c65cc08 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -222,7 +222,7 @@ foreign import setShadowOffsetX :: forall eff. Context2D -> Number -> Eff (canva foreign import setShadowOffsetY :: forall eff. Context2D -> Number -> Eff (canvas :: CANVAS | eff) Unit -- | Set the current miter limit. -foreign import setMiterLimit :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +foreign import setMiterLimit :: forall eff. Context2D -> Number -> Eff (canvas :: CANVAS | eff) Unit -- | Enumerates the different types of line cap. data LineCap = Round | Square | Butt From 4264e95c8ada56342b51535df56731471bb4cba8 Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 3 Dec 2017 12:39:03 -0800 Subject: [PATCH 12/35] context first in setLineCap --- src/Graphics/Canvas.js | 4 ++-- src/Graphics/Canvas.purs | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index 0c9bfcb..3eba4c4 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -149,8 +149,8 @@ exports.setMiterLimit = function(ctx) { }; }; -exports.setLineCapImpl = function(cap) { - return function(ctx) { +exports.setLineCapImpl = function(ctx) { + return function(cap) { return function() { ctx.lineCap = cap; return {}; diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index c65cc08..27fead1 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -229,13 +229,13 @@ data LineCap = Round | Square | Butt derive instance eqLineCap :: Eq LineCap -foreign import setLineCapImpl :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +foreign import setLineCapImpl :: forall eff. Context2D -> String -> Eff (canvas :: CANVAS | eff) Unit -- | Set the current line cap type. -setLineCap :: forall eff. LineCap -> Context2D -> Eff (canvas :: CANVAS | eff) Unit -setLineCap Round = setLineCapImpl "round" -setLineCap Square = setLineCapImpl "square" -setLineCap Butt = setLineCapImpl "butt" +setLineCap :: forall eff. Context2D -> LineCap -> Eff (canvas :: CANVAS | eff) Unit +setLineCap context Round = setLineCapImpl context "round" +setLineCap context Square = setLineCapImpl context "square" +setLineCap context Butt = setLineCapImpl context "butt" -- Note that we can't re-use `Round` from LineCap, so I've added `Join` to all of these From d8faa61331804f3a83cc89288c3f5fb10e198542 Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 3 Dec 2017 12:41:56 -0800 Subject: [PATCH 13/35] context first in setLineJoin --- src/Graphics/Canvas.js | 4 ++-- src/Graphics/Canvas.purs | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index 3eba4c4..1ac11ab 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -158,8 +158,8 @@ exports.setLineCapImpl = function(ctx) { }; }; -exports.setLineJoinImpl = function(join) { - return function(ctx) { +exports.setLineJoinImpl = function(ctx) { + return function(join) { return function() { ctx.lineJoin = join; return {}; diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index 27fead1..f7ad1b8 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -242,13 +242,13 @@ setLineCap context Butt = setLineCapImpl context "butt" -- | Enumerates the different types of line join data LineJoin = BevelJoin | RoundJoin | MiterJoin -foreign import setLineJoinImpl :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +foreign import setLineJoinImpl :: forall eff. Context2D -> String -> Eff (canvas :: CANVAS | eff) Unit -- | Set the current line join type. -setLineJoin :: forall eff. LineJoin -> Context2D -> Eff (canvas :: CANVAS | eff) Unit -setLineJoin BevelJoin = setLineJoinImpl "bevel" -setLineJoin RoundJoin = setLineJoinImpl "round" -setLineJoin MiterJoin = setLineJoinImpl "miter" +setLineJoin :: forall eff. Context2D -> LineJoin -> Eff (canvas :: CANVAS | eff) Unit +setLineJoin context BevelJoin = setLineJoinImpl context "bevel" +setLineJoin context RoundJoin = setLineJoinImpl context "round" +setLineJoin context MiterJoin = setLineJoinImpl context "miter" -- | Enumerates the different types of composite operations and blend modes. data Composite From 90dd6bcbd2a7f239ddf2823d55fbe582812964ab Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 3 Dec 2017 12:44:24 -0800 Subject: [PATCH 14/35] context first in scale --- src/Graphics/Canvas.js | 4 ++-- src/Graphics/Canvas.purs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index 1ac11ab..a1479f4 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -287,8 +287,8 @@ exports.clearRect = function(ctx) { }; }; -exports.scale = function(t) { - return function(ctx) { +exports.scale = function(ctx) { + return function(t) { return function() { ctx.scale(t.scaleX, t.scaleY); return {}; diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index f7ad1b8..e8b2e78 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -451,7 +451,7 @@ type ScaleTransform = } -- | Apply a scaling transform. -foreign import scale :: forall eff. ScaleTransform -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +foreign import scale :: forall eff. Context2D -> ScaleTransform -> Eff (canvas :: CANVAS | eff) Unit -- | Apply a rotation. foreign import rotate :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Unit From 60ab29e1523a54aa7037b581349d95bc52923439 Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 3 Dec 2017 12:45:14 -0800 Subject: [PATCH 15/35] context first in rotate --- src/Graphics/Canvas.js | 4 ++-- src/Graphics/Canvas.purs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index a1479f4..6dd1940 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -296,8 +296,8 @@ exports.scale = function(ctx) { }; }; -exports.rotate = function(angle) { - return function(ctx) { +exports.rotate = function(ctx) { + return function(angle) { return function() { ctx.rotate(angle); return {}; diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index e8b2e78..b30ecf9 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -454,7 +454,7 @@ type ScaleTransform = foreign import scale :: forall eff. Context2D -> ScaleTransform -> Eff (canvas :: CANVAS | eff) Unit -- | Apply a rotation. -foreign import rotate :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +foreign import rotate :: forall eff. Context2D -> Number -> Eff (canvas :: CANVAS | eff) Unit -- | An object representing a translation: -- | From 700e0f944c41793020a49a7fefdeb5c90edbd409 Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 3 Dec 2017 12:46:22 -0800 Subject: [PATCH 16/35] context first in translate --- src/Graphics/Canvas.js | 4 ++-- src/Graphics/Canvas.purs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index 6dd1940..a7e6054 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -305,8 +305,8 @@ exports.rotate = function(ctx) { }; }; -exports.translate = function(t) { - return function(ctx) { +exports.translate = function(ctx) { + return function(t) { return function() { ctx.translate(t.translateX, t.translateY); return {}; diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index b30ecf9..036b227 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -465,7 +465,7 @@ type TranslateTransform = } -- | Apply a translation -foreign import translate :: forall eff. TranslateTransform -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +foreign import translate :: forall eff. Context2D -> TranslateTransform -> Eff (canvas :: CANVAS | eff) Unit -- | An object representing a general transformation as a homogeneous matrix. type Transform = From bf26aed8d973165ce61d74f10a3a7ec3fe7eb4f4 Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 3 Dec 2017 12:47:36 -0800 Subject: [PATCH 17/35] context first in transform --- src/Graphics/Canvas.js | 4 ++-- src/Graphics/Canvas.purs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index a7e6054..8a68762 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -314,8 +314,8 @@ exports.translate = function(ctx) { }; }; -exports.transform = function(t) { - return function(ctx) { +exports.transform = function(ctx) { + return function(t) { return function() { ctx.transform(t.m11, t.m12, t.m21, t.m22, t.m31, t.m32); return {}; diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index 036b227..54a4827 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -478,7 +478,7 @@ type Transform = } -- | Apply a general transformation to the current transformation matrix -foreign import transform :: forall eff. Transform -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +foreign import transform :: forall eff. Context2D -> Transform -> Eff (canvas :: CANVAS | eff) Unit -- | Set the transformation matrix foreign import setTransform :: forall eff. Transform -> Context2D -> Eff (canvas :: CANVAS | eff) Unit From 13c4b980c9565e6dfc7e313af4f1e9d7f1905fff Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 3 Dec 2017 12:48:22 -0800 Subject: [PATCH 18/35] context first in setTransform --- src/Graphics/Canvas.js | 4 ++-- src/Graphics/Canvas.purs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index 8a68762..9e849f5 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -323,8 +323,8 @@ exports.transform = function(ctx) { }; }; -exports.setTransform = function(t) { - return function(ctx) { +exports.setTransform = function(ctx) { + return function(t) { return function() { ctx.setTransform(t.m11, t.m12, t.m21, t.m22, t.m31, t.m32); return {}; diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index 54a4827..c779239 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -481,7 +481,7 @@ type Transform = foreign import transform :: forall eff. Context2D -> Transform -> Eff (canvas :: CANVAS | eff) Unit -- | Set the transformation matrix -foreign import setTransform :: forall eff. Transform -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +foreign import setTransform :: forall eff. Context2D -> Transform -> Eff (canvas :: CANVAS | eff) Unit -- | Enumerates types of text alignment. data TextAlign From fe6c8f19a57e7b948e99f25e556dd76fc60dd68b Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 3 Dec 2017 12:51:26 -0800 Subject: [PATCH 19/35] context first in setFont --- src/Graphics/Canvas.js | 4 ++-- src/Graphics/Canvas.purs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index 9e849f5..6ee5ddb 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -362,8 +362,8 @@ exports.font = function(ctx) { }; }; -exports.setFont = function(fontspec) { - return function(ctx) { +exports.setFont = function(ctx) { + return function(fontspec) { return function() { ctx.font = fontspec; return {}; diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index c779239..9ce9761 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -531,7 +531,7 @@ type TextMetrics = { width :: Number } foreign import font :: forall eff. Context2D -> Eff (canvas :: CANVAS | eff) String -- | Set the current font. -foreign import setFont :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +foreign import setFont :: forall eff. Context2D -> String -> Eff (canvas :: CANVAS | eff) Unit -- | Fill some text. foreign import fillText :: forall eff. Context2D -> String -> Number -> Number -> Eff (canvas :: CANVAS | eff) Unit From 5ce0eda1bc62363184b6eb174a3dc3e63c99ac78 Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 3 Dec 2017 12:55:26 -0800 Subject: [PATCH 20/35] context first in createPattern --- src/Graphics/Canvas.js | 6 +++--- src/Graphics/Canvas.purs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index 6ee5ddb..be0e2d3 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -552,9 +552,9 @@ exports.drawImageFull = function(ctx) { }; }; -exports.createPatternImpl = function(img) { - return function(repeat) { - return function(ctx) { +exports.createPatternImpl = function(ctx) { + return function(img) { + return function(repeat) { return function() { return ctx.createPattern(img, repeat); }; diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index 9ce9761..37d904b 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -603,11 +603,11 @@ instance showPatternRepeat :: Show PatternRepeat where show RepeatY = "RepeatY" show NoRepeat = "NoRepeat" -foreign import createPatternImpl :: forall eff. CanvasImageSource -> String -> Context2D -> Eff (canvas :: CANVAS | eff) CanvasPattern +foreign import createPatternImpl :: forall eff. Context2D -> CanvasImageSource -> String -> Eff (canvas :: CANVAS | eff) CanvasPattern -- | Create a new canvas pattern (repeatable image). -createPattern :: forall eff. CanvasImageSource -> PatternRepeat -> Context2D -> Eff (canvas :: CANVAS | eff) CanvasPattern -createPattern img repeat = createPatternImpl img (toString repeat) +createPattern :: forall eff. Context2D -> CanvasImageSource -> PatternRepeat -> Eff (canvas :: CANVAS | eff) CanvasPattern +createPattern context img repeat = createPatternImpl context img (toString repeat) where toString Repeat = "repeat" toString RepeatX = "repeat-x" From c1573d8e8960c1fd410288100dc9f4b363d83977 Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 3 Dec 2017 12:56:28 -0800 Subject: [PATCH 21/35] context first in setPatternFillStyle --- src/Graphics/Canvas.js | 4 ++-- src/Graphics/Canvas.purs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index be0e2d3..f638c1d 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -562,8 +562,8 @@ exports.createPatternImpl = function(ctx) { }; }; -exports.setPatternFillStyle = function(pattern) { - return function(ctx) { +exports.setPatternFillStyle = function(ctx) { + return function(pattern) { return function() { ctx.fillStyle = pattern; return {}; diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index 37d904b..56ef795 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -615,7 +615,7 @@ createPattern context img repeat = createPatternImpl context img (toString repea toString NoRepeat = "no-repeat" -- | Set the Context2D fillstyle to the CanvasPattern. -foreign import setPatternFillStyle :: forall eff. CanvasPattern -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +foreign import setPatternFillStyle :: forall eff. Context2D -> CanvasPattern -> Eff (canvas :: CANVAS | eff) Unit -- | A type representing a linear gradient. -- | - Starting point coordinates: (`x0`, `y0`) From 2e3e27907182a0a882787f7a39b673c16bb20336 Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 3 Dec 2017 12:57:43 -0800 Subject: [PATCH 22/35] context first in createLinearGradient --- src/Graphics/Canvas.js | 4 ++-- src/Graphics/Canvas.purs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index f638c1d..a2a23ad 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -571,8 +571,8 @@ exports.setPatternFillStyle = function(ctx) { }; }; -exports.createLinearGradient = function(linearGradient) { - return function(ctx) { +exports.createLinearGradient = function(ctx) { + return function(linearGradient) { return function() { return ctx.createLinearGradient(linearGradient.x0, linearGradient.y0, linearGradient.x1, linearGradient.y1); }; diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index 56ef795..7c4ca70 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -629,7 +629,7 @@ type LinearGradient = } -- | Create a linear CanvasGradient. -foreign import createLinearGradient :: forall eff. LinearGradient -> Context2D -> Eff (canvas :: CANVAS | eff) CanvasGradient +foreign import createLinearGradient :: forall eff. Context2D -> LinearGradient -> Eff (canvas :: CANVAS | eff) CanvasGradient -- | A type representing a radial gradient. -- | - Starting circle center coordinates: (`x0`, `y0`) From fa4c276da99028e3f4373a0b52e99f44d4d4bdf0 Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 3 Dec 2017 12:58:43 -0800 Subject: [PATCH 23/35] context first in createRadialGradient --- src/Graphics/Canvas.js | 4 ++-- src/Graphics/Canvas.purs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index a2a23ad..e8fa941 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -579,8 +579,8 @@ exports.createLinearGradient = function(ctx) { }; }; -exports.createRadialGradient = function(radialGradient) { - return function(ctx) { +exports.createRadialGradient = function(ctx) { + return function(radialGradient) { return function() { return ctx.createRadialGradient(radialGradient.x0, radialGradient.y0, radialGradient.r0, radialGradient.x1, radialGradient.y1, radialGradient.r1); }; diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index 7c4ca70..735dfb0 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -647,7 +647,7 @@ type RadialGradient = } -- | Create a radial CanvasGradient. -foreign import createRadialGradient :: forall eff. RadialGradient -> Context2D -> Eff (canvas :: CANVAS | eff) CanvasGradient +foreign import createRadialGradient :: forall eff. Context2D -> RadialGradient -> Eff (canvas :: CANVAS | eff) CanvasGradient -- | Add a single color stop to a CanvasGradient. foreign import addColorStop :: forall eff. Number -> String -> CanvasGradient -> Eff (canvas :: CANVAS | eff) CanvasGradient From 327cede50acd140cc8ddda3f9adf94fd4cf1ae26 Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 3 Dec 2017 13:02:01 -0800 Subject: [PATCH 24/35] gradient first in addColorStop --- src/Graphics/Canvas.js | 6 +++--- src/Graphics/Canvas.purs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index e8fa941..e9ff70c 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -587,9 +587,9 @@ exports.createRadialGradient = function(ctx) { }; }; -exports.addColorStop = function(stop) { - return function(color) { - return function(gradient) { +exports.addColorStop = function(gradient) { + return function(stop) { + return function(color) { return function() { gradient.addColorStop(stop, color); return gradient; diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index 735dfb0..e90a45b 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -650,7 +650,7 @@ type RadialGradient = foreign import createRadialGradient :: forall eff. Context2D -> RadialGradient -> Eff (canvas :: CANVAS | eff) CanvasGradient -- | Add a single color stop to a CanvasGradient. -foreign import addColorStop :: forall eff. Number -> String -> CanvasGradient -> Eff (canvas :: CANVAS | eff) CanvasGradient +foreign import addColorStop :: forall eff. CanvasGradient -> Number -> String -> Eff (canvas :: CANVAS | eff) CanvasGradient -- | Set the Context2D fillstyle to the CanvasGradient. foreign import setGradientFillStyle :: forall eff. CanvasGradient -> Context2D -> Eff (canvas :: CANVAS | eff) Unit From be6e3afe3d46b415ea2cff4fb1f65a98a3caa02f Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 3 Dec 2017 13:03:12 -0800 Subject: [PATCH 25/35] return effectful unit from addColorStop --- src/Graphics/Canvas.js | 2 +- src/Graphics/Canvas.purs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index e9ff70c..11477d3 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -592,7 +592,7 @@ exports.addColorStop = function(gradient) { return function(color) { return function() { gradient.addColorStop(stop, color); - return gradient; + return {}; }; }; }; diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index e90a45b..8e55bec 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -650,7 +650,7 @@ type RadialGradient = foreign import createRadialGradient :: forall eff. Context2D -> RadialGradient -> Eff (canvas :: CANVAS | eff) CanvasGradient -- | Add a single color stop to a CanvasGradient. -foreign import addColorStop :: forall eff. CanvasGradient -> Number -> String -> Eff (canvas :: CANVAS | eff) CanvasGradient +foreign import addColorStop :: forall eff. CanvasGradient -> Number -> String -> Eff (canvas :: CANVAS | eff) Unit -- | Set the Context2D fillstyle to the CanvasGradient. foreign import setGradientFillStyle :: forall eff. CanvasGradient -> Context2D -> Eff (canvas :: CANVAS | eff) Unit From aa57ec9a221c3169524354a037daad5155b9504d Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 3 Dec 2017 13:05:02 -0800 Subject: [PATCH 26/35] context first in setGradientFillStyle --- src/Graphics/Canvas.js | 4 ++-- src/Graphics/Canvas.purs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index 11477d3..cb6ceec 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -598,8 +598,8 @@ exports.addColorStop = function(gradient) { }; }; -exports.setGradientFillStyle = function(gradient) { - return function(ctx) { +exports.setGradientFillStyle = function(ctx) { + return function(gradient) { return function() { ctx.fillStyle = gradient; return {}; diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index 8e55bec..75c7e5c 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -653,7 +653,7 @@ foreign import createRadialGradient :: forall eff. Context2D -> RadialGradient - foreign import addColorStop :: forall eff. CanvasGradient -> Number -> String -> Eff (canvas :: CANVAS | eff) Unit -- | Set the Context2D fillstyle to the CanvasGradient. -foreign import setGradientFillStyle :: forall eff. CanvasGradient -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +foreign import setGradientFillStyle :: forall eff. Context2D -> CanvasGradient -> Eff (canvas :: CANVAS | eff) Unit -- | A type representing a quadratic Bézier curve. -- | - Bézier control point: (`cpx`, `cpy`) From 556e0406a16fa206b1afc5e78af3d97739961e26 Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 3 Dec 2017 13:08:46 -0800 Subject: [PATCH 27/35] context first in quadraticCurveTo --- src/Graphics/Canvas.js | 4 ++-- src/Graphics/Canvas.purs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index cb6ceec..cb95875 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -607,8 +607,8 @@ exports.setGradientFillStyle = function(ctx) { }; }; -exports.quadraticCurveTo = function(qCurve) { - return function(ctx) { +exports.quadraticCurveTo = function(ctx) { + return function(qCurve) { return function() { ctx.quadraticCurveTo(qCurve.cpx, qCurve.cpy, qCurve.x, qCurve.y); return {}; diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index 75c7e5c..585f473 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -667,7 +667,7 @@ type QuadraticCurve = } -- | Draw a quadratic Bézier curve. -foreign import quadraticCurveTo :: forall eff. QuadraticCurve -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +foreign import quadraticCurveTo :: forall eff. Context2D -> QuadraticCurve -> Eff (canvas :: CANVAS | eff) Unit -- | A type representing a cubic Bézier curve. -- | - First Bézier control point: (`cp1x`, `cp1y`) From 8dba84dc2057ba53f3838685116e5da4b4b4734f Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 3 Dec 2017 13:09:50 -0800 Subject: [PATCH 28/35] context first in bezierCurveTo --- src/Graphics/Canvas.js | 4 ++-- src/Graphics/Canvas.purs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index cb95875..ba48e25 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -616,8 +616,8 @@ exports.quadraticCurveTo = function(ctx) { }; }; -exports.bezierCurveTo = function(bCurve) { - return function(ctx) { +exports.bezierCurveTo = function(ctx) { + return function(bCurve) { return function() { ctx.bezierCurveTo(bCurve.cp1x, bCurve.cp1y, bCurve.cp2x, bCurve.cp2y, bCurve.x, bCurve.y); return {}; diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index 585f473..5fb2ba0 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -684,4 +684,4 @@ type BezierCurve = } -- | Draw a cubic Bézier curve. -foreign import bezierCurveTo :: forall eff. BezierCurve -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +foreign import bezierCurveTo :: forall eff. Context2D -> BezierCurve -> Eff (canvas :: CANVAS | eff) Unit From 12ea5384b5496f40710b203e995e409cf24194a2 Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 3 Dec 2017 13:13:45 -0800 Subject: [PATCH 29/35] canvas first in setCanvasWidth --- src/Graphics/Canvas.js | 4 ++-- src/Graphics/Canvas.purs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index ba48e25..e159aa0 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -53,8 +53,8 @@ exports.getCanvasHeight = function(canvas) { }; }; -exports.setCanvasWidth = function(width) { - return function(canvas) { +exports.setCanvasWidth = function(canvas) { + return function(width) { return function() { canvas.width = width; return {}; diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index 5fb2ba0..ae04700 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -178,7 +178,7 @@ foreign import getCanvasWidth :: forall eff. CanvasElement -> Eff (canvas :: CAN foreign import getCanvasHeight :: forall eff. CanvasElement -> Eff (canvas :: CANVAS | eff) Number -- | Set the canvas width in pixels. -foreign import setCanvasWidth :: forall eff. Number -> CanvasElement -> Eff (canvas :: CANVAS | eff) Unit +foreign import setCanvasWidth :: forall eff. CanvasElement -> Number -> Eff (canvas :: CANVAS | eff) Unit -- | Set the canvas height in pixels. foreign import setCanvasHeight :: forall eff. Number -> CanvasElement -> Eff (canvas :: CANVAS | eff) Unit @@ -195,7 +195,7 @@ getCanvasDimensions ce = do -- | Set the canvas dimensions in pixels. setCanvasDimensions :: forall eff. Dimensions -> CanvasElement -> Eff (canvas :: CANVAS | eff) Unit -setCanvasDimensions d ce = setCanvasHeight d.height ce *> setCanvasWidth d.width ce +setCanvasDimensions d ce = setCanvasHeight d.height ce *> setCanvasWidth ce d.width -- | Create a data URL for the current canvas contents foreign import canvasToDataURL :: forall eff. CanvasElement -> Eff (canvas :: CANVAS | eff) String From d5eaa94624f33939e12250e38a7e9ec7fd01cf94 Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 3 Dec 2017 13:20:48 -0800 Subject: [PATCH 30/35] canvas first in setCanvasHeight --- src/Graphics/Canvas.js | 4 ++-- src/Graphics/Canvas.purs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index e159aa0..279611b 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -62,8 +62,8 @@ exports.setCanvasWidth = function(canvas) { }; }; -exports.setCanvasHeight = function(height) { - return function(canvas) { +exports.setCanvasHeight = function(canvas) { + return function(height) { return function() { canvas.height = height; return {}; diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index ae04700..165391a 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -181,7 +181,7 @@ foreign import getCanvasHeight :: forall eff. CanvasElement -> Eff (canvas :: CA foreign import setCanvasWidth :: forall eff. CanvasElement -> Number -> Eff (canvas :: CANVAS | eff) Unit -- | Set the canvas height in pixels. -foreign import setCanvasHeight :: forall eff. Number -> CanvasElement -> Eff (canvas :: CANVAS | eff) Unit +foreign import setCanvasHeight :: forall eff. CanvasElement -> Number -> Eff (canvas :: CANVAS | eff) Unit -- | Canvas dimensions (width and height) in pixels. type Dimensions = { width :: Number, height :: Number } @@ -195,7 +195,7 @@ getCanvasDimensions ce = do -- | Set the canvas dimensions in pixels. setCanvasDimensions :: forall eff. Dimensions -> CanvasElement -> Eff (canvas :: CANVAS | eff) Unit -setCanvasDimensions d ce = setCanvasHeight d.height ce *> setCanvasWidth ce d.width +setCanvasDimensions d ce = setCanvasHeight ce d.height *> setCanvasWidth ce d.width -- | Create a data URL for the current canvas contents foreign import canvasToDataURL :: forall eff. CanvasElement -> Eff (canvas :: CANVAS | eff) String From 8dae399471ab68852910f4ec7cf48255d37095ff Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Sun, 3 Dec 2017 13:22:35 -0800 Subject: [PATCH 31/35] canvas first in setCanvasDimensions --- src/Graphics/Canvas.purs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Graphics/Canvas.purs b/src/Graphics/Canvas.purs index 165391a..0ae61e1 100644 --- a/src/Graphics/Canvas.purs +++ b/src/Graphics/Canvas.purs @@ -194,8 +194,8 @@ getCanvasDimensions ce = do pure {width : w, height : h} -- | Set the canvas dimensions in pixels. -setCanvasDimensions :: forall eff. Dimensions -> CanvasElement -> Eff (canvas :: CANVAS | eff) Unit -setCanvasDimensions d ce = setCanvasHeight ce d.height *> setCanvasWidth ce d.width +setCanvasDimensions :: forall eff. CanvasElement -> Dimensions -> Eff (canvas :: CANVAS | eff) Unit +setCanvasDimensions ce d = setCanvasHeight ce d.height *> setCanvasWidth ce d.width -- | Create a data URL for the current canvas contents foreign import canvasToDataURL :: forall eff. CanvasElement -> Eff (canvas :: CANVAS | eff) String From 7d6b340a9fe42ac6750c72585f83b0aa7f61174c Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Wed, 13 Dec 2017 11:40:17 -0800 Subject: [PATCH 32/35] re-generate documents --- generated-docs/Graphics/Canvas.md | 509 +++++++++++++++--------------- 1 file changed, 261 insertions(+), 248 deletions(-) diff --git a/generated-docs/Graphics/Canvas.md b/generated-docs/Graphics/Canvas.md index 455b5ff..dea33fe 100644 --- a/generated-docs/Graphics/Canvas.md +++ b/generated-docs/Graphics/Canvas.md @@ -43,6 +43,159 @@ data CanvasImageSource :: Type Opaque object for drawing elements and things to the canvas. +#### `Arc` + +``` purescript +type Arc = { x :: Number, y :: Number, r :: Number, start :: Number, end :: Number } +``` + +A type representing an arc object: + +- The center coordinates `x` and `y`, +- The radius `r`, +- The starting and ending angles, `start` and `end`. + +#### `Composite` + +``` purescript +data Composite + = SourceOver + | SourceIn + | SourceOut + | SourceAtop + | DestinationOver + | DestinationIn + | DestinationOut + | DestinationAtop + | Lighter + | Copy + | Xor + | Multiply + | Screen + | Overlay + | Darken + | Lighten + | ColorDodge + | ColorBurn + | HardLight + | SoftLight + | Difference + | Exclusion + | Hue + | Saturation + | Color + | Luminosity +``` + +Enumerates the different types of composite operations and blend modes. + +##### Instances +``` purescript +Show Composite +``` + +#### `Dimensions` + +``` purescript +type Dimensions = { width :: Number, height :: Number } +``` + +Canvas dimensions (width and height) in pixels. + +#### `LineCap` + +``` purescript +data LineCap + = Round + | Square + | Butt +``` + +Enumerates the different types of line cap. + +##### Instances +``` purescript +Eq LineCap +``` + +#### `LineJoin` + +``` purescript +data LineJoin + = BevelJoin + | RoundJoin + | MiterJoin +``` + +Enumerates the different types of line join + +#### `Rectangle` + +``` purescript +type Rectangle = { x :: Number, y :: Number, w :: Number, h :: Number } +``` + +A type representing a rectangle object: + +- The top-left corner coordinates `x` and `y`, +- The width and height `w` and `h`. + +#### `ScaleTransform` + +``` purescript +type ScaleTransform = { scaleX :: Number, scaleY :: Number } +``` + +An object representing a scaling transform: + +- The scale factors in the `x` and `y` directions, `scaleX` and `scaleY`. + +#### `TextMetrics` + +``` purescript +type TextMetrics = { width :: Number } +``` + +Text metrics: + +- The text width in pixels. + +#### `Transform` + +``` purescript +type Transform = { m11 :: Number, m12 :: Number, m21 :: Number, m22 :: Number, m31 :: Number, m32 :: Number } +``` + +An object representing a general transformation as a homogeneous matrix. + +#### `TranslateTransform` + +``` purescript +type TranslateTransform = { translateX :: Number, translateY :: Number } +``` + +An object representing a translation: + +- The translation amounts in the `x` and `y` directions, `translateX` and `translateY`. + +#### `TextAlign` + +``` purescript +data TextAlign + = AlignLeft + | AlignRight + | AlignCenter + | AlignStart + | AlignEnd +``` + +Enumerates types of text alignment. + +##### Instances +``` purescript +Show TextAlign +``` + #### `CanvasPattern` ``` purescript @@ -51,6 +204,23 @@ data CanvasPattern :: Type Opaque object describing a pattern. +#### `PatternRepeat` + +``` purescript +data PatternRepeat + = Repeat + | RepeatX + | RepeatY + | NoRepeat +``` + +Enumerates the different types of pattern repetitions. + +##### Instances +``` purescript +Show PatternRepeat +``` + #### `CanvasGradient` ``` purescript @@ -59,19 +229,48 @@ data CanvasGradient :: Type Opaque object describing a gradient. -#### `canvasElementToImageSource` +#### `LinearGradient` ``` purescript -canvasElementToImageSource :: CanvasElement -> CanvasImageSource +type LinearGradient = { x0 :: Number, y0 :: Number, x1 :: Number, y1 :: Number } ``` -#### `tryLoadImage` +A type representing a linear gradient. + - Starting point coordinates: (`x0`, `y0`) + - Ending point coordinates: (`x1`, `y1`) + +#### `RadialGradient` ``` purescript -tryLoadImage :: forall eff. String -> (Maybe CanvasImageSource -> Eff (canvas :: CANVAS | eff) Unit) -> Eff (canvas :: CANVAS | eff) Unit +type RadialGradient = { x0 :: Number, y0 :: Number, r0 :: Number, x1 :: Number, y1 :: Number, r1 :: Number } ``` -Asynchronously load an image file by specifying its path. +A type representing a radial gradient. + - Starting circle center coordinates: (`x0`, `y0`) + - Starting circle radius: `r0` + - Ending circle center coordinates: (`x1`, `y1`) + - Ending circle radius: `r1` + +#### `QuadraticCurve` + +``` purescript +type QuadraticCurve = { cpx :: Number, cpy :: Number, x :: Number, y :: Number } +``` + +A type representing a quadratic Bézier curve. + - Bézier control point: (`cpx`, `cpy`) + - Ending point coordinates: (`x`, `y`) + +#### `BezierCurve` + +``` purescript +type BezierCurve = { cp1x :: Number, cp1y :: Number, cp2x :: Number, cp2y :: Number, x :: Number, y :: Number } +``` + +A type representing a cubic Bézier curve. + - First Bézier control point: (`cp1x`, `cp1y`) + - Second Bézier control point: (`cp2x`, `cp2y`) + - Ending point: (`x`, `y`) #### `getCanvasElementById` @@ -97,37 +296,29 @@ getCanvasWidth :: forall eff. CanvasElement -> Eff (canvas :: CANVAS | eff) Numb Get the canvas width in pixels. -#### `getCanvasHeight` - -``` purescript -getCanvasHeight :: forall eff. CanvasElement -> Eff (canvas :: CANVAS | eff) Number -``` - -Get the canvas height in pixels. - #### `setCanvasWidth` ``` purescript -setCanvasWidth :: forall eff. Number -> CanvasElement -> Eff (canvas :: CANVAS | eff) Unit +setCanvasWidth :: forall eff. CanvasElement -> Number -> Eff (canvas :: CANVAS | eff) Unit ``` Set the canvas width in pixels. -#### `setCanvasHeight` +#### `getCanvasHeight` ``` purescript -setCanvasHeight :: forall eff. Number -> CanvasElement -> Eff (canvas :: CANVAS | eff) Unit +getCanvasHeight :: forall eff. CanvasElement -> Eff (canvas :: CANVAS | eff) Number ``` -Set the canvas height in pixels. +Get the canvas height in pixels. -#### `Dimensions` +#### `setCanvasHeight` ``` purescript -type Dimensions = { width :: Number, height :: Number } +setCanvasHeight :: forall eff. CanvasElement -> Number -> Eff (canvas :: CANVAS | eff) Unit ``` -Canvas dimensions (width and height) in pixels. +Set the canvas height in pixels. #### `getCanvasDimensions` @@ -140,7 +331,7 @@ Get the canvas dimensions in pixels. #### `setCanvasDimensions` ``` purescript -setCanvasDimensions :: forall eff. Dimensions -> CanvasElement -> Eff (canvas :: CANVAS | eff) Unit +setCanvasDimensions :: forall eff. CanvasElement -> Dimensions -> Eff (canvas :: CANVAS | eff) Unit ``` Set the canvas dimensions in pixels. @@ -156,7 +347,7 @@ Create a data URL for the current canvas contents #### `setLineWidth` ``` purescript -setLineWidth :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +setLineWidth :: forall eff. Context2D -> Number -> Eff (canvas :: CANVAS | eff) Unit ``` Set the current line width. @@ -164,7 +355,7 @@ Set the current line width. #### `setFillStyle` ``` purescript -setFillStyle :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +setFillStyle :: forall eff. Context2D -> String -> Eff (canvas :: CANVAS | eff) Unit ``` Set the current fill style/color. @@ -172,23 +363,15 @@ Set the current fill style/color. #### `setStrokeStyle` ``` purescript -setStrokeStyle :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +setStrokeStyle :: forall eff. Context2D -> String -> Eff (canvas :: CANVAS | eff) Unit ``` Set the current stroke style/color. -#### `setShadowColor` - -``` purescript -setShadowColor :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Unit -``` - -Set the current shadow color. - #### `setShadowBlur` ``` purescript -setShadowBlur :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +setShadowBlur :: forall eff. Context2D -> Number -> Eff (canvas :: CANVAS | eff) Unit ``` Set the current shadow blur radius. @@ -196,7 +379,7 @@ Set the current shadow blur radius. #### `setShadowOffsetX` ``` purescript -setShadowOffsetX :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +setShadowOffsetX :: forall eff. Context2D -> Number -> Eff (canvas :: CANVAS | eff) Unit ``` Set the current shadow x-offset. @@ -204,96 +387,43 @@ Set the current shadow x-offset. #### `setShadowOffsetY` ``` purescript -setShadowOffsetY :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +setShadowOffsetY :: forall eff. Context2D -> Number -> Eff (canvas :: CANVAS | eff) Unit ``` Set the current shadow y-offset. -#### `setMiterLimit` +#### `setShadowColor` ``` purescript -setMiterLimit :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +setShadowColor :: forall eff. Context2D -> String -> Eff (canvas :: CANVAS | eff) Unit ``` -Set the current miter limit. +Set the current shadow color. -#### `LineCap` +#### `setMiterLimit` ``` purescript -data LineCap - = Round - | Square - | Butt +setMiterLimit :: forall eff. Context2D -> Number -> Eff (canvas :: CANVAS | eff) Unit ``` -Enumerates the different types of line cap. +Set the current miter limit. #### `setLineCap` ``` purescript -setLineCap :: forall eff. LineCap -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +setLineCap :: forall eff. Context2D -> LineCap -> Eff (canvas :: CANVAS | eff) Unit ``` Set the current line cap type. -#### `LineJoin` - -``` purescript -data LineJoin - = BevelJoin - | RoundJoin - | MiterJoin -``` - -Enumerates the different types of line join - #### `setLineJoin` ``` purescript -setLineJoin :: forall eff. LineJoin -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +setLineJoin :: forall eff. Context2D -> LineJoin -> Eff (canvas :: CANVAS | eff) Unit ``` Set the current line join type. -#### `Composite` - -``` purescript -data Composite - = SourceOver - | SourceIn - | SourceOut - | SourceAtop - | DestinationOver - | DestinationIn - | DestinationOut - | DestinationAtop - | Lighter - | Copy - | Xor - | Multiply - | Screen - | Overlay - | Darken - | Lighten - | ColorDodge - | ColorBurn - | HardLight - | SoftLight - | Difference - | Exclusion - | Hue - | Saturation - | Color - | Luminosity -``` - -Enumerates the different types of composite operations and blend modes. - -##### Instances -``` purescript -Show Composite -``` - #### `setGlobalCompositeOperation` ``` purescript @@ -402,18 +532,6 @@ fillPath ctx $ do closePath ctx ``` -#### `Arc` - -``` purescript -type Arc = { x :: Number, y :: Number, r :: Number, start :: Number, end :: Number } -``` - -A type representing an arc object: - -- The center coordinates `x` and `y`, -- The radius `r`, -- The starting and ending angles, `start` and `end`. - #### `arc` ``` purescript @@ -422,17 +540,6 @@ arc :: forall eff. Context2D -> Arc -> Eff (canvas :: CANVAS | eff) Unit Render an arc object. -#### `Rectangle` - -``` purescript -type Rectangle = { x :: Number, y :: Number, w :: Number, h :: Number } -``` - -A type representing a rectangle object: - -- The top-left corner coordinates `x` and `y`, -- The width and height `w` and `h`. - #### `rect` ``` purescript @@ -465,20 +572,10 @@ clearRect :: forall eff. Context2D -> Rectangle -> Eff (canvas :: CANVAS | eff) Clear a rectangle. -#### `ScaleTransform` - -``` purescript -type ScaleTransform = { scaleX :: Number, scaleY :: Number } -``` - -An object representing a scaling transform: - -- The scale factors in the `x` and `y` directions, `scaleX` and `scaleY`. - #### `scale` ``` purescript -scale :: forall eff. ScaleTransform -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +scale :: forall eff. Context2D -> ScaleTransform -> Eff (canvas :: CANVAS | eff) Unit ``` Apply a scaling transform. @@ -486,62 +583,34 @@ Apply a scaling transform. #### `rotate` ``` purescript -rotate :: forall eff. Number -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +rotate :: forall eff. Context2D -> Number -> Eff (canvas :: CANVAS | eff) Unit ``` Apply a rotation. -#### `TranslateTransform` - -``` purescript -type TranslateTransform = { translateX :: Number, translateY :: Number } -``` - -An object representing a translation: - -- The translation amounts in the `x` and `y` directions, `translateX` and `translateY`. - #### `translate` ``` purescript -translate :: forall eff. TranslateTransform -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +translate :: forall eff. Context2D -> TranslateTransform -> Eff (canvas :: CANVAS | eff) Unit ``` Apply a translation -#### `Transform` - -``` purescript -type Transform = { m11 :: Number, m12 :: Number, m21 :: Number, m22 :: Number, m31 :: Number, m32 :: Number } -``` - -An object representing a general transformation as a homogeneous matrix. - #### `transform` ``` purescript -transform :: forall eff. Transform -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +transform :: forall eff. Context2D -> Transform -> Eff (canvas :: CANVAS | eff) Unit ``` -Apply a general transformation. +Apply a general transformation to the current transformation matrix -#### `TextAlign` +#### `setTransform` ``` purescript -data TextAlign - = AlignLeft - | AlignRight - | AlignCenter - | AlignStart - | AlignEnd +setTransform :: forall eff. Context2D -> Transform -> Eff (canvas :: CANVAS | eff) Unit ``` -Enumerates types of text alignment. - -##### Instances -``` purescript -Show TextAlign -``` +Set the transformation matrix #### `textAlign` @@ -559,16 +628,6 @@ setTextAlign :: forall eff. Context2D -> TextAlign -> Eff (canvas :: CANVAS | ef Set the current text alignment. -#### `TextMetrics` - -``` purescript -type TextMetrics = { width :: Number } -``` - -Text metrics: - -- The text width in pixels. - #### `font` ``` purescript @@ -580,7 +639,7 @@ Get the current font. #### `setFont` ``` purescript -setFont :: forall eff. String -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +setFont :: forall eff. Context2D -> String -> Eff (canvas :: CANVAS | eff) Unit ``` Set the current font. @@ -641,6 +700,14 @@ withContext ctx $ do ... ``` +#### `tryLoadImage` + +``` purescript +tryLoadImage :: forall eff. String -> (Maybe CanvasImageSource -> Eff (canvas :: CANVAS | eff) Unit) -> Eff (canvas :: CANVAS | eff) Unit +``` + +Asynchronously load an image file by specifying its path. + #### `getImageData` ``` purescript @@ -649,18 +716,18 @@ getImageData :: forall eff. Context2D -> Number -> Number -> Number -> Number -> Get image data for a portion of the canvas. -#### `putImageDataFull` +#### `putImageData` ``` purescript -putImageDataFull :: forall eff. Context2D -> ImageData -> Number -> Number -> Number -> Number -> Number -> Number -> Eff (canvas :: CANVAS | eff) Unit +putImageData :: forall eff. Context2D -> ImageData -> Number -> Number -> Eff (canvas :: CANVAS | eff) Unit ``` Set image data for a portion of the canvas. -#### `putImageData` +#### `putImageDataFull` ``` purescript -putImageData :: forall eff. Context2D -> ImageData -> Number -> Number -> Eff (canvas :: CANVAS | eff) Unit +putImageDataFull :: forall eff. Context2D -> ImageData -> Number -> Number -> Number -> Number -> Number -> Number -> Eff (canvas :: CANVAS | eff) Unit ``` Set image data for a portion of the canvas. @@ -705,6 +772,12 @@ imageDataBuffer :: ImageData -> Uint8ClampedArray Get the underlying buffer from an `ImageData` object. +#### `canvasElementToImageSource` + +``` purescript +canvasElementToImageSource :: CanvasElement -> CanvasImageSource +``` + #### `drawImage` ``` purescript @@ -723,27 +796,10 @@ drawImageScale :: forall eff. Context2D -> CanvasImageSource -> Number -> Number drawImageFull :: forall eff. Context2D -> CanvasImageSource -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Eff (canvas :: CANVAS | eff) Unit ``` -#### `PatternRepeat` - -``` purescript -data PatternRepeat - = Repeat - | RepeatX - | RepeatY - | NoRepeat -``` - -Enumerates the different types of pattern repetitions. - -##### Instances -``` purescript -Show PatternRepeat -``` - #### `createPattern` ``` purescript -createPattern :: forall eff. CanvasImageSource -> PatternRepeat -> Context2D -> Eff (canvas :: CANVAS | eff) CanvasPattern +createPattern :: forall eff. Context2D -> CanvasImageSource -> PatternRepeat -> Eff (canvas :: CANVAS | eff) CanvasPattern ``` Create a new canvas pattern (repeatable image). @@ -751,45 +807,23 @@ Create a new canvas pattern (repeatable image). #### `setPatternFillStyle` ``` purescript -setPatternFillStyle :: forall eff. CanvasPattern -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +setPatternFillStyle :: forall eff. Context2D -> CanvasPattern -> Eff (canvas :: CANVAS | eff) Unit ``` Set the Context2D fillstyle to the CanvasPattern. -#### `LinearGradient` - -``` purescript -type LinearGradient = { x0 :: Number, y0 :: Number, x1 :: Number, y1 :: Number } -``` - -A type representing a linear gradient. - - Starting point coordinates: (`x0`, `y0`) - - Ending point coordinates: (`x1`, `y1`) - #### `createLinearGradient` ``` purescript -createLinearGradient :: forall eff. LinearGradient -> Context2D -> Eff (canvas :: CANVAS | eff) CanvasGradient +createLinearGradient :: forall eff. Context2D -> LinearGradient -> Eff (canvas :: CANVAS | eff) CanvasGradient ``` Create a linear CanvasGradient. -#### `RadialGradient` - -``` purescript -type RadialGradient = { x0 :: Number, y0 :: Number, r0 :: Number, x1 :: Number, y1 :: Number, r1 :: Number } -``` - -A type representing a radial gradient. - - Starting circle center coordinates: (`x0`, `y0`) - - Starting circle radius: `r0` - - Ending circle center coordinates: (`x1`, `y1`) - - Ending circle radius: `r1` - #### `createRadialGradient` ``` purescript -createRadialGradient :: forall eff. RadialGradient -> Context2D -> Eff (canvas :: CANVAS | eff) CanvasGradient +createRadialGradient :: forall eff. Context2D -> RadialGradient -> Eff (canvas :: CANVAS | eff) CanvasGradient ``` Create a radial CanvasGradient. @@ -797,7 +831,7 @@ Create a radial CanvasGradient. #### `addColorStop` ``` purescript -addColorStop :: forall eff. Number -> String -> CanvasGradient -> Eff (canvas :: CANVAS | eff) CanvasGradient +addColorStop :: forall eff. CanvasGradient -> Number -> String -> Eff (canvas :: CANVAS | eff) Unit ``` Add a single color stop to a CanvasGradient. @@ -805,44 +839,23 @@ Add a single color stop to a CanvasGradient. #### `setGradientFillStyle` ``` purescript -setGradientFillStyle :: forall eff. CanvasGradient -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +setGradientFillStyle :: forall eff. Context2D -> CanvasGradient -> Eff (canvas :: CANVAS | eff) Unit ``` Set the Context2D fillstyle to the CanvasGradient. -#### `QuadraticCurve` - -``` purescript -type QuadraticCurve = { cpx :: Number, cpy :: Number, x :: Number, y :: Number } -``` - -A type representing a quadratic Bézier curve. - - Bézier control point: (`cpx`, `cpy`) - - Ending point coordinates: (`x`, `y`) - #### `quadraticCurveTo` ``` purescript -quadraticCurveTo :: forall eff. QuadraticCurve -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +quadraticCurveTo :: forall eff. Context2D -> QuadraticCurve -> Eff (canvas :: CANVAS | eff) Unit ``` Draw a quadratic Bézier curve. -#### `BezierCurve` - -``` purescript -type BezierCurve = { cp1x :: Number, cp1y :: Number, cp2x :: Number, cp2y :: Number, x :: Number, y :: Number } -``` - -A type representing a cubic Bézier curve. - - First Bézier control point: (`cp1x`, `cp1y`) - - Second Bézier control point: (`cp2x`, `cp2y`) - - Ending point: (`x`, `y`) - #### `bezierCurveTo` ``` purescript -bezierCurveTo :: forall eff. BezierCurve -> Context2D -> Eff (canvas :: CANVAS | eff) Unit +bezierCurveTo :: forall eff. Context2D -> BezierCurve -> Eff (canvas :: CANVAS | eff) Unit ``` Draw a cubic Bézier curve. From f5d34dab36ebefb5e4cb443ea6c1083f142c2069 Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Wed, 13 Dec 2017 11:46:58 -0800 Subject: [PATCH 33/35] shared unit value --- src/Graphics/Canvas.js | 100 +++++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 49 deletions(-) diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index 279611b..6dfced8 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -1,6 +1,8 @@ /* global exports */ "use strict"; +const unit = {}; + exports.canvasElementToImageSource = function(e) { return e; }; @@ -18,7 +20,7 @@ exports.tryLoadImageImpl = function (src) { e(); }, false); - return {}; + return unit; } } }; @@ -57,7 +59,7 @@ exports.setCanvasWidth = function(canvas) { return function(width) { return function() { canvas.width = width; - return {}; + return unit; }; }; }; @@ -66,7 +68,7 @@ exports.setCanvasHeight = function(canvas) { return function(height) { return function() { canvas.height = height; - return {}; + return unit; }; }; }; @@ -81,7 +83,7 @@ exports.setLineWidth = function(ctx) { return function(width) { return function() { ctx.lineWidth = width; - return {}; + return unit; }; }; }; @@ -90,7 +92,7 @@ exports.setFillStyle = function(ctx) { return function(style) { return function() { ctx.fillStyle = style; - return {}; + return unit; }; }; }; @@ -99,7 +101,7 @@ exports.setStrokeStyle = function(ctx) { return function(style) { return function() { ctx.strokeStyle = style; - return {}; + return unit; }; }; }; @@ -108,7 +110,7 @@ exports.setShadowColor = function(ctx) { return function(color) { return function() { ctx.shadowColor = color; - return {}; + return unit; }; }; }; @@ -117,7 +119,7 @@ exports.setShadowBlur = function(ctx) { return function(blur) { return function() { ctx.shadowBlur = blur; - return {}; + return unit; }; }; }; @@ -126,7 +128,7 @@ exports.setShadowOffsetX = function(ctx) { return function(offsetX) { return function() { ctx.shadowOffsetX = offsetX; - return {}; + return unit; }; }; }; @@ -135,7 +137,7 @@ exports.setShadowOffsetY = function(ctx) { return function(offsetY) { return function() { ctx.shadowOffsetY = offsetY; - return {}; + return unit; }; }; }; @@ -144,7 +146,7 @@ exports.setMiterLimit = function(ctx) { return function(limit) { return function() { ctx.miterLimit = limit; - return {}; + return unit; }; }; }; @@ -153,7 +155,7 @@ exports.setLineCapImpl = function(ctx) { return function(cap) { return function() { ctx.lineCap = cap; - return {}; + return unit; }; }; }; @@ -162,7 +164,7 @@ exports.setLineJoinImpl = function(ctx) { return function(join) { return function() { ctx.lineJoin = join; - return {}; + return unit; }; }; }; @@ -171,7 +173,7 @@ exports.setGlobalCompositeOperationImpl = function(ctx) { return function(op) { return function() { ctx.globalCompositeOperation = op; - return {}; + return unit; }; }; }; @@ -180,7 +182,7 @@ exports.setGlobalAlpha = function(ctx) { return function(alpha) { return function() { ctx.globalAlpha = alpha; - return {}; + return unit; }; }; }; @@ -188,28 +190,28 @@ exports.setGlobalAlpha = function(ctx) { exports.beginPath = function(ctx) { return function() { ctx.beginPath(); - return {}; + return unit; }; }; exports.stroke = function(ctx) { return function() { ctx.stroke(); - return {}; + return unit; }; }; exports.fill = function(ctx) { return function() { ctx.fill(); - return {}; + return unit; }; }; exports.clip = function(ctx) { return function() { ctx.clip(); - return {}; + return unit; }; }; @@ -218,7 +220,7 @@ exports.lineTo = function(ctx) { return function(y) { return function() { ctx.lineTo(x, y); - return {}; + return unit; }; }; }; @@ -229,7 +231,7 @@ exports.moveTo = function(ctx) { return function(y) { return function() { ctx.moveTo(x, y); - return {}; + return unit; }; }; }; @@ -238,7 +240,7 @@ exports.moveTo = function(ctx) { exports.closePath = function(ctx) { return function() { ctx.closePath(); - return {}; + return unit; }; }; @@ -246,7 +248,7 @@ exports.arc = function(ctx) { return function(a) { return function() { ctx.arc(a.x, a.y, a.r, a.start, a.end); - return {}; + return unit; }; }; }; @@ -255,7 +257,7 @@ exports.rect = function(ctx) { return function(r) { return function() { ctx.rect(r.x, r.y, r.w, r.h); - return {}; + return unit; }; }; }; @@ -264,7 +266,7 @@ exports.fillRect = function(ctx) { return function(r) { return function() { ctx.fillRect(r.x, r.y, r.w, r.h); - return {}; + return unit; }; }; }; @@ -273,7 +275,7 @@ exports.strokeRect = function(ctx) { return function(r) { return function() { ctx.strokeRect(r.x, r.y, r.w, r.h); - return {}; + return unit; }; }; }; @@ -282,7 +284,7 @@ exports.clearRect = function(ctx) { return function(r) { return function() { ctx.clearRect(r.x, r.y, r.w, r.h); - return {}; + return unit; }; }; }; @@ -291,7 +293,7 @@ exports.scale = function(ctx) { return function(t) { return function() { ctx.scale(t.scaleX, t.scaleY); - return {}; + return unit; }; }; }; @@ -300,7 +302,7 @@ exports.rotate = function(ctx) { return function(angle) { return function() { ctx.rotate(angle); - return {}; + return unit; }; }; }; @@ -309,7 +311,7 @@ exports.translate = function(ctx) { return function(t) { return function() { ctx.translate(t.translateX, t.translateY); - return {}; + return unit; }; }; }; @@ -318,7 +320,7 @@ exports.transform = function(ctx) { return function(t) { return function() { ctx.transform(t.m11, t.m12, t.m21, t.m22, t.m31, t.m32); - return {}; + return unit; }; }; }; @@ -327,7 +329,7 @@ exports.setTransform = function(ctx) { return function(t) { return function() { ctx.setTransform(t.m11, t.m12, t.m21, t.m22, t.m31, t.m32); - return {}; + return unit; }; }; }; @@ -336,7 +338,7 @@ exports.clearRect = function(ctx) { return function(r) { return function() { ctx.clearRect(r.x, r.y, r.w, r.h); - return {}; + return unit; }; }; }; @@ -351,7 +353,7 @@ exports.setTextAlignImpl = function(ctx) { return function(textAlign) { return function() { ctx.textAlign = textAlign; - return {}; + return unit; } } }; @@ -366,7 +368,7 @@ exports.setFont = function(ctx) { return function(fontspec) { return function() { ctx.font = fontspec; - return {}; + return unit; }; }; }; @@ -377,7 +379,7 @@ exports.fillText = function(ctx) { return function(y) { return function() { ctx.fillText(text, x, y); - return {}; + return unit; }; }; }; @@ -390,7 +392,7 @@ exports.strokeText = function(ctx) { return function(y) { return function() { ctx.strokeText(text, x, y); - return {}; + return unit; }; }; }; @@ -408,14 +410,14 @@ exports.measureText = function(ctx) { exports.save = function(ctx) { return function() { ctx.save(); - return {}; + return unit; }; }; exports.restore = function(ctx) { return function() { ctx.restore(); - return {}; + return unit; }; }; @@ -455,7 +457,7 @@ exports.putImageDataFull = function(ctx) { return function(dh) { return function() { ctx.putImageData(image_data, x, y, dx, dy, dw, dh); - return {}; + return unit; }; }; }; @@ -472,7 +474,7 @@ exports.putImageData = function(ctx) { return function(y) { return function() { ctx.putImageData(image_data, x, y); - return {}; + return unit; }; }; }; @@ -503,7 +505,7 @@ exports.drawImage = function(ctx) { return function(dy) { return function() { ctx.drawImage(image_source, dx, dy); - return {}; + return unit; }; }; }; @@ -518,7 +520,7 @@ exports.drawImageScale = function(ctx) { return function(dHeight) { return function() { ctx.drawImage(image_source, dx, dy, dWidth, dHeight); - return {}; + return unit; }; }; }; @@ -539,7 +541,7 @@ exports.drawImageFull = function(ctx) { return function(dHeight) { return function() { ctx.drawImage(image_source, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight); - return {}; + return unit; }; }; }; @@ -566,7 +568,7 @@ exports.setPatternFillStyle = function(ctx) { return function(pattern) { return function() { ctx.fillStyle = pattern; - return {}; + return unit; }; }; }; @@ -592,7 +594,7 @@ exports.addColorStop = function(gradient) { return function(color) { return function() { gradient.addColorStop(stop, color); - return {}; + return unit; }; }; }; @@ -602,7 +604,7 @@ exports.setGradientFillStyle = function(ctx) { return function(gradient) { return function() { ctx.fillStyle = gradient; - return {}; + return unit; }; }; }; @@ -611,7 +613,7 @@ exports.quadraticCurveTo = function(ctx) { return function(qCurve) { return function() { ctx.quadraticCurveTo(qCurve.cpx, qCurve.cpy, qCurve.x, qCurve.y); - return {}; + return unit; }; }; }; @@ -620,7 +622,7 @@ exports.bezierCurveTo = function(ctx) { return function(bCurve) { return function() { ctx.bezierCurveTo(bCurve.cp1x, bCurve.cp1y, bCurve.cp2x, bCurve.cp2y, bCurve.x, bCurve.y); - return {}; + return unit; }; }; }; From a9059f6788f4adfc7393586af9dc91a6afff5ce6 Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Thu, 21 Dec 2017 08:50:28 -0800 Subject: [PATCH 34/35] remove explicit unit returns --- src/Graphics/Canvas.js | 52 ------------------------------------------ 1 file changed, 52 deletions(-) diff --git a/src/Graphics/Canvas.js b/src/Graphics/Canvas.js index 6dfced8..6c2cb0d 100644 --- a/src/Graphics/Canvas.js +++ b/src/Graphics/Canvas.js @@ -1,8 +1,6 @@ /* global exports */ "use strict"; -const unit = {}; - exports.canvasElementToImageSource = function(e) { return e; }; @@ -19,8 +17,6 @@ exports.tryLoadImageImpl = function (src) { img.addEventListener("error", function(error) { e(); }, false); - - return unit; } } }; @@ -59,7 +55,6 @@ exports.setCanvasWidth = function(canvas) { return function(width) { return function() { canvas.width = width; - return unit; }; }; }; @@ -68,7 +63,6 @@ exports.setCanvasHeight = function(canvas) { return function(height) { return function() { canvas.height = height; - return unit; }; }; }; @@ -83,7 +77,6 @@ exports.setLineWidth = function(ctx) { return function(width) { return function() { ctx.lineWidth = width; - return unit; }; }; }; @@ -92,7 +85,6 @@ exports.setFillStyle = function(ctx) { return function(style) { return function() { ctx.fillStyle = style; - return unit; }; }; }; @@ -101,7 +93,6 @@ exports.setStrokeStyle = function(ctx) { return function(style) { return function() { ctx.strokeStyle = style; - return unit; }; }; }; @@ -110,7 +101,6 @@ exports.setShadowColor = function(ctx) { return function(color) { return function() { ctx.shadowColor = color; - return unit; }; }; }; @@ -119,7 +109,6 @@ exports.setShadowBlur = function(ctx) { return function(blur) { return function() { ctx.shadowBlur = blur; - return unit; }; }; }; @@ -128,7 +117,6 @@ exports.setShadowOffsetX = function(ctx) { return function(offsetX) { return function() { ctx.shadowOffsetX = offsetX; - return unit; }; }; }; @@ -137,7 +125,6 @@ exports.setShadowOffsetY = function(ctx) { return function(offsetY) { return function() { ctx.shadowOffsetY = offsetY; - return unit; }; }; }; @@ -146,7 +133,6 @@ exports.setMiterLimit = function(ctx) { return function(limit) { return function() { ctx.miterLimit = limit; - return unit; }; }; }; @@ -155,7 +141,6 @@ exports.setLineCapImpl = function(ctx) { return function(cap) { return function() { ctx.lineCap = cap; - return unit; }; }; }; @@ -164,7 +149,6 @@ exports.setLineJoinImpl = function(ctx) { return function(join) { return function() { ctx.lineJoin = join; - return unit; }; }; }; @@ -173,7 +157,6 @@ exports.setGlobalCompositeOperationImpl = function(ctx) { return function(op) { return function() { ctx.globalCompositeOperation = op; - return unit; }; }; }; @@ -182,7 +165,6 @@ exports.setGlobalAlpha = function(ctx) { return function(alpha) { return function() { ctx.globalAlpha = alpha; - return unit; }; }; }; @@ -190,28 +172,24 @@ exports.setGlobalAlpha = function(ctx) { exports.beginPath = function(ctx) { return function() { ctx.beginPath(); - return unit; }; }; exports.stroke = function(ctx) { return function() { ctx.stroke(); - return unit; }; }; exports.fill = function(ctx) { return function() { ctx.fill(); - return unit; }; }; exports.clip = function(ctx) { return function() { ctx.clip(); - return unit; }; }; @@ -220,7 +198,6 @@ exports.lineTo = function(ctx) { return function(y) { return function() { ctx.lineTo(x, y); - return unit; }; }; }; @@ -231,7 +208,6 @@ exports.moveTo = function(ctx) { return function(y) { return function() { ctx.moveTo(x, y); - return unit; }; }; }; @@ -240,7 +216,6 @@ exports.moveTo = function(ctx) { exports.closePath = function(ctx) { return function() { ctx.closePath(); - return unit; }; }; @@ -248,7 +223,6 @@ exports.arc = function(ctx) { return function(a) { return function() { ctx.arc(a.x, a.y, a.r, a.start, a.end); - return unit; }; }; }; @@ -257,7 +231,6 @@ exports.rect = function(ctx) { return function(r) { return function() { ctx.rect(r.x, r.y, r.w, r.h); - return unit; }; }; }; @@ -266,7 +239,6 @@ exports.fillRect = function(ctx) { return function(r) { return function() { ctx.fillRect(r.x, r.y, r.w, r.h); - return unit; }; }; }; @@ -275,7 +247,6 @@ exports.strokeRect = function(ctx) { return function(r) { return function() { ctx.strokeRect(r.x, r.y, r.w, r.h); - return unit; }; }; }; @@ -284,7 +255,6 @@ exports.clearRect = function(ctx) { return function(r) { return function() { ctx.clearRect(r.x, r.y, r.w, r.h); - return unit; }; }; }; @@ -293,7 +263,6 @@ exports.scale = function(ctx) { return function(t) { return function() { ctx.scale(t.scaleX, t.scaleY); - return unit; }; }; }; @@ -302,7 +271,6 @@ exports.rotate = function(ctx) { return function(angle) { return function() { ctx.rotate(angle); - return unit; }; }; }; @@ -311,7 +279,6 @@ exports.translate = function(ctx) { return function(t) { return function() { ctx.translate(t.translateX, t.translateY); - return unit; }; }; }; @@ -320,7 +287,6 @@ exports.transform = function(ctx) { return function(t) { return function() { ctx.transform(t.m11, t.m12, t.m21, t.m22, t.m31, t.m32); - return unit; }; }; }; @@ -329,7 +295,6 @@ exports.setTransform = function(ctx) { return function(t) { return function() { ctx.setTransform(t.m11, t.m12, t.m21, t.m22, t.m31, t.m32); - return unit; }; }; }; @@ -338,7 +303,6 @@ exports.clearRect = function(ctx) { return function(r) { return function() { ctx.clearRect(r.x, r.y, r.w, r.h); - return unit; }; }; }; @@ -353,7 +317,6 @@ exports.setTextAlignImpl = function(ctx) { return function(textAlign) { return function() { ctx.textAlign = textAlign; - return unit; } } }; @@ -368,7 +331,6 @@ exports.setFont = function(ctx) { return function(fontspec) { return function() { ctx.font = fontspec; - return unit; }; }; }; @@ -379,7 +341,6 @@ exports.fillText = function(ctx) { return function(y) { return function() { ctx.fillText(text, x, y); - return unit; }; }; }; @@ -392,7 +353,6 @@ exports.strokeText = function(ctx) { return function(y) { return function() { ctx.strokeText(text, x, y); - return unit; }; }; }; @@ -410,14 +370,12 @@ exports.measureText = function(ctx) { exports.save = function(ctx) { return function() { ctx.save(); - return unit; }; }; exports.restore = function(ctx) { return function() { ctx.restore(); - return unit; }; }; @@ -457,7 +415,6 @@ exports.putImageDataFull = function(ctx) { return function(dh) { return function() { ctx.putImageData(image_data, x, y, dx, dy, dw, dh); - return unit; }; }; }; @@ -474,7 +431,6 @@ exports.putImageData = function(ctx) { return function(y) { return function() { ctx.putImageData(image_data, x, y); - return unit; }; }; }; @@ -505,7 +461,6 @@ exports.drawImage = function(ctx) { return function(dy) { return function() { ctx.drawImage(image_source, dx, dy); - return unit; }; }; }; @@ -520,7 +475,6 @@ exports.drawImageScale = function(ctx) { return function(dHeight) { return function() { ctx.drawImage(image_source, dx, dy, dWidth, dHeight); - return unit; }; }; }; @@ -541,7 +495,6 @@ exports.drawImageFull = function(ctx) { return function(dHeight) { return function() { ctx.drawImage(image_source, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight); - return unit; }; }; }; @@ -568,7 +521,6 @@ exports.setPatternFillStyle = function(ctx) { return function(pattern) { return function() { ctx.fillStyle = pattern; - return unit; }; }; }; @@ -594,7 +546,6 @@ exports.addColorStop = function(gradient) { return function(color) { return function() { gradient.addColorStop(stop, color); - return unit; }; }; }; @@ -604,7 +555,6 @@ exports.setGradientFillStyle = function(ctx) { return function(gradient) { return function() { ctx.fillStyle = gradient; - return unit; }; }; }; @@ -613,7 +563,6 @@ exports.quadraticCurveTo = function(ctx) { return function(qCurve) { return function() { ctx.quadraticCurveTo(qCurve.cpx, qCurve.cpy, qCurve.x, qCurve.y); - return unit; }; }; }; @@ -622,7 +571,6 @@ exports.bezierCurveTo = function(ctx) { return function(bCurve) { return function() { ctx.bezierCurveTo(bCurve.cp1x, bCurve.cp1y, bCurve.cp2x, bCurve.cp2y, bCurve.x, bCurve.y); - return unit; }; }; }; From f3cc2f470fea9d26330a866df72647a0a1478500 Mon Sep 17 00:00:00 2001 From: Greg Wiley Date: Thu, 21 Dec 2017 08:55:17 -0800 Subject: [PATCH 35/35] remove unused psc-package config --- psc-package.json | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 psc-package.json diff --git a/psc-package.json b/psc-package.json deleted file mode 100644 index baa0c60..0000000 --- a/psc-package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "canvas", - "source": "https://github.com/purescript/package-sets.git", - "set": "psc-0.11.5", - "depends": [ - "arraybuffer-types", - "bifunctors", - "control", - "eff", - "either", - "exceptions", - "foldable-traversable", - "functions", - "invariant", - "maybe", - "monoid", - "newtype", - "prelude" - ] -}