Skip to content

Expose the information in the ImageData type. #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"purescript-eff": "^0.1.0",
"purescript-functions": "^0.1.0",
"purescript-maybe": "^0.3.0",
"purescript-exceptions": "^0.3.1"
"purescript-exceptions": "^0.3.1",
"purescript-arraybuffer-types": "^0.2.0"
}
}
18 changes: 0 additions & 18 deletions src/Graphics/Canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,24 +446,6 @@ exports.createImageDataCopy = function(ctx) {
};
};

exports.getImageDataWidth = function(image_data) {
return function() {
return image_data.width;
};
};

exports.getImageDataHeight = function(image_data) {
return function() {
return image_data.height;
};
};

exports.getImageDataPixelArray = function(image_data) {
return function() {
return image_data.data;
};
};

exports.drawImage = function(ctx) {
return function(image_source) {
return function(dx) {
Expand Down
21 changes: 3 additions & 18 deletions src/Graphics/Canvas.purs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module Graphics.Canvas
, CanvasElement()
, Context2D()
, ImageData()
, CanvasPixelArray()
, CanvasImageSource()
, Arc()
, Composite(..)
Expand Down Expand Up @@ -82,9 +81,6 @@ module Graphics.Canvas

, withImage
, getImageData
, getImageDataWidth
, getImageDataHeight
, getImageDataPixelArray
, putImageData
, putImageDataFull
, createImageData
Expand All @@ -106,6 +102,7 @@ module Graphics.Canvas

import Prelude

import Data.ArrayBuffer.Types
import Data.Function
import Data.Maybe
import Control.Monad.Eff
Expand All @@ -121,10 +118,7 @@ foreign import data CanvasElement :: *
foreign import data Context2D :: *

-- | An image data object, used to store raster data outside the canvas.
foreign import data ImageData :: *

-- | An array of pixel data.
foreign import data CanvasPixelArray :: *
type ImageData = { width :: Int, height :: Int, data :: Uint8ClampedArray }

-- | Opaque object for drawing elements and things to the canvas.
foreign import data CanvasImageSource :: *
Expand Down Expand Up @@ -462,7 +456,7 @@ foreign import getImageData :: forall eff. Context2D -> Number -> Number -> Numb
-- | 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

-- | Get image data for a portion of the canvas.
-- | Set image data for a portion of the canvas.
foreign import putImageData :: forall eff. Context2D -> ImageData -> Number -> Number -> Eff (canvas :: Canvas | eff) Context2D

-- | Create an image data object.
Expand All @@ -471,15 +465,6 @@ foreign import createImageData :: forall eff. Context2D -> Number -> Number -> E
-- | Create a copy of an image data object.
foreign import createImageDataCopy :: forall eff. Context2D -> ImageData -> Eff (canvas :: Canvas | eff) ImageData

-- | Get the width of an image data object in pixels.
foreign import getImageDataWidth :: forall eff. ImageData -> Eff (canvas :: Canvas | eff) Number

-- | Get the height of an image data object in pixels.
foreign import getImageDataHeight :: forall eff. ImageData -> Eff (canvas :: Canvas | eff) Number

-- | Get the pixel data array from an image data object.
foreign import getImageDataPixelArray :: forall eff. ImageData -> Eff (canvas :: Canvas | eff) CanvasPixelArray

foreign import drawImage :: forall eff. Context2D -> CanvasImageSource -> Number -> Number -> Eff (canvas :: Canvas | eff) Context2D

foreign import drawImageScale :: forall eff. Context2D -> CanvasImageSource -> Number -> Number -> Number -> Number -> Eff (canvas :: Canvas | eff) Context2D
Expand Down