Commit 77b89518 authored by Benoit Barbot's avatar Benoit Barbot
Browse files

progress

parent c1b2e712
Pipeline #975 failed with stage
in 14 seconds
......@@ -228,7 +228,6 @@ module Circle =
ctx##stroke;
()
let projection (center,asym,radius,angle) origin =
let (x1,y1) as v1 = rot (-.angle) (center -.. origin) in
let intersect = mult ((abs_float x1 -. (radius/.asym)) /. (abs_float x1)) v1 in
......@@ -297,7 +296,6 @@ module Circle =
end
module Text =
struct
type t = (point)*string
......
......@@ -315,6 +315,7 @@ module GraphEditor (G: GRAPH ) = struct
download string_value "graph.gex" "data:application/xml") ]
[pcdata "Get GEX"];*)
button ~a:[a_onclick (fun _ -> layout_graph s; draw s (0.0,0.0))] [pcdata "Layout Graph"];
Raw.a ~a:[a_href "tikzeditor.html?q=GEXNAgKKgImlTgAMY29udGVudA==SgAEQQ==lTgAMQXR0cmlidXRlSgAIZHJhdw==NAgRMgImlTgAMY29udGVudA==SgAEQg==lTgAMQXR0cmlidXRlSgAIZHJhdw==AgAAgABlTgAMQXR0cmlidXRlSgAIZHJhdw==lTgAMQXR0cmlidXRlSgAELT4="] [pcdata "Direct Link"]
]]
......@@ -324,16 +325,21 @@ module GraphEditor (G: GRAPH ) = struct
let saveload = Eliom_content.Html.To_dom.of_div saveload_elt in
let slider = Eliom_content.Html.To_dom.of_input slider_elt in
let ctx = canvas##(getContext (Dom_html._2d_)) in
let query = getURL "q" in
ctx##.lineCap := Js.string "round";
ctx##.font := Js.string "15px Arial";
let s = {zoom=1.5;
origin= -50.0, -50.0;
selected_obj = Empty;
graph=G.new_graph ();
graph= G.new_graph ();
canvas;
ctx;
attribute_list
} in
try (match query with Some str -> if String.sub str 0 3 = "GEX"
then s.graph<-parse_exchange_string str
| None -> ())
with _ -> ();
slider##.value := Js.string @@ string_of_float @@ (s.zoom -. 0.2 ) *. 50. ;
slider##.oninput := Dom.handler (fun _ ->
s.zoom <- 0.2 +. (float_of_string @@ Js.to_string slider##.value) /. 50.0;
......
open Eliom_content.Html.D
let text_input ?(class_ = "") ?(on_change = fun _ -> true) value =
let input2 = input ~a:[a_input_type `Text] () in
let input = Eliom_content.Html.To_dom.of_input input2 in
......@@ -27,7 +27,7 @@ let choice_input ?(class_ = "") ?(on_change = fun _ -> ()) ?(init_value=None) op
input2
let color_input ?(class_ = "") ?(on_change = fun _ -> true) value =
let input2 = input ~a:[a_input_type `Color] () in
let input = Eliom_content.Html.To_dom.of_input input2 in
input##.value := Js.string (DrawingGeom.Color.to_string (DrawingGeom.Color.parse value));
......@@ -39,3 +39,19 @@ let color_input ?(class_ = "") ?(on_change = fun _ -> true) value =
input##.oninput := Dom.handler on_input;
input##.className := Js.string class_;
input2
let rec split_attr s i =
match String.index_from_opt s i '=' with
Some j ->
let opt = String.sub s i (j-i) in
( match String.index_from_opt s (j+1) '&' with
Some k ->
(opt, String.sub s (j+1) (k-j-1))::(split_attr s (k+1))
| None -> [opt, String.sub s (j+1) ((String.length s)-j-1)])
| None -> []
let getURL s =
let query = Js.to_string Dom_html.window##.location##.search in
let m = split_attr query 1 in
List.assoc_opt s m
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment