From da798e2955bb5d9174de53d200ec1208a6782ce5 Mon Sep 17 00:00:00 2001 From: Thomas Honeyman Date: Sun, 6 Dec 2020 13:32:51 -0800 Subject: [PATCH 1/5] Update for GitHub Actions --- .github/workflows/ci.yml | 29 + .gitignore | 7 +- .travis.yml | 15 - README.md | 16 +- bower.json | 2 +- generated-docs/Graphics/Canvas.md | 863 ------------------------------ package.json | 8 +- 7 files changed, 47 insertions(+), 893 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml delete mode 100644 generated-docs/Graphics/Canvas.md diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..49aff92 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,29 @@ +name: CI + +on: push + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - uses: purescript-contrib/setup-purescript@main + + - uses: actions/setup-node@v1 + with: + node-version: "10" + + - name: Install dependencies + run: | + npm install -g bower + npm install + bower install --production + + - name: Build source + run: npm run-script build + + - name: Run tests + run: | + bower install + npm run-script test --if-present diff --git a/.gitignore b/.gitignore index 73c09cb..dc9eaee 100644 --- a/.gitignore +++ b/.gitignore @@ -4,10 +4,7 @@ bower_components/ package-lock.json /.* +!/.github !/.gitignore -!/.travis.yml -# OS generated files # -###################### -ehthumbs.db -Thumbs.db +*.db diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 968390b..0000000 --- a/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -language: node_js -dist: trusty -sudo: required -node_js: stable -install: - - npm install -g bower - - npm install - - bower install -script: - - npm run -s build -after_success: -- >- - test $TRAVIS_TAG && - echo $GITHUB_TOKEN | pulp login && - echo y | pulp publish --no-push diff --git a/README.md b/README.md index dd46ed1..17cb8dc 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,17 @@ # purescript-canvas -[![Latest release](http://img.shields.io/bower/v/purescript-canvas.svg)](https://github.com/purescript-contrib/purescript-canvas/releases) +[![Latest release](http://img.shields.io/github/release/purescript-web/purescript-canvas.svg)](https://github.com/purescript-web/purescript-canvas/releases) +[![Build status](https://github.com/purescript/purescript-canvas/workflows/CI/badge.svg?branch=master)](https://github.com/purescript/purescript-canvas/actions?query=workflow%3ACI+branch%3Amaster) +[![Pursuit](https://pursuit.purescript.org/packages/purescript-canvas/badge)](https://pursuit.purescript.org/packages/purescript-canvas) -Canvas bindings for PureScript +Canvas bindings for PureScript. -- [Module Documentation](generated-docs/) +## Installation -## Installing +``` +spago install canvas +``` - bower i purescript-canvas +## Documentation + +Module documentation is [published on Pursuit](http://pursuit.purescript.org/packages/purescript-canvas). diff --git a/bower.json b/bower.json index 98d069a..d40502e 100644 --- a/bower.json +++ b/bower.json @@ -17,7 +17,7 @@ ], "repository": { "type": "git", - "url": "git://github.com/paf31/purescript-canvas.git" + "url": "https://github.com/paf31/purescript-canvas.git" }, "dependencies": { "purescript-effect": "^2.0.0", diff --git a/generated-docs/Graphics/Canvas.md b/generated-docs/Graphics/Canvas.md deleted file mode 100644 index de572d5..0000000 --- a/generated-docs/Graphics/Canvas.md +++ /dev/null @@ -1,863 +0,0 @@ -## Module Graphics.Canvas - -This module defines foreign types and functions for working with the 2D -Canvas API. - -#### `CanvasElement` - -``` purescript -data CanvasElement :: Type -``` - -A canvas HTML element. - -#### `Context2D` - -``` purescript -data Context2D :: Type -``` - -A 2D graphics context. - -#### `ImageData` - -``` purescript -data ImageData :: Type -``` - -An image data object, used to store raster data outside the canvas. - -#### `CanvasImageSource` - -``` purescript -data CanvasImageSource :: Type -``` - -Opaque object for drawing elements and things to the canvas. - -#### `Arc` - -``` purescript -type Arc = { x :: Number, y :: Number, radius :: 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, width :: Number, height :: 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 -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 -data CanvasGradient :: Type -``` - -Opaque object describing a gradient. - -#### `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`) - -#### `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` - -#### `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` - -``` purescript -getCanvasElementById :: String -> Effect (Maybe CanvasElement) -``` - -Get a canvas element by ID, or `Nothing` if the element does not exist. - -#### `getContext2D` - -``` purescript -getContext2D :: CanvasElement -> Effect Context2D -``` - -Get the 2D graphics context for a canvas element. - -#### `getCanvasWidth` - -``` purescript -getCanvasWidth :: CanvasElement -> Effect Number -``` - -Get the canvas width in pixels. - -#### `setCanvasWidth` - -``` purescript -setCanvasWidth :: CanvasElement -> Number -> Effect Unit -``` - -Set the canvas width in pixels. - -#### `getCanvasHeight` - -``` purescript -getCanvasHeight :: CanvasElement -> Effect Number -``` - -Get the canvas height in pixels. - -#### `setCanvasHeight` - -``` purescript -setCanvasHeight :: CanvasElement -> Number -> Effect Unit -``` - -Set the canvas height in pixels. - -#### `getCanvasDimensions` - -``` purescript -getCanvasDimensions :: CanvasElement -> Effect Dimensions -``` - -Get the canvas dimensions in pixels. - -#### `setCanvasDimensions` - -``` purescript -setCanvasDimensions :: CanvasElement -> Dimensions -> Effect Unit -``` - -Set the canvas dimensions in pixels. - -#### `canvasToDataURL` - -``` purescript -canvasToDataURL :: CanvasElement -> Effect String -``` - -Create a data URL for the current canvas contents - -#### `setLineWidth` - -``` purescript -setLineWidth :: Context2D -> Number -> Effect Unit -``` - -Set the current line width. - -#### `setLineDash` - -``` purescript -setLineDash :: Context2D -> Array Number -> Effect Unit -``` - -Set the current line dash pattern. - -#### `setFillStyle` - -``` purescript -setFillStyle :: Context2D -> String -> Effect Unit -``` - -Set the current fill style/color. - -#### `setStrokeStyle` - -``` purescript -setStrokeStyle :: Context2D -> String -> Effect Unit -``` - -Set the current stroke style/color. - -#### `setShadowBlur` - -``` purescript -setShadowBlur :: Context2D -> Number -> Effect Unit -``` - -Set the current shadow blur radius. - -#### `setShadowOffsetX` - -``` purescript -setShadowOffsetX :: Context2D -> Number -> Effect Unit -``` - -Set the current shadow x-offset. - -#### `setShadowOffsetY` - -``` purescript -setShadowOffsetY :: Context2D -> Number -> Effect Unit -``` - -Set the current shadow y-offset. - -#### `setShadowColor` - -``` purescript -setShadowColor :: Context2D -> String -> Effect Unit -``` - -Set the current shadow color. - -#### `setMiterLimit` - -``` purescript -setMiterLimit :: Context2D -> Number -> Effect Unit -``` - -Set the current miter limit. - -#### `setLineCap` - -``` purescript -setLineCap :: Context2D -> LineCap -> Effect Unit -``` - -Set the current line cap type. - -#### `setLineJoin` - -``` purescript -setLineJoin :: Context2D -> LineJoin -> Effect Unit -``` - -Set the current line join type. - -#### `setGlobalCompositeOperation` - -``` purescript -setGlobalCompositeOperation :: Context2D -> Composite -> Effect Unit -``` - -Set the current composite operation. - -#### `setGlobalAlpha` - -``` purescript -setGlobalAlpha :: Context2D -> Number -> Effect Unit -``` - -Set the current global alpha level. - -#### `beginPath` - -``` purescript -beginPath :: Context2D -> Effect Unit -``` - -Begin a path object. - -#### `stroke` - -``` purescript -stroke :: Context2D -> Effect Unit -``` - -Stroke the current object. - -#### `fill` - -``` purescript -fill :: Context2D -> Effect Unit -``` - -Fill the current object. - -#### `clip` - -``` purescript -clip :: Context2D -> Effect Unit -``` - -Clip to the current object. - -#### `lineTo` - -``` purescript -lineTo :: Context2D -> Number -> Number -> Effect Unit -``` - -Move the path to the specified coordinates, drawing a line segment. - -#### `moveTo` - -``` purescript -moveTo :: Context2D -> Number -> Number -> Effect Unit -``` - -Move the path to the specified coordinates, without drawing a line segment. - -#### `closePath` - -``` purescript -closePath :: Context2D -> Effect Unit -``` - -Close the current path. - -#### `strokePath` - -``` purescript -strokePath :: forall a. Context2D -> Effect a -> Effect a -``` - -A convenience function for drawing a stroked path. - -For example: - -```purescript -strokePath ctx $ do - moveTo ctx 10.0 10.0 - lineTo ctx 20.0 20.0 - lineTo ctx 10.0 20.0 - closePath ctx -``` - -#### `fillPath` - -``` purescript -fillPath :: forall a. Context2D -> Effect a -> Effect a -``` - -A convenience function for drawing a filled path. - -For example: - -```purescript -fillPath ctx $ do - moveTo ctx 10.0 10.0 - lineTo ctx 20.0 20.0 - lineTo ctx 10.0 20.0 - closePath ctx -``` - -#### `arc` - -``` purescript -arc :: Context2D -> Arc -> Effect Unit -``` - -Render an arc object. - -#### `rect` - -``` purescript -rect :: Context2D -> Rectangle -> Effect Unit -``` - -Render a rectangle. - -#### `fillRect` - -``` purescript -fillRect :: Context2D -> Rectangle -> Effect Unit -``` - -Fill a rectangle. - -#### `strokeRect` - -``` purescript -strokeRect :: Context2D -> Rectangle -> Effect Unit -``` - -Stroke a rectangle. - -#### `clearRect` - -``` purescript -clearRect :: Context2D -> Rectangle -> Effect Unit -``` - -Clear a rectangle. - -#### `scale` - -``` purescript -scale :: Context2D -> ScaleTransform -> Effect Unit -``` - -Apply a scaling transform. - -#### `rotate` - -``` purescript -rotate :: Context2D -> Number -> Effect Unit -``` - -Apply a rotation. - -#### `translate` - -``` purescript -translate :: Context2D -> TranslateTransform -> Effect Unit -``` - -Apply a translation - -#### `transform` - -``` purescript -transform :: Context2D -> Transform -> Effect Unit -``` - -Apply a general transformation to the current transformation matrix - -#### `setTransform` - -``` purescript -setTransform :: Context2D -> Transform -> Effect Unit -``` - -Set the transformation matrix - -#### `textAlign` - -``` purescript -textAlign :: Context2D -> Effect TextAlign -``` - -Get the current text alignment. - -#### `setTextAlign` - -``` purescript -setTextAlign :: Context2D -> TextAlign -> Effect Unit -``` - -Set the current text alignment. - -#### `font` - -``` purescript -font :: Context2D -> Effect String -``` - -Get the current font. - -#### `setFont` - -``` purescript -setFont :: Context2D -> String -> Effect Unit -``` - -Set the current font. - -#### `fillText` - -``` purescript -fillText :: Context2D -> String -> Number -> Number -> Effect Unit -``` - -Fill some text. - -#### `strokeText` - -``` purescript -strokeText :: Context2D -> String -> Number -> Number -> Effect Unit -``` - -Stroke some text. - -#### `measureText` - -``` purescript -measureText :: Context2D -> String -> Effect TextMetrics -``` - -Measure some text. - -#### `save` - -``` purescript -save :: Context2D -> Effect Unit -``` - -Save the current context. - -#### `restore` - -``` purescript -restore :: Context2D -> Effect Unit -``` - -Restore the previous context. - -#### `withContext` - -``` purescript -withContext :: forall a. Context2D -> Effect a -> Effect a -``` - -A convenience function: run the action, preserving the existing context. - -For example, outside this block, the fill style is preseved: - -```purescript -withContext ctx $ do - setFillStyle "red" ctx - ... -``` - -#### `tryLoadImage` - -``` purescript -tryLoadImage :: String -> (Maybe CanvasImageSource -> Effect Unit) -> Effect Unit -``` - -Asynchronously load an image file by specifying its path. - -#### `getImageData` - -``` purescript -getImageData :: Context2D -> Number -> Number -> Number -> Number -> Effect ImageData -``` - -Get image data for a portion of the canvas. - -#### `putImageData` - -``` purescript -putImageData :: Context2D -> ImageData -> Number -> Number -> Effect Unit -``` - -Set image data for a portion of the canvas. - -#### `putImageDataFull` - -``` purescript -putImageDataFull :: Context2D -> ImageData -> Number -> Number -> Number -> Number -> Number -> Number -> Effect Unit -``` - -Set image data for a portion of the canvas. - -#### `createImageData` - -``` purescript -createImageData :: Context2D -> Number -> Number -> Effect ImageData -``` - -Create an image data object. - -#### `createImageDataCopy` - -``` purescript -createImageDataCopy :: Context2D -> ImageData -> Effect ImageData -``` - -Create a copy of an image data object. - -#### `imageDataWidth` - -``` purescript -imageDataWidth :: ImageData -> Int -``` - -Get the width of an `ImageData` object. - -#### `imageDataHeight` - -``` purescript -imageDataHeight :: ImageData -> Int -``` - -Get the height of an `ImageData` object. - -#### `imageDataBuffer` - -``` purescript -imageDataBuffer :: ImageData -> Uint8ClampedArray -``` - -Get the underlying buffer from an `ImageData` object. - -#### `canvasElementToImageSource` - -``` purescript -canvasElementToImageSource :: CanvasElement -> CanvasImageSource -``` - -#### `drawImage` - -``` purescript -drawImage :: Context2D -> CanvasImageSource -> Number -> Number -> Effect Unit -``` - -#### `drawImageScale` - -``` purescript -drawImageScale :: Context2D -> CanvasImageSource -> Number -> Number -> Number -> Number -> Effect Unit -``` - -#### `drawImageFull` - -``` purescript -drawImageFull :: Context2D -> CanvasImageSource -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Number -> Effect Unit -``` - -#### `createPattern` - -``` purescript -createPattern :: Context2D -> CanvasImageSource -> PatternRepeat -> Effect CanvasPattern -``` - -Create a new canvas pattern (repeatable image). - -#### `setPatternFillStyle` - -``` purescript -setPatternFillStyle :: Context2D -> CanvasPattern -> Effect Unit -``` - -Set the Context2D fillstyle to the CanvasPattern. - -#### `createLinearGradient` - -``` purescript -createLinearGradient :: Context2D -> LinearGradient -> Effect CanvasGradient -``` - -Create a linear CanvasGradient. - -#### `createRadialGradient` - -``` purescript -createRadialGradient :: Context2D -> RadialGradient -> Effect CanvasGradient -``` - -Create a radial CanvasGradient. - -#### `addColorStop` - -``` purescript -addColorStop :: CanvasGradient -> Number -> String -> Effect Unit -``` - -Add a single color stop to a CanvasGradient. - -#### `setGradientFillStyle` - -``` purescript -setGradientFillStyle :: Context2D -> CanvasGradient -> Effect Unit -``` - -Set the Context2D fillstyle to the CanvasGradient. - -#### `quadraticCurveTo` - -``` purescript -quadraticCurveTo :: Context2D -> QuadraticCurve -> Effect Unit -``` - -Draw a quadratic Bézier curve. - -#### `bezierCurveTo` - -``` purescript -bezierCurveTo :: Context2D -> BezierCurve -> Effect Unit -``` - -Draw a cubic Bézier curve. - - diff --git a/package.json b/package.json index 7dfafc7..4d9685b 100644 --- a/package.json +++ b/package.json @@ -6,9 +6,9 @@ "test": "pulp test" }, "devDependencies": { - "pulp": "^12.2.0", - "purescript-psa": "^0.6.0", - "purescript": "^0.12.0", - "rimraf": "^2.6.2" + "pulp": "^15.0.0", + "purescript-psa": "^0.8.0", + "purescript": "^0.13.8", + "rimraf": "^3.0.2" } } From a26df54cdb1c0fbf87e5c78c706954d0591f8f1b Mon Sep 17 00:00:00 2001 From: JordanMartinez Date: Mon, 7 Dec 2020 18:05:29 -0800 Subject: [PATCH 2/5] Remove test script There aren't any tests in this repo. If we want to add them later, this script should be added again. --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 4d9685b..70e3e73 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,7 @@ "private": true, "scripts": { "clean": "rimraf output && rimraf .pulp-cache", - "build": "pulp build -- --censor-lib --strict", - "test": "pulp test" + "build": "pulp build -- --censor-lib --strict" }, "devDependencies": { "pulp": "^15.0.0", From e8acfa1d9ec1255d0b69deb618367192c6bc2793 Mon Sep 17 00:00:00 2001 From: Cyril Sobierajewicz Date: Tue, 8 Dec 2020 19:08:12 +0100 Subject: [PATCH 3/5] Run CI on push / pull_request to master --- .github/workflows/ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 49aff92..063845e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,10 @@ name: CI -on: push +on: + push: + branches: [master] + pull_request: + branches: [master] jobs: build: From 0a87b18844c38add569016f819a26d0b2d95ae5f Mon Sep 17 00:00:00 2001 From: Cyril Sobierajewicz Date: Tue, 8 Dec 2020 19:08:15 +0100 Subject: [PATCH 4/5] Fix build status badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 17cb8dc..4e295af 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # purescript-canvas [![Latest release](http://img.shields.io/github/release/purescript-web/purescript-canvas.svg)](https://github.com/purescript-web/purescript-canvas/releases) -[![Build status](https://github.com/purescript/purescript-canvas/workflows/CI/badge.svg?branch=master)](https://github.com/purescript/purescript-canvas/actions?query=workflow%3ACI+branch%3Amaster) +[![Build status](https://github.com/purescript-web/purescript-canvas/workflows/CI/badge.svg?branch=master)](https://github.com/purescript-web/purescript-canvas/actions?query=workflow%3ACI+branch%3Amaster) [![Pursuit](https://pursuit.purescript.org/packages/purescript-canvas/badge)](https://pursuit.purescript.org/packages/purescript-canvas) Canvas bindings for PureScript. From c333e33c1ef7bd473e056835b5bcdb73f624e393 Mon Sep 17 00:00:00 2001 From: Thomas Honeyman Date: Tue, 8 Dec 2020 17:06:26 -0800 Subject: [PATCH 5/5] Update bower.json --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index d40502e..5d32d0e 100644 --- a/bower.json +++ b/bower.json @@ -17,7 +17,7 @@ ], "repository": { "type": "git", - "url": "https://github.com/paf31/purescript-canvas.git" + "url": "https://github.com/purescript/purescript-canvas.git" }, "dependencies": { "purescript-effect": "^2.0.0",