-let gen_trace (type s) = (); fun t tree ->
- let module T = (val (t) : Tree.Sig.S with type t = s) in
- let rec loop odot ohtml node parent =
- if node == T.nil then () else begin
- let s_node = "node" ^ (string_of_int (T.preorder tree node)) in
- fprintf odot "%s[ id=\"%s\" label=\"%s\"];\n"
- s_node s_node (Utils.QName.to_string (T.tag tree node));
+module CTable = Hashtbl.Make (K)
+
+let ctable = CTable.create 20
+let rgb x =
+ let h = K.hash x in
+ let r = h land 0xff
+ and g = (h lsr 8) land 0xff
+ and b = (h lsr 16) land 0xff
+ in
+ r, g, b
+let color ((a,b,c) as x) =
+ try
+ CTable.find ctable x
+ with
+ Not_found ->
+ let r,g,b = rgb x in
+ let s = "rgb(" ^ (string_of_int r) ^ ","
+ ^ (string_of_int g) ^ ","
+ ^ (string_of_int b) ^ ")"
+ in
+ CTable.add ctable x s;
+ s
+let text_color x =
+ let r,g,b = rgb x in
+ let av = (r + g + b) / 3 in
+ if av > 128 then "rgb(0,0,0)"
+ else "rgb(255,255,255)"
+
+
+let gen_trace (type s) = fun auto t tree ->
+ let module T = (val (t) : Tree.S with type t = s) in
+ let root = T.root tree in
+ let rec loop osvg ohtml node parent x y =
+ if node != T.nil then begin