input boxes; % % % SETTINGS % % % font stuff defaultfont := "cmr10"; defaultscale := 2; % Generate EPS prologues := 1; % unit u := cm; % ring radius, ring thickness rr := 7.5u; rthick := 2bp; % node diameter, node tickness nr := 0.3u; nthick := 1.5bp; % arrow thickness, arrowhead length athick := 0.5bp; ahlength := 8bp; % direct arrow thickness, arrowhead length dathick := 2bp; dalength := 12bp; % label offset labeloffset := 15bp; % % DON'T MESS WITH THIS % % node method draws a node. % % parameters: % node index into nodes[] % angle, north is 0 % color % label location: lft, rt, top, bot, ulft, urt, llft, lrt % label text def node(expr isKey)(suffix $)(expr $$)(expr $$$)(suffix #)(text ##) = path p; pair c; path n; path r; if isKey > 0: r := keyring; else: r := ring; fi % p is path from circle center outwards. % do weirdo calculation to make angle be clockwise p := (rr, rr) -- (rr, rr) + 2rr * dir (90 + (-1 * $$)); % c is center of node c := r intersectionpoint p; % n is the node path % $ := fullcircle scaled 2nr shifted c; % draw the node circleit.$(btex etex); $.c = c; $.dx = $.dy; $.dx = nr; fill bpath $ withcolor $$$; drawoptions(withpen pencircle scaled nthick); drawboxed($); drawoptions(); % do the label label.#(##, c); enddef; % % Connects with % def connect(expr $$$)(suffix $)(suffix $$) = pair s, d, m; path p; % path from middle to node's c p := $.c -- $$.c; % line that goes from middle through p path q; q = p rotatedaround(1/2[$c.,$$.c], 90); % frac is the normalized distance between two nodes. dist := ((xpart $.c - xpart $$.c) ++ (ypart $.c - ypart $$.c)); frac := dist/(2rr); path pp; if ($$$ > 0): pp := $.c .. q intersectionpoint outerring .. $$.c; else: pp := $.c .. frac[q intersectionpoint p, (rr,rr)] .. $$.c; fi % intersection between that path and circle s = pp intersectionpoint bpath $; d = pp intersectionpoint bpath $$; if $$$ > 0: pp := s .. q intersectionpoint outerring .. d; else: pp := s .. frac[q intersectionpoint p, (rr,rr)] .. d; fi drawarrow pp withpen pencircle scaled athick; enddef; % % Directly connects with % def directconnect(suffix $)(suffix $$) = pair s, d; path p; % path from middle to node's c p := $.c -- $$.c; path pp; % intersection between that path and circle s = p intersectionpoint bpath $; d = p intersectionpoint bpath $$; pp := s -- d; drawarrow pp withpen pencircle scaled dathick; enddef; def init_chord = path ring; path outerring; path keyring; ring := fullcircle scaled 2rr shifted (rr, rr); outerring := fullcircle scaled 2.15rr shifted (1rr, 1rr); draw ring withpen pencircle scaled rthick; % draw outerring withpen pencircle scaled nthick; keyring := fullcircle scaled 2.3rr shifted (rr, rr); % draw keyring withpen pencircle scaled nthick; enddef;