Skip to content

Commit

Permalink
[ new ] fetch canvas dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-hoeck committed Jul 21, 2023
1 parent 67d4e6e commit 281526e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Web/MVC/Canvas.idr
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ record CDims where
cwidth : Double
cheight : Double

export
cdims : Ref Canvas -> JSIO CDims
cdims r = do
canvas <- castElementByRef {t = HTMLCanvasElement} r
w <- cast <$> get canvas width
h <- cast <$> get canvas height
pure $ CD w h

export
context2D : HTMLCanvasElement -> JSIO CanvasRenderingContext2D
context2D canvas = do
Expand Down

0 comments on commit 281526e

Please sign in to comment.