Skip to content

Type width and height of canvas element as Int #94

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Notable changes to this project are documented in this file. The format is based
## [Unreleased]

Breaking changes:
- Changed types of width and height from Number to Int. The API guarantees that these values are integers as is, and even silently rounds non-integers if given.

New features:
- Added `imageSmoothingEnabled` to toggle the image smoothing of a `Context2D`.
Expand Down
10 changes: 5 additions & 5 deletions src/Graphics/Canvas.purs
Original file line number Diff line number Diff line change
Expand Up @@ -172,19 +172,19 @@ getCanvasElementById elId = runFn3 getCanvasElementByIdImpl elId Just Nothing
foreign import getContext2D :: CanvasElement -> Effect Context2D

-- | Get the canvas width in pixels.
foreign import getCanvasWidth :: CanvasElement -> Effect Number
foreign import getCanvasWidth :: CanvasElement -> Effect Int

-- | Get the canvas height in pixels.
foreign import getCanvasHeight :: CanvasElement -> Effect Number
foreign import getCanvasHeight :: CanvasElement -> Effect Int

-- | Set the canvas width in pixels.
foreign import setCanvasWidth :: CanvasElement -> Number -> Effect Unit
foreign import setCanvasWidth :: CanvasElement -> Int -> Effect Unit

-- | Set the canvas height in pixels.
foreign import setCanvasHeight :: CanvasElement -> Number -> Effect Unit
foreign import setCanvasHeight :: CanvasElement -> Int -> Effect Unit

-- | Canvas dimensions (width and height) in pixels.
type Dimensions = { width :: Number, height :: Number }
type Dimensions = { width :: Int, height :: Int }

-- | Get the canvas dimensions in pixels.
getCanvasDimensions :: CanvasElement -> Effect Dimensions
Expand Down