diff options
author | Sébastien Dailly <sebastien@chimrod.com> | 2021-05-25 11:08:00 +0200 |
---|---|---|
committer | Sébastien Dailly <sebastien@dailly.me> | 2022-02-07 16:22:43 +0100 |
commit | 6a75fb043ed30389fff1ce97fe20ee56b1c95066 (patch) | |
tree | 20e0c2cb39dffcf85449e0b810d773909c405a0e /script.it/script_event/export.ml | |
parent | 90f1f73f08b2d9231b2ee029b9e39dd570e36f36 (diff) |
Update script.it project
Diffstat (limited to 'script.it/script_event/export.ml')
-rwxr-xr-x | script.it/script_event/export.ml | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/script.it/script_event/export.ml b/script.it/script_event/export.ml new file mode 100755 index 0000000..9e900c7 --- /dev/null +++ b/script.it/script_event/export.ml @@ -0,0 +1,30 @@ +open StdLabels +open Brr +module State = Script_state.State + +type t = unit + +let update () state = + let my_host = Uri.host @@ Window.location @@ G.window in + if (Hashtbl.hash my_host) = Blog.Hash_host.expected_host then ( + (* Convert the path into an sVG element *) + let svg = Layer.Svg.svg + ~at:Brr.At.[ + v (Jstr.v "xmlns") (Jstr.v "http://www.w3.org/2000/svg") + ; v (Jstr.v "xmlns:xlink") (Jstr.v "http://www.w3.org/1999/xlink") ] + (List.map state.State.paths + ~f:(fun path -> + + Layer.Paths.to_svg + ~color:Blog.Nord.nord0 + (module Path.Fixed) + Outline.(path.path, path.back) + state.State.rendering + + )) in + let content = El.prop Elements.Prop.outerHTML svg in + Elements.Transfert.send + ~mime_type:(Jstr.v "image/svg+xml") + ~filename:(Jstr.v "out.svg") + content); + state |