source: Deliverables/Dissemination/final-review/wp5/Pics/ternary1.ml @ 3282

Last change on this file since 3282 was 3282, checked in by regisgia, 7 years ago
  • WP5 slides for the final review.
File size: 1.7 KB
Line 
1
2open Mlpost
3
4
5(* Helpers *)
6
7let tex = Box.tex ~dx:(Num.cm 0.2) ~dy:(Num.cm 0.1) ~stroke:(Some Color.black)
8
9let texttt name s = tex ~name ("\\texttt{" ^ s ^ "}")
10
11let middle p1 p2 =
12  let p = Point.add p1 p2 in
13  Point.mult (Num.of_float 0.5) p
14
15let pathp = Path.pathp ~style:Path.jLine
16
17
18(* Boxes *)
19
20let cond = texttt "cond" "x?"
21let res1 = texttt "res1" "y+2*z"
22let res2 = texttt "res2" "z"
23
24let boxes =
25  let res = Box.vbox ~padding:(Num.cm 0.1) [res1 ; res2] in
26  Box.hbox ~padding:(Num.cm 1.) [cond ; res]
27
28
29(* Arrows *)
30
31let edge = 0.5
32
33let get s = Box.get s boxes
34
35let entry =
36  let p2 = Box.west (get "cond") in
37  let p1 = Point.shift (Point.pt (Num.cm (-.edge), Num.zero)) p2 in
38  [Arrow.simple ~dashed:Dash.evenly (pathp [p1 ; p2])]
39
40let exits =
41  let p1 = Box.east (get "res1") in
42  let p2 = Point.shift (Point.pt (Num.cm edge, Num.zero)) p1 in
43  let p3 = Box.east (get "res2") in
44  let p4 = Point.pt (Point.xpart p2, Point.ypart p3) in
45  [Arrow.simple ~dashed:Dash.evenly (pathp [p1 ; p2]) ;
46   Arrow.simple ~dashed:Dash.evenly (pathp [p3 ; p4])]
47
48let branch =
49  let p1 = Box.east (get "cond") in
50  let p3 = Box.west (get "res1") in
51  let p2 = Point.pt (Point.xpart (middle p1 p3), Point.ypart p1) in
52  let p4 = Box.west (get "res2") in
53  let ptmp1 = Point.pt (Point.xpart p2, Point.ypart p3) in
54  let ptmp2 = Point.pt (Point.xpart p2, Point.ypart p4) in
55  [Path.draw (pathp [p1 ; p2]) ;
56   Arrow.simple (pathp [p2 ; ptmp1 ; p3]) ;
57   Arrow.simple (pathp [p2 ; ptmp2 ; p4])]
58
59let arrows = Box.group (List.map Box.pic (entry @ exits @ branch))
60
61
62(* Ternary *)
63
64let ternary = Box.group  [boxes ; arrows]
65
66
67(* Output pictures *)
68
69let result = ternary
70let result = Box.draw result
71
72let _ = Metapost.emit "ternary1" result
Note: See TracBrowser for help on using the repository browser.