* [NTG-context] Metapost lines with fancy line endings and connections
@ 2024-12-01 9:51 Wolfgang Schuster
2024-12-01 10:45 ` [NTG-context] " Bruce Horrocks
0 siblings, 1 reply; 9+ messages in thread
From: Wolfgang Schuster @ 2024-12-01 9:51 UTC (permalink / raw)
To: ntg-context
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 9+ messages in thread
* [NTG-context] Re: Metapost lines with fancy line endings and connections
2024-12-01 9:51 [NTG-context] Metapost lines with fancy line endings and connections Wolfgang Schuster
@ 2024-12-01 10:45 ` Bruce Horrocks
2024-12-01 10:54 ` Bruce Horrocks
2024-12-01 12:08 ` Wolfgang Schuster
0 siblings, 2 replies; 9+ messages in thread
From: Bruce Horrocks @ 2024-12-01 10:45 UTC (permalink / raw)
To: ntg-context mailing list
> On 1 Dec 2024, at 09:51, Wolfgang Schuster <wolfgang.schuster.lists@gmail.com> wrote:
>
> 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.
Draw the paths two grid squares sorter and at each end draw a “dot” which is a triangle of the right direction and shading?
So your first line
draw (1,7) -- (7,7) ;
becomes
triangle_dot_bottom_right_fill (1,7) ; draw (2,6) ; triangle_dot_bottom_left_fill (7,7) ;
If there are load of them then it might be easier to write a macro to walk the (1,7) — (7,7) path and insert “dots” at the changes of direction.
Regards,
—
Bruce Horrocks
Hampshire, UK
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 9+ messages in thread
* [NTG-context] Re: Metapost lines with fancy line endings and connections
2024-12-01 10:45 ` [NTG-context] " Bruce Horrocks
@ 2024-12-01 10:54 ` Bruce Horrocks
2024-12-01 11:34 ` Hans Hagen via ntg-context
2024-12-01 12:08 ` Wolfgang Schuster
1 sibling, 1 reply; 9+ messages in thread
From: Bruce Horrocks @ 2024-12-01 10:54 UTC (permalink / raw)
To: ntg-context mailing list
> On 1 Dec 2024, at 10:45, Bruce Horrocks <ntg@scorecrow.com> wrote:
>
>
>
>> On 1 Dec 2024, at 09:51, Wolfgang Schuster <wolfgang.schuster.lists@gmail.com> wrote:
>>
>> 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.
>
> Draw the paths two grid squares sorter and at each end draw a “dot” which is a triangle of the right direction and shading?
s/sorter/shorter/
>
> So your first line
>
> draw (1,7) -- (7,7) ;
>
> becomes
>
> triangle_dot_bottom_right_fill (1,7) ; draw (2,6) ; triangle_dot_bottom_left_fill (7,7) ;
triangle_dot_bottom_right_fill (1,7) ; draw (2,7) -- (6,7) ; triangle_dot_bottom_left_fill (7,7) ;
<sigh> Sorry, brain not in gear
>
> If there are load of them then it might be easier to write a macro to walk the (1,7) — (7,7) path and insert “dots” at the changes of direction.
>
> Regards,
—
Bruce Horrocks
Hampshire, UK
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 9+ messages in thread
* [NTG-context] Re: Metapost lines with fancy line endings and connections
2024-12-01 10:54 ` Bruce Horrocks
@ 2024-12-01 11:34 ` Hans Hagen via ntg-context
2024-12-01 12:24 ` Wolfgang Schuster
0 siblings, 1 reply; 9+ messages in thread
From: Hans Hagen via ntg-context @ 2024-12-01 11:34 UTC (permalink / raw)
To: ntg-context; +Cc: Hans Hagen
On 12/1/2024 11:54 AM, Bruce Horrocks wrote:
> <sigh> Sorry, brain not in gear
so once you're rebooted, you can figure out the logic behind this:
linecap := butt ;
linejoin := beveled ;
or even
pickup pensquare rotated -60 scaled (1/sqrt(2)) ;
linecap := 1 ;
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 9+ messages in thread
* [NTG-context] Re: Metapost lines with fancy line endings and connections
2024-12-01 10:45 ` [NTG-context] " Bruce Horrocks
2024-12-01 10:54 ` Bruce Horrocks
@ 2024-12-01 12:08 ` Wolfgang Schuster
1 sibling, 0 replies; 9+ messages in thread
From: Wolfgang Schuster @ 2024-12-01 12:08 UTC (permalink / raw)
To: mailing list for ConTeXt users, Bruce Horrocks
Bruce Horrocks schrieb am 01.12.2024 um 11:45:
>
>> On 1 Dec 2024, at 09:51, Wolfgang Schuster <wolfgang.schuster.lists@gmail.com> wrote:
>>
>> 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.
> Draw the paths two grid squares sorter and at each end draw a “dot” which is a triangle of the right direction and shading?
>
> So your first line
>
> draw (1,7) -- (7,7) ;
>
> becomes
>
> triangle_dot_bottom_right_fill (1,7) ; draw (2,6) ; triangle_dot_bottom_left_fill (7,7) ;
>
> If there are load of them then it might be easier to write a macro to walk the (1,7) — (7,7) path and insert “dots” at the changes of direction.
I had this in my mind but wasn't sure if this is the best solution.
Using a macro to create the line is a must here but I have to think how
to set which delimiters for the line should be used (using different
macros for each variation or passing the shape as argument).
BTW: Use && to connect the parts of the line to avoid graphical errors
in your pdf viewer.
\startMPpage[offset=1pt]
pickup pensquare scaled 1 ;
draw (0,0) ;
draw (1,0) ;
draw (0,2) && (1,2) ;
\stopMPpage
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 9+ messages in thread
* [NTG-context] Re: Metapost lines with fancy line endings and connections
2024-12-01 11:34 ` Hans Hagen via ntg-context
@ 2024-12-01 12:24 ` Wolfgang Schuster
2024-12-01 13:02 ` Mikael Sundqvist
0 siblings, 1 reply; 9+ messages in thread
From: Wolfgang Schuster @ 2024-12-01 12:24 UTC (permalink / raw)
To: mailing list for ConTeXt users, Hans Hagen via ntg-context
Hans Hagen via ntg-context schrieb am 01.12.2024 um 12:34:
> On 12/1/2024 11:54 AM, Bruce Horrocks wrote:
>
>> <sigh> Sorry, brain not in gear
>
> so once you're rebooted, you can figure out the logic behind this:
>
> linecap := butt ;
> linejoin := beveled ;
This doesn't result in the desired output I want.
> or even
>
> pickup pensquare rotated -60 scaled (1/sqrt(2)) ;
> linecap := 1 ;
I played with custom pens but failed to create a working triangle pen.
I'll take another look into it because a few custom pens can draw all lines.
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 9+ messages in thread
* [NTG-context] Re: Metapost lines with fancy line endings and connections
2024-12-01 12:24 ` Wolfgang Schuster
@ 2024-12-01 13:02 ` Mikael Sundqvist
2024-12-01 13:13 ` Hans Hagen
2024-12-01 13:56 ` Wolfgang Schuster
0 siblings, 2 replies; 9+ messages in thread
From: Mikael Sundqvist @ 2024-12-01 13:02 UTC (permalink / raw)
To: mailing list for ConTeXt users
Hi
On Sun, Dec 1, 2024 at 1:28 PM Wolfgang Schuster
<wolfgang.schuster.lists@gmail.com> wrote:
>
> Hans Hagen via ntg-context schrieb am 01.12.2024 um 12:34:
> > On 12/1/2024 11:54 AM, Bruce Horrocks wrote:
> >
> >> <sigh> Sorry, brain not in gear
> >
> > so once you're rebooted, you can figure out the logic behind this:
> >
> > linecap := butt ;
> > linejoin := beveled ;
>
> This doesn't result in the desired output I want.
> > or even
> >
> > pickup pensquare rotated -60 scaled (1/sqrt(2)) ;
> > linecap := 1 ;
>
> I played with custom pens but failed to create a working triangle pen.
> I'll take another look into it because a few custom pens can draw all lines.
\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" ;
pen pentriangle ;
pentriangle := (makepen ((0,0) -- (1,0) -- (1,1) -- cycle) shifted
(-1/2,-1/2)) scaled 1 ;
drawoptions(withcolor "red");
pickup pensquare scaled 1;
draw (1,7) -- (7,7) ;
draw (7,1) ;
draw (5,4) ;
pickup pentriangle ;
draw (1,1) -- (2,1) withpen pentriangle rotated 90 ;
draw (3,1) -- (3,5) withpen pentriangle rotated 180 ;
draw (7,3) -- (5,3) withpen pentriangle rotated 90 ;
draw (7,5) -- (5,5) withpen pentriangle rotated 0 ;
\stopuseMPgraphic
seems to work here. But I happily admit it is a bit cumbersome...
/Mikael
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 9+ messages in thread
* [NTG-context] Re: Metapost lines with fancy line endings and connections
2024-12-01 13:02 ` Mikael Sundqvist
@ 2024-12-01 13:13 ` Hans Hagen
2024-12-01 13:56 ` Wolfgang Schuster
1 sibling, 0 replies; 9+ messages in thread
From: Hans Hagen @ 2024-12-01 13:13 UTC (permalink / raw)
To: ntg-context
On 12/1/2024 2:02 PM, Mikael Sundqvist wrote:
> Hi
>
> On Sun, Dec 1, 2024 at 1:28 PM Wolfgang Schuster
> <wolfgang.schuster.lists@gmail.com> wrote:
>>
>> Hans Hagen via ntg-context schrieb am 01.12.2024 um 12:34:
>>> On 12/1/2024 11:54 AM, Bruce Horrocks wrote:
>>>
>>>> <sigh> Sorry, brain not in gear
>>>
>>> so once you're rebooted, you can figure out the logic behind this:
>>>
>>> linecap := butt ;
>>> linejoin := beveled ;
>>
>> This doesn't result in the desired output I want.
>>> or even
>>>
>>> pickup pensquare rotated -60 scaled (1/sqrt(2)) ;
>>> linecap := 1 ;
>>
>> I played with custom pens but failed to create a working triangle pen.
>> I'll take another look into it because a few custom pens can draw all lines.
>
> \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" ;
> pen pentriangle ;
> pentriangle := (makepen ((0,0) -- (1,0) -- (1,1) -- cycle) shifted
> (-1/2,-1/2)) scaled 1 ;
> drawoptions(withcolor "red");
> pickup pensquare scaled 1;
> draw (1,7) -- (7,7) ;
> draw (7,1) ;
> draw (5,4) ;
> pickup pentriangle ;
> draw (1,1) -- (2,1) withpen pentriangle rotated 90 ;
> draw (3,1) -- (3,5) withpen pentriangle rotated 180 ;
> draw (7,3) -- (5,3) withpen pentriangle rotated 90 ;
> draw (7,5) -- (5,5) withpen pentriangle rotated 0 ;
> \stopuseMPgraphic
>
> seems to work here. But I happily admit it is a bit cumbersome...
i wonder of we can use our new secret penstroked feature but i'm not in
that mode now,
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 9+ messages in thread
* [NTG-context] Re: Metapost lines with fancy line endings and connections
2024-12-01 13:02 ` Mikael Sundqvist
2024-12-01 13:13 ` Hans Hagen
@ 2024-12-01 13:56 ` Wolfgang Schuster
1 sibling, 0 replies; 9+ messages in thread
From: Wolfgang Schuster @ 2024-12-01 13:56 UTC (permalink / raw)
To: mailing list for ConTeXt users, Mikael Sundqvist
Mikael Sundqvist schrieb am 01.12.2024 um 14:02:
> Hi
>
> On Sun, Dec 1, 2024 at 1:28 PM Wolfgang Schuster
> <wolfgang.schuster.lists@gmail.com> wrote:
>> Hans Hagen via ntg-context schrieb am 01.12.2024 um 12:34:
>>> On 12/1/2024 11:54 AM, Bruce Horrocks wrote:
>>>
>>>> <sigh> Sorry, brain not in gear
>>> so once you're rebooted, you can figure out the logic behind this:
>>>
>>> linecap := butt ;
>>> linejoin := beveled ;
>> This doesn't result in the desired output I want.
>>> or even
>>>
>>> pickup pensquare rotated -60 scaled (1/sqrt(2)) ;
>>> linecap := 1 ;
>> I played with custom pens but failed to create a working triangle pen.
>> I'll take another look into it because a few custom pens can draw all lines.
> \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" ;
> pen pentriangle ;
> pentriangle := (makepen ((0,0) -- (1,0) -- (1,1) -- cycle) shifted
> (-1/2,-1/2)) scaled 1 ;
> drawoptions(withcolor "red");
> pickup pensquare scaled 1;
> draw (1,7) -- (7,7) ;
> draw (7,1) ;
> draw (5,4) ;
> pickup pentriangle ;
> draw (1,1) -- (2,1) withpen pentriangle rotated 90 ;
> draw (3,1) -- (3,5) withpen pentriangle rotated 180 ;
> draw (7,3) -- (5,3) withpen pentriangle rotated 90 ;
> draw (7,5) -- (5,5) withpen pentriangle rotated 0 ;
> \stopuseMPgraphic
>
> seems to work here. But I happily admit it is a bit cumbersome...
It's a good starting point and I can work with it.
When I look at your pen setting it's possible I forgot the parentheses
before the shift operation.
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-12-01 13:58 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-01 9:51 [NTG-context] Metapost lines with fancy line endings and connections Wolfgang Schuster
2024-12-01 10:45 ` [NTG-context] " Bruce Horrocks
2024-12-01 10:54 ` Bruce Horrocks
2024-12-01 11:34 ` Hans Hagen via ntg-context
2024-12-01 12:24 ` Wolfgang Schuster
2024-12-01 13:02 ` Mikael Sundqvist
2024-12-01 13:13 ` Hans Hagen
2024-12-01 13:56 ` Wolfgang Schuster
2024-12-01 12:08 ` Wolfgang Schuster
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).