File tree 4 files changed +16
-9
lines changed
4 files changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ let canvas_component =
25
25
~doc: " A drawing context lets you draw on the canvas"
26
26
" gl_context" (abstract any) ;
27
27
section " Canvas Element Management" [
28
- inherits ([] , " canvas" ) ([] , " Document .node" ) " as_node" ;
28
+ inherits ([] , " canvas" ) ([] , " Browser.DOM .node" ) " as_node" ;
29
29
map_attribute " canvas" " width"
30
30
~doc: " Reflects the height HTML attribute, specifying the width of \
31
31
the coordinate space in CSS pixels."
@@ -38,15 +38,15 @@ let canvas_component =
38
38
~doc: " Obtain a 2D context, should work everywhere"
39
39
[]
40
40
(abs " _"
41
- (set (arg 0 ) Const. (string " 2d" ))
41
+ (set_const (arg 0 ) Const. (string " 2d" ))
42
42
(call_method " getContext" ))
43
43
(abbrv " context" ) ;
44
44
def_method " canvas" " get_gl_context"
45
45
~doc: " Obtain a 3D context, works only on browsers supporting \
46
46
WebGL"
47
47
[]
48
48
(abs " _"
49
- (set (arg 0 ) Const. (string " webgl" ))
49
+ (set_const (arg 0 ) Const. (string " webgl" ))
50
50
(call_method " getContext" ))
51
51
(abbrv " gl_context" ) ;
52
52
] ;
Original file line number Diff line number Diff line change @@ -208,7 +208,7 @@ let raphael_component =
208
208
~doc: " Gives you a reference to the DOM object, so you can assign \
209
209
event handlers or just mess around.\n \
210
210
Note: Don't mess with it."
211
- ~read_only: true (abbrv " Document .node" ) ;
211
+ ~read_only: true (abbrv " Browser.DOM .node" ) ;
212
212
map_attribute " t" " id"
213
213
~doc: " Unique id of the element. Especially usesful when you want \
214
214
to listen to events of the element, because all events are \
@@ -831,7 +831,7 @@ let raphael_component =
831
831
832
832
[ labeled_arg " node"
833
833
~doc: " the parent DOM node"
834
- ((abbrv " Document .node" ) @@ arg 0 ) ;
834
+ ((abbrv " Browser.DOM .node" ) @@ arg 0 ) ;
835
835
labeled_arg " width"
836
836
~doc: " the width in pixels"
837
837
(int @@ arg 1 ) ;
@@ -1550,7 +1550,7 @@ let raphael_component =
1550
1550
1551
1551
[ labeled_arg " node"
1552
1552
~doc: " the parent DOM node"
1553
- ((abbrv " Document .node" ) @@ arg 0 ) ;
1553
+ ((abbrv " Browser.DOM .node" ) @@ arg 0 ) ;
1554
1554
labeled_arg " width"
1555
1555
~doc: " the width in pixels"
1556
1556
(int @@ arg 1 ) ;
Original file line number Diff line number Diff line change 1
1
< html >
2
- < body >
2
+ < body id =" body " >
3
3
</ body >
4
4
< script src ="libs.js " type ="text/javascript "> </ script >
5
5
< script src ="main.js " type ="text/javascript "> </ script >
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ open JavaScript
7
7
open Raphael
8
8
open Howler
9
9
10
+ module Dom = Browser. DOM
11
+
10
12
let looping_rotation ?(center = 0. , 0. ) ?(start = 0. ) element duration =
11
13
let rec loop deg =
12
14
let matrix = Matrix. identity () in
@@ -33,8 +35,13 @@ let scale =
33
35
fun i -> scale.(i)
34
36
35
37
let _ =
36
- let canvas = Document. create " div" in
37
- Document. append (Document. body () ) canvas ;
38
+ let document = Dom. document in
39
+ let body =
40
+ match Dom. get_element_by_id document " body" with
41
+ | None -> assert false
42
+ | Some elt -> elt in
43
+ let canvas = Dom. create_element_mode " div" in
44
+ Dom. append_child (Dom. element_as_node body) canvas;
38
45
let paper = raphael_at_node canvas 500 500 in
39
46
Paper. set_start paper ;
40
47
for i = 15 downto 0 do
You can’t perform that action at this time.
0 commit comments