Created
December 11, 2018 01:38
-
-
Save youz/de3fd47db2cb0c667aabd888e98e676d to your computer and use it in GitHub Desktop.
cd sample sources
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@require: stdja | |
@require: math | |
@require: cd | |
let testdiag toolbox = | |
let a = toolbox#obj (40pt, 85pt) ${A} in | |
let b = toolbox#obj (110pt, 85pt) ${B} in | |
let c = toolbox#obj (40pt, 25pt) ${C} in | |
let d = toolbox#obj (110pt, 25pt) ${D} in | |
let objs = List.map toolbox#draw-obj [a; b; c; d] |> List.concat in | |
let f = toolbox#draw-arr ${f} .45 -10pt a b in | |
let g = toolbox#draw-arr ${g} .5 5pt a c in | |
let h = toolbox#draw-arr ${h} .5 -10pt b d in | |
let k = toolbox#draw-arr ${k} .45 10pt c d in | |
List.concat [objs; f; g; h; k] | |
in | |
document (| | |
title = {}; | |
author = {}; | |
show-title = false; | |
show-toc =false; | |
|) '< | |
+p{ \CD.diagram(150pt)(115pt)(testdiag); } | |
> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@require: stdja | |
@require: math | |
@import: cd-util | |
let-inline ctx \insert-image w path = | |
let img = load-image path in | |
use-image-by-width img w | |
in | |
document (| | |
title = {}; | |
author = {}; | |
show-title = false; | |
show-toc = false; | |
|) '< | |
+p{ | |
\cdutil(200pt)(90pt) | |
[(`A`, ${A}, (180pt, 20pt)); | |
(`B`, ${B}, (30pt, 20pt)) | |
] | |
[(`A`, `B`, ${\text!{\insert-image(50pt)(`genbaneko.jpg`);}}, 0.7, 0.-.0.4)]; | |
} | |
+p{ | |
\cdutil(200pt)(90pt) | |
[(`neko`, ${\text!{\insert-image(80pt)(`genbaneko_.jpg`);}}, (150pt, 10pt)); | |
(`d`, ${}, (120pt, 50pt)); | |
(`logo`, ${\text!{\SATySFi;}}, (40pt, 50pt)) | |
] | |
[(`d`, `logo`, ${\text!{ヨシ!}}, 0.7, 0.-.1.)]; | |
} | |
> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@require: stdja | |
@import: cd-util | |
document (| | |
title = {}; | |
author = {}; | |
show-title = false; | |
show-toc = false; | |
|) '< | |
+p{ | |
\cdutil(305pt)(125pt) | |
[(`A`, ${A}, (30pt, 90pt)); | |
(`B`, ${B}, (90pt, 90pt)); | |
(`C`, ${C}, (150pt, 90pt)); | |
(`D`, ${D}, (210pt, 90pt)); | |
(`E`, ${E}, (270pt, 90pt)); | |
(`A'`, ${A'}, (30pt, 30pt)); | |
(`B'`, ${B'}, (90pt, 30pt)); | |
(`C'`, ${C'}, (150pt, 30pt)); | |
(`D'`, ${D'}, (210pt, 30pt)); | |
(`E'`, ${E'}, (270pt, 30pt)) | |
] | |
[(`A`, `B`, ${f}, 0.4, 1.0); | |
(`B`, `C`, ${g}, 0.4, 1.0); | |
(`C`, `D`, ${h}, 0.4, 1.0); | |
(`D`, `E`, ${j}, 0.4, 1.0); | |
(`A`, `A'`, ${l}, 0.4, 1.0); | |
(`B`, `B'`, ${m}, 0.4, 1.0); | |
(`C`, `C'`, ${n}, 0.4, 1.0); | |
(`D`, `D'`, ${p}, 0.4, 1.0); | |
(`E`, `E'`, ${q}, 0.4, 1.0); | |
(`A'`, `B'`, ${r}, 0.4, 0.-.1.); | |
(`B'`, `C'`, ${s}, 0.4, 0.-.1.); | |
(`C'`, `D'`, ${t}, 0.4, 0.-.1.); | |
(`D'`, `E'`, ${u}, 0.4, 0.-.1.) | |
]; | |
} | |
> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@require: cd | |
let-inline ctx \cdutil width height objects edges = | |
let diagf r = | |
let sz = get-font-size ctx in | |
let objs = List.map (fun (l, m, p) -> (l, r#obj p m)) objects in | |
let objg = List.map (fun (_, o) -> r#draw-obj o) objs in | |
let obj label = | |
match List.assoc string-same label objs with | |
| None -> r#obj (0pt, 0pt) ${} | |
| Some(o) -> o | |
in | |
let arrg = List.map (fun (s, e, m, t, l) -> | |
r#draw-arr m t (0pt -' (sz *' l)) (obj s) (obj e) | |
) edges in | |
List.append objg arrg |> List.concat | |
in | |
read-inline ctx {\CD.diagram(width)(height)(diagf);} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment