it renders text, but wrong

This commit is contained in:
cqc
2022-09-02 19:22:06 -05:00
parent 7460b8f793
commit 6a484c3a06
5 changed files with 462 additions and 1123 deletions

View File

@ -40,7 +40,7 @@ let _ =
(* File in this case is actually the CSS font name *) (* File in this case is actually the CSS font name *)
Text.create vg ~name:"sans" ~file:"sans" |> ignore ; Text.create vg ~name:"sans" ~file:"sans" |> ignore ;
webgl_ctx##clearColor 0.3 0.3 0.32 1. ; webgl_ctx##clearColor 0.3 0.3 0.32 1. ;
let rec render (time : float) = let render ev =
webgl_ctx##clear webgl_ctx##clear
( webgl_ctx##._COLOR_BUFFER_BIT_ ( webgl_ctx##._COLOR_BUFFER_BIT_
lor webgl_ctx##._DEPTH_BUFFER_BIT_ lor webgl_ctx##._DEPTH_BUFFER_BIT_
@ -49,7 +49,7 @@ let _ =
begin_frame vg ~width:canvas##.width ~height:canvas##.height begin_frame vg ~width:canvas##.width ~height:canvas##.height
~device_ratio ; ~device_ratio ;
Transform.scale vg ~x:device_ratio ~y:device_ratio ; Transform.scale vg ~x:device_ratio ~y:device_ratio ;
Human.Display.render vg canvas##.width canvas##.height ; ignore Human.Panel.Ui.(panel vg Gg.P2.o test ev) ;
(* (*
Path.begin_ vg ; Path.begin_ vg ;
Path.rect vg ~x:40. ~y:40. ~w:320. ~h:320. ; Path.rect vg ~x:40. ~y:40. ~w:320. ~h:320. ;
@ -62,8 +62,11 @@ let _ =
Text.set_align vg ~align:Align.(center lor middle) ; Text.set_align vg ~align:Align.(center lor middle) ;
set_fill_color vg ~color:Color.white ; set_fill_color vg ~color:Color.white ;
Text.text vg ~x:0. ~y:0. "Hello World!" ; *) Text.text vg ~x:0. ~y:0. "Hello World!" ; *)
NVG.end_frame vg ; NVG.end_frame vg in
Dom_html.window##requestAnimationFrame (Js.wrap_callback render) Dom_html.window##requestAnimationFrame
|> ignore in (Js.wrap_callback (fun _ -> render Human.Event.empty))
Dom_html.window##requestAnimationFrame (Js.wrap_callback render) |> ignore ;
|> ignore Dom_html.document##.onkeydown
:= Dom.handler (fun (evt : Dom_html.keyboardEvent Js.t) ->
render (Human.Event_js.evt_of_jskey `Press evt) ;
Js._false )

17
dune
View File

@ -1,19 +1,26 @@
(env (env
(dev (dev (flags (:standard -warn-error -A))
(flags (:standard -warn-error -A)))) (js_of_ocaml (flags --pretty --no-inline --source-map --debug-info) (compilation_mode separate)))
)
(executable (executable
(name boot_js) (name boot_js)
(modes byte js) (modes byte js)
(preprocess (pps js_of_ocaml-ppx)) (preprocess (pps js_of_ocaml-ppx))
(modules boot_js backend backend_js human)
(modules boot_js human)
(libraries (libraries
fmt
graphv_webgl graphv_webgl
js_of_ocaml js_of_ocaml
lwt lwt
irmin-git ; irmin-git
irmin-indexeddb ; irmin-indexeddb
zed zed
gg gg
)) ))

View File

@ -1,3 +1,2 @@
(lang dune 2.8) (lang dune 3.4)
(name komm) (name boot)
(wrapped_executables false)

1542
human.ml

File diff suppressed because it is too large Load Diff

View File

@ -17,8 +17,8 @@ div {
} }
canvas { canvas {
width: 400px; width: 100%;
height: 400px; height: 100%;
} }
</style> </style>
</head> </head>