* [NTG-context] Rounded pens with Metapost
@ 2024-12-06 19:16 Wolfgang Schuster
2024-12-07 12:29 ` [NTG-context] " Keith McKay
2024-12-07 13:56 ` Mikael Sundqvist
0 siblings, 2 replies; 4+ messages in thread
From: Wolfgang Schuster @ 2024-12-06 19:16 UTC (permalink / raw)
To: ntg-context
Hi,
are there now better ways to create rounded pens without adding many
support points?
\starttext
\startMPpage[offset=1dk]
path Halfcircle ; Halfcircle = (1,0){up} for i = 1 upto 180 : .. ((1,0)
rotated i) endfor -- cycle ;
draw Halfcircle scaled 10 shifted (0,12) ;
pen HalfcirclePen ; HalfcirclePen := makepen Halfcircle ;
draw ((0,1) -- (1,1)) scaled 10 withpen HalfcirclePen ;
draw ((0,0) -- (0,1)) scaled 10 withpen HalfcirclePen rotated 90 ;
draw ((1,0) -- (1,1)) scaled 10 withpen HalfcirclePen rotated 270 ;
draw ((0,0) -- (1,0)) scaled 10 withpen HalfcirclePen rotated 180 ;
\stopMPpage
\startMPpage[offset=1dk]
path RoundedRectangle ; RoundedRectangle = (-1,0){up} for i = 180 step
-1 until 89 : .. ((1,0) rotated i) endfor -- (1,1){down} for i = 360
step -1 until 269 : .. ((1,0) rotated i shifted (0,1)) endfor -- cycle ;
draw RoundedRectangle scaled 10 shifted (0,12) ;
pen RoundedRectanglePen ; RoundedRectanglePen := makepen RoundedRectangle ;
draw ((1,0) -- (1,1)) scaled 10 withpen RoundedRectanglePen
reflectedabout (up,down) rotated 270 ;
draw ((0,0) -- (1,0)) scaled 10 withpen RoundedRectanglePen rotated 180 ;
\stopMPpage
\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] 4+ messages in thread
* [NTG-context] Re: Rounded pens with Metapost
2024-12-06 19:16 [NTG-context] Rounded pens with Metapost Wolfgang Schuster
@ 2024-12-07 12:29 ` Keith McKay
2024-12-07 13:02 ` Wolfgang Schuster
2024-12-07 13:56 ` Mikael Sundqvist
1 sibling, 1 reply; 4+ messages in thread
From: Keith McKay @ 2024-12-07 12:29 UTC (permalink / raw)
To: ntg-context
[-- Attachment #1.1: Type: text/plain, Size: 2653 bytes --]
Hi Wolfgang
I thought using the metapost variable tcircle as a pen would work but
for some reason it does not give rounded corners for the square in the
first MPpage. Not a solution unfortunately.
Best Wishes
Keith
path Tcircle; Tcircle := tcircle;
draw Tcircle scaled 20 shifted(0,24)withcolor red;
pen TcirclePen ; TcirclePen := makepen Tcircle ;
draw ((0,1)-- (1,1))scaled 10 withpen TcirclePen shifted
(12,12)withcolor red;
draw ((0,0)-- (0,1))scaled 10 withpen TcirclePen rotated 90 shifted
(12,12)withcolor red;
draw ((1,0)-- (1,1))scaled 10 withpen TcirclePen rotated 270 shifted
(12,12)withcolor red;
draw ((0,0)-- (1,0))scaled 10 withpen TcirclePen rotated 180 shifted
(12,12)withcolor red;
On 06/12/2024 19:16, Wolfgang Schuster wrote:
> Hi,
>
> are there now better ways to create rounded pens without adding many
> support points?
>
> \starttext
>
> \startMPpage[offset=1dk]
>
> path Halfcircle ; Halfcircle = (1,0){up} for i = 1 upto 180 : ..
> ((1,0) rotated i) endfor -- cycle ;
>
> draw Halfcircle scaled 10 shifted (0,12) ;
>
> pen HalfcirclePen ; HalfcirclePen := makepen Halfcircle ;
>
> draw ((0,1) -- (1,1)) scaled 10 withpen HalfcirclePen ;
> draw ((0,0) -- (0,1)) scaled 10 withpen HalfcirclePen rotated 90 ;
> draw ((1,0) -- (1,1)) scaled 10 withpen HalfcirclePen rotated 270 ;
> draw ((0,0) -- (1,0)) scaled 10 withpen HalfcirclePen rotated 180 ;
>
> \stopMPpage
>
> \startMPpage[offset=1dk]
>
> path RoundedRectangle ; RoundedRectangle = (-1,0){up} for i = 180 step
> -1 until 89 : .. ((1,0) rotated i) endfor -- (1,1){down} for i = 360
> step -1 until 269 : .. ((1,0) rotated i shifted (0,1)) endfor -- cycle ;
>
> draw RoundedRectangle scaled 10 shifted (0,12) ;
>
> pen RoundedRectanglePen ; RoundedRectanglePen := makepen
> RoundedRectangle ;
>
> draw ((1,0) -- (1,1)) scaled 10 withpen RoundedRectanglePen
> reflectedabout (up,down) rotated 270 ;
> draw ((0,0) -- (1,0)) scaled 10 withpen RoundedRectanglePen rotated 180 ;
>
> \stopMPpage
>
> \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
> ___________________________________________________________________________________
>
[-- Attachment #1.2: Type: text/html, Size: 6693 bytes --]
[-- Attachment #2: Type: text/plain, Size: 511 bytes --]
___________________________________________________________________________________
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] 4+ messages in thread
* [NTG-context] Re: Rounded pens with Metapost
2024-12-07 12:29 ` [NTG-context] " Keith McKay
@ 2024-12-07 13:02 ` Wolfgang Schuster
0 siblings, 0 replies; 4+ messages in thread
From: Wolfgang Schuster @ 2024-12-07 13:02 UTC (permalink / raw)
To: mailing list for ConTeXt users, Keith McKay
[-- Attachment #1.1: Type: text/plain, Size: 1431 bytes --]
Keith McKay schrieb am 07.12.2024 um 13:29:
>
> Hi Wolfgang
>
> I thought using the metapost variable tcircle as a pen would work but
> for some reason it does not give rounded corners for the square in the
> first MPpage. Not a solution unfortunately.
>
> Best Wishes
>
> Keith
>
> path Tcircle; Tcircle := tcircle;
>
> draw Tcircle scaled 20 shifted(0,24)withcolor red;
>
> pen TcirclePen ; TcirclePen := makepen Tcircle ;
>
> draw ((0,1)-- (1,1))scaled 10 withpen TcirclePen shifted
> (12,12)withcolor red;
>
> draw ((0,0)-- (0,1))scaled 10 withpen TcirclePen rotated 90 shifted
> (12,12)withcolor red;
>
> draw ((1,0)-- (1,1))scaled 10 withpen TcirclePen rotated 270 shifted
> (12,12)withcolor red;
>
> draw ((0,0)-- (1,0))scaled 10 withpen TcirclePen rotated 180 shifted
> (12,12)withcolor red;
>
This is the first thing I tried but it doesn't work with pens.
The following example shows how the curve gets rounder with the number
of steps.
\starttext
\doloopoverlist
{90,60,45,30,20,15,10,5,1}
{\recursestring:
\startMPcode
draw ((-1cm,0)--(5cm,0)) shifted (0,1cm) withcolor (1,0,0);
pen testpen ; testpen := makepen ((1,0){up} for i = 1 step
\recursestring\space until 181 : .. ((1,0) rotated i) endfor -- cycle) ;
draw (0,0)--(4cm,0) withpen testpen scaled 1cm;
\stopMPcode
\blank}
\stoptext
Wolfgang
[-- Attachment #1.2: Type: text/html, Size: 4280 bytes --]
[-- Attachment #2: Type: text/plain, Size: 511 bytes --]
___________________________________________________________________________________
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] 4+ messages in thread
* [NTG-context] Re: Rounded pens with Metapost
2024-12-06 19:16 [NTG-context] Rounded pens with Metapost Wolfgang Schuster
2024-12-07 12:29 ` [NTG-context] " Keith McKay
@ 2024-12-07 13:56 ` Mikael Sundqvist
1 sibling, 0 replies; 4+ messages in thread
From: Mikael Sundqvist @ 2024-12-07 13:56 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1: Type: text/plain, Size: 2481 bytes --]
Hi,
as far as I have understood one can only either use a circle (and
then, lowlevel, Postscript/PDF uses that) or a polygon (and then that
is used low-level).
Since a few weeks (not sure if it is in distribution yet) there is
also a penstroked macro that imitates the penstroke a bit (one can
make variants of it). Example:
\startMPpage[offset=1dk]
fill function(2,"x","sin(x)",0,epsed(6*pi),0.1)
scaled 20
penstroked
function(2,"x","1+7*(sin(x)^2)",0,epsed(pi),0.001)
withcolor "orange" ;
\stopMPpage
/Mikael
On Fri, Dec 6, 2024 at 8:19 PM Wolfgang Schuster
<wolfgang.schuster.lists@gmail.com> wrote:
>
> Hi,
>
> are there now better ways to create rounded pens without adding many
> support points?
>
> \starttext
>
> \startMPpage[offset=1dk]
>
> path Halfcircle ; Halfcircle = (1,0){up} for i = 1 upto 180 : .. ((1,0)
> rotated i) endfor -- cycle ;
>
> draw Halfcircle scaled 10 shifted (0,12) ;
>
> pen HalfcirclePen ; HalfcirclePen := makepen Halfcircle ;
>
> draw ((0,1) -- (1,1)) scaled 10 withpen HalfcirclePen ;
> draw ((0,0) -- (0,1)) scaled 10 withpen HalfcirclePen rotated 90 ;
> draw ((1,0) -- (1,1)) scaled 10 withpen HalfcirclePen rotated 270 ;
> draw ((0,0) -- (1,0)) scaled 10 withpen HalfcirclePen rotated 180 ;
>
> \stopMPpage
>
> \startMPpage[offset=1dk]
>
> path RoundedRectangle ; RoundedRectangle = (-1,0){up} for i = 180 step
> -1 until 89 : .. ((1,0) rotated i) endfor -- (1,1){down} for i = 360
> step -1 until 269 : .. ((1,0) rotated i shifted (0,1)) endfor -- cycle ;
>
> draw RoundedRectangle scaled 10 shifted (0,12) ;
>
> pen RoundedRectanglePen ; RoundedRectanglePen := makepen RoundedRectangle ;
>
> draw ((1,0) -- (1,1)) scaled 10 withpen RoundedRectanglePen
> reflectedabout (up,down) rotated 270 ;
> draw ((0,0) -- (1,0)) scaled 10 withpen RoundedRectanglePen rotated 180 ;
>
> \stopMPpage
>
> \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
> ___________________________________________________________________________________
[-- Attachment #2: image.png --]
[-- Type: image/png, Size: 13056 bytes --]
[-- Attachment #3: Type: text/plain, Size: 511 bytes --]
___________________________________________________________________________________
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] 4+ messages in thread
end of thread, other threads:[~2024-12-07 13:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-06 19:16 [NTG-context] Rounded pens with Metapost Wolfgang Schuster
2024-12-07 12:29 ` [NTG-context] " Keith McKay
2024-12-07 13:02 ` Wolfgang Schuster
2024-12-07 13:56 ` Mikael Sundqvist
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).