{{/* A radial diagram of a specification and its direct relationships, drawn at build time so it needs no client-side script. */}} {{ $page := . }} {{ $groups := partialCached "spec/relations.html" . .RelPermalink }} {{ $nodes := slice }} {{ $seen := slice }} {{ range $groups }} {{ $g := . }} {{ range .pages }} {{ if not (in $seen .RelPermalink) }} {{ $seen = $seen | append .RelPermalink }} {{ $nodes = $nodes | append (dict "page" . "key" $g.key "dir" $g.dir) }} {{ end }} {{ end }} {{ end }} {{ $n := len $nodes }} {{ if $n }} {{ $cx := 340.0 }}{{ $cy := 210.0 }}{{ $rx := 225.0 }}{{ $ry := 150.0 }} {{ .Title }} and {{ $n }} related specifications {{ range site.Params.relations }} {{ end }} {{ range $i, $node := $nodes }} {{ $angle := sub (div (mul 2.0 (mul math.Pi $i)) $n) (div math.Pi 2.0) }} {{ if eq $n 2 }}{{ $angle = mul math.Pi $i }}{{ end }} {{ $ux := math.Cos $angle }}{{ $uy := math.Sin $angle }} {{ $x := add $cx (mul $rx $ux) }}{{ $y := add $cy (mul $ry $uy) }} {{ $dx := sub $x $cx }}{{ $dy := sub $y $cy }} {{ $len := math.Sqrt (add (mul $dx $dx) (mul $dy $dy)) }} {{ $x1 := add $cx (mul (div $dx $len) 46.0) }}{{ $y1 := add $cy (mul (div $dy $len) 46.0) }} {{ $x2 := sub $x (mul (div $dx $len) 15.0) }}{{ $y2 := sub $y (mul (div $dy $len) 15.0) }} {{ $marker := "" }} {{ if eq $node.dir "out" }}{{ $marker = printf `marker-end="url(#nb-arrow-%s)"` $node.key }}{{ end }} {{ if eq $node.dir "in" }}{{ $marker = printf `marker-start="url(#nb-arrow-%s)"` $node.key }}{{ end }} {{ $anchor := "middle" }}{{ $lx := $x }}{{ $ly := add $y 30.0 }} {{ if gt $ux 0.25 }}{{ $anchor = "start" }}{{ $lx = add $x 18.0 }}{{ $ly = add $y 4.0 }}{{ end }} {{ if lt $ux -0.25 }}{{ $anchor = "end" }}{{ $lx = sub $x 18.0 }}{{ $ly = add $y 4.0 }}{{ end }} {{ if and (le $ux 0.25) (ge $ux -0.25) (lt $uy 0.0) }}{{ $ly = sub $y 20.0 }}{{ end }} {{ $node.page.Title }} {{ $node.page.Title }} {{ end }} {{ $glyph := partialCached "spec/glyph.html" . .RelPermalink }} {{ replace (string $glyph) `