#This MetaPost symbol definition is licensed under CC0 1.0. See the package LICENCE.txt for details. # use with the following -attr type "value" options # -attr theme default = draws in the default brown # -attr theme inherit = draws in the symbol colour defined in the layout # -attr theme 1 = draws in red # Therion 6 does not support -attr on point mapconnection, so this code contains a hacky workaround; # by placing a point u:mapconnectiondata below the point mapconnection, the -attr from that point # will be used instead. (Note that it must appear below it in rendering order - that means any use of # -clip must also be taken into account!) #the next line is part of the hack text en "point u:mapconnectiondata" "" layout l_mapconnection_MY code metapost def l_mapconnection_MY (expr P) = T:=identity; begingroup; save arrowsize, type, arrowhead; %the length of the arrowhead, which must be bigger than the pen size by enough margin for the line's curved end not to poke past the walls of the arrowhead arrowsize:=0.4u; string theme; if known ATTR_theme: theme:=ATTR_theme; %this is part of the hack p_u_mapconnectiondata_ATTR_theme:=""; elseif known p_u_mapconnectiondata_ATTR_theme: %the same attribute, passed using a point u:mapconnectiondata %this is part of the hack theme:=p_u_mapconnectiondata_ATTR_theme; p_u_mapconnectiondata_ATTR_theme:=""; else: theme:="default"; fi; if (theme = "1"): drawoptions( withcolor (1,0,0) dashed evenly ); %red elseif (theme = "2"): drawoptions( withcolor (1,0.6,0) dashed evenly ); %orange elseif (theme = "3"): drawoptions( withcolor (0.78,0.78,0) dashed evenly ); %dark yellow elseif (theme = "4"): drawoptions( withcolor (0.46,0.78,0) dashed evenly ); %spring green elseif (theme = "5"): drawoptions( withcolor (0,0.78,0) dashed evenly ); %green elseif (theme = "6"): drawoptions( withcolor (0,0.5,0.44) dashed evenly ); %greeny teal elseif (theme = "7"): drawoptions( withcolor (0,0.8,0.87) dashed evenly ); %sky blue elseif (theme = "8"): drawoptions( withcolor (0,0,1) dashed evenly ); %navy blue elseif (theme = "9"): drawoptions( withcolor (0.5,0,1) dashed evenly ); %violet elseif (theme = "10"): drawoptions( withcolor (1,0,1) dashed evenly ); %fuchia elseif (theme = "inherit"): drawoptions( dashed evenly ); %normally black, but can be coloured by the layout else: drawoptions( withcolor (0.4,0,0) dashed dashpattern(on .1u off .5u on .1u) ); %brown fi; %shorten the line by the size of the arrow head, so that it cannot bulge out of the sides of the arrowhead thdraw ( subpath( arctime arrowsize of P, arctime ( ( arclength P ) - arrowsize ) of P ) of P ) withpen PenA; drawoptions(); path arrowhead; arrowhead:=(0,0)--( 2 * arrowsize / 5, arrowsize )--( -2 * arrowsize / 5, arrowsize )--cycle; thfill arrowhead rotated ( angle( thdir( P, 0 ) ) - 90 ) shifted ( point 0 of P ); thfill arrowhead rotated ( angle( thdir( P, length P ) ) + 90 ) shifted ( point (length P) of P ); endgroup; enddef; initsymbol("l_mapconnection_MY"); %this is part of the hack %store the attr string p_u_mapconnectiondata_ATTR_theme; def p_u_mapconnectiondata (expr P,R,S,A)= if known ATTR_theme: p_u_mapconnectiondata_ATTR_theme:=ATTR_theme; fi; enddef; initsymbol("p_u_mapconnectiondata"); endcode endlayout