Skip to content
This repository
Browse code

[enhance] Canvas: adding functions to get Canvas width/height.

  • Loading branch information...
commit 6c6fde2476876ab6cd60284dc0889bfcdb2ae0ed 1 parent 69d5afd
Adam Koprowski akoprow authored
12 plugins/browser_canvas/bslCanvas.js
@@ -48,6 +48,18 @@
48 48 return js_none
49 49 }
50 50
  51 +##register get_width: Canvas.canvas -> int
  52 +##args(canvas)
  53 +{
  54 + return canvas.width;
  55 +}
  56 +
  57 +##register get_height: Canvas.canvas -> int
  58 +##args(canvas)
  59 +{
  60 + return canvas.height;
  61 +}
  62 +
51 63 // Context
52 64
53 65 ##register get_context: Canvas.canvas, string -> opa[option(Canvas.context)]
14 stdlib/web/canvas/canvas.opa
@@ -64,9 +64,7 @@ type Canvas.linejoin =
64 64 / {miter}
65 65
66 66 type Canvas.imagedata =
67   - {width:int
68   - height:int
69   - }
  67 + {width: int; height: int}
70 68
71 69 type Canvas.image =
72 70 {image : Image.image}
@@ -159,6 +157,16 @@ Canvas = {{
159 157 get_context(canvas,"2d")
160 158
161 159 /**
  160 + * {2 Canvas size}
  161 + **/
  162 +
  163 + get_width(canvas : Canvas.canvas) : int =
  164 + %%BslCanvas.get_width%%(canvas)
  165 +
  166 + get_height(canvas : Canvas.canvas) : int =
  167 + %%BslCanvas.get_height%%(canvas)
  168 +
  169 + /**
162 170 * {2 Canvas state}
163 171 **/
164 172

0 comments on commit 6c6fde2

Please sign in to comment.
Something went wrong with that request. Please try again.