Hi,

I have a bunch of similar graphics on a 7x7 where some lines have exceptions for the endings and connections.

- When a line ends in one of the four corners the line end has an angle of 45 degrees. - When a line takes a turn the outer corner results also in a 45 degree angle.
- Single points always use straight endings.
- Lines which end outside of a corner end with a straight line.

While I can get the desired result which a filled path I'm looking for a solution where I have to set fewer control points.

The example below shows the simpler draw alternative where I need only a start and end point versus the outline alternative where I need at least twice as many points to get the desired output.

\starttext

\startuseMPgraphic{draw}
draw hlingrid(0, 7, 1, 7, 7) withpen pencircle scaled 1/20 shifted (0.5,0.5) withcolor "darkgray" ; draw vlingrid(0, 7, 1, 7, 7) withpen pencircle scaled 1/20 shifted (0.5,0.5) withcolor "darkgray" ;
pickup pensquare scaled 1;
drawoptions(withcolor "red");
draw (1,7) -- (7,7) ;
draw (1,1) -- (3,1) -- (3,5) ;
draw (7,3) -- (5,3) -- (5,5) -- (7,5) ;
draw (7,1) ;
\stopuseMPgraphic

\startuseMPgraphic{fill}
draw hlingrid(0, 7, 1, 7, 7) withpen pencircle scaled 1/20 withcolor "darkgray" ; draw vlingrid(0, 7, 1, 7, 7) withpen pencircle scaled 1/20 withcolor "darkgray" ;
drawoptions(withcolor "green");
fill (0,6) -- (7,6) -- (6,7) -- (1,7) -- cycle ;
fill (1,0) -- (2,0) -- (3,1) -- (3,5) -- (2,5) -- (2,1) -- (0,1) -- cycle ;
fill (7,2) -- (5,2) -- (4,3) -- (4,4) -- (5,5) -- (7,5) -- (7,4) -- (5,4) -- (5,3) -- (7,3) -- cycle ;
fill (6,0) -- (7,0) -- (7,1) -- (6,1) -- cycle ;
\stopuseMPgraphic

\startcombination[2*1]
  {\scale[s=10]{\useMPgraphic{draw}}}{draw option}
  {\scale[s=10]{\useMPgraphic{fill}}}{fill option}
\stopcombination

\startoverlay
  {\scale[s=10]{\useMPgraphic{draw}}}
  {\scale[s=10]{\useMPgraphic{fill}}}
\stopoverlay

\stoptext

Wolfgang

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

Reply via email to