* [NTG-context] Envelopes and shaded paths
@ 2024-09-21 16:49 Keith McKay
2024-09-21 18:33 ` [NTG-context] " Florent Michel
2024-09-21 18:37 ` Florent Michel
0 siblings, 2 replies; 4+ messages in thread
From: Keith McKay @ 2024-09-21 16:49 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 1622 bytes --]
Hi,
I have been playing about with envelopes to produce shaded paths as
described in the new LuaMetFun manual, see page 105 therein. Using the
code below I wanted to produce a shaded path, in this case a curve and
then rotating it in 5 degree steps from 0 to 355 degrees to produce a
kind of spiral. Here is the code:
\startMPpage
pair A,B; path p, psubPath, asPathEnvelope; A = (0cm,0cm);B = (5cm,0cm);
p = A{dir 60}.. B; fill fullsquare scaled 12cm withcolor
0.5[blue,white]; for i = 0 step 5 until 355: psubPath := (subpath((0.1 *
length p), (1 * length p))of p)rotated i; asPathEnvelope := envelope
pensquare scaled 0.5mm of psubPath; fill asPathEnvelope rotated i
yscaled 1 withshademethod "linear" withshadecolors
(0.5[blue,white],white); endfor; \stopMPpage
I had expected to get a series of curves where the outer point of the
curve was white, shading down to 0.5[blue,white]at the inner point of
the curve.
I was expecting the shading to remain that way, however, as the curve is
rotated round, the shading effect slowly changes until it is reversed,
and as it
continues to be rotated it returns to it original shading. Although I
quite like that effect, it's a nice feature, I would like to be able to
produce the shading
the way I wanted. A while back Hans explained to me why this happened
and how I could remedy it, but unfortunately my aged memory has failed
me and I
cant remember how to do it. So I thought the youthful brains of the
ConTeXt group may be able to help out, and it might be of interest in
any case. I
attach a pdf of the spiral effect.
Best Wishes
Keith McKay
[-- Attachment #1.2: Type: text/html, Size: 5670 bytes --]
[-- Attachment #2: spiral.pdf --]
[-- Type: application/pdf, Size: 12849 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
* [NTG-context] Re: Envelopes and shaded paths
2024-09-21 16:49 [NTG-context] Envelopes and shaded paths Keith McKay
@ 2024-09-21 18:33 ` Florent Michel
2024-09-21 18:37 ` Florent Michel
1 sibling, 0 replies; 4+ messages in thread
From: Florent Michel @ 2024-09-21 18:33 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 3502 bytes --]
Hi,
It's probably not the best solution as it uses the ‘old’ shading method,
but seems to give the result you were expecting:
\startMPpage
pair A,B;
path p, psubPath, asPathEnvelope;
A = (0cm,0cm);B = (5cm,0cm);
p = A{dir 60} .. B;
fill fullsquare scaled 12cm withcolor 0.5[blue,white];
for i = 0 step 5 until 355:
psubPath := (subpath((0.1 * length p), (1 * length p) ) of p) rotated i;
asPathEnvelope := envelope pensquare scaled 0.5mm of psubPath;
fill asPathEnvelope
withshade define_linear_shade((0,0), (cosd(i) * 6cm, sind(i) * 6cm),
0.5[blue,white], white);
endfor;
\stopMPpage
(This code generates about twice as many lines as in your pdf; this can be
reversed by changing the step from 5 to 10.)
My guess is that in your example the shading direction is not rotated with
the path. It should be possible to rotate it by properly using
`withshadedirection` (see section 8.3.3 in the metafun manual),
although after experimenting a bit I could not find an easy way to make it
work. (This does not say much though - I'm definitely not very experienced
in MetaFun.)
Best wishes,
Florent
Le sam. 21 sept. 2024 à 17:51, Keith McKay <mckaymeister@gmail.com> a
écrit :
> Hi,
>
> I have been playing about with envelopes to produce shaded paths as
> described in the new LuaMetFun manual, see page 105 therein. Using the code
> below I wanted to produce a shaded path, in this case a curve and then
> rotating it in 5 degree steps from 0 to 355 degrees to produce a kind of
> spiral. Here is the code:
>
> \startMPpage
>
> pair A,B; path p, psubPath, asPathEnvelope; A = (0cm,0cm);B = (5cm,0cm); p
> = A{dir 60} .. B; fill fullsquare scaled 12cm withcolor 0.5[blue,white]; for
> i = 0 step 5 until 355: psubPath := (subpath((0.1 * length p), (1 *
> length p) ) of p)rotated i; asPathEnvelope := envelope pensquare scaled
> 0.5mm of psubPath; fill asPathEnvelope rotated i yscaled 1
> withshademethod "linear" withshadecolors (0.5[blue,white],white) ; endfor;
> \stopMPpage
>
> I had expected to get a series of curves where the outer point of the
> curve was white, shading down to 0.5[blue,white] at the inner point of
> the curve.
>
> I was expecting the shading to remain that way, however, as the curve is
> rotated round, the shading effect slowly changes until it is reversed, and
> as it
>
> continues to be rotated it returns to it original shading. Although I
> quite like that effect, it's a nice feature, I would like to be able to
> produce the shading
>
> the way I wanted. A while back Hans explained to me why this happened and
> how I could remedy it, but unfortunately my aged memory has failed me and I
>
> cant remember how to do it. So I thought the youthful brains of the
> ConTeXt group may be able to help out, and it might be of interest in any
> case. I
>
> attach a pdf of the spiral effect.
>
> Best Wishes
>
> Keith McKay
>
>
> ___________________________________________________________________________________
> 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: 8222 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: Envelopes and shaded paths
2024-09-21 16:49 [NTG-context] Envelopes and shaded paths Keith McKay
2024-09-21 18:33 ` [NTG-context] " Florent Michel
@ 2024-09-21 18:37 ` Florent Michel
2024-09-22 15:06 ` Keith McKay
1 sibling, 1 reply; 4+ messages in thread
From: Florent Michel @ 2024-09-21 18:37 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 3033 bytes --]
Apologies for the double email. Seems I slightly misunderstood what you
aimed for - the corrected (assuming there is no other misunderstanding from
me) is:
\startMPpage
pair A,B;
path p, psubPath, asPathEnvelope;
A = (0cm,0cm);B = (5cm,0cm);
p = A{dir 60} .. B;
fill fullsquare scaled 12cm withcolor 0.5[blue,white];
for i = 0 step 5 until 355:
psubPath := (subpath((0.1 * length p), (1 * length p) ) of p) rotated i;
asPathEnvelope := envelope pensquare scaled 0.5mm of psubPath;
fill asPathEnvelope
withshade define_linear_shade((cosd(i) * 0.5cm, sind(i) * 0.5cm),
(cosd(i) * 5cm, sind(i) * 5cm), 0.5[blue,white], white);
endfor;
\stopMPpage
Le sam. 21 sept. 2024 à 17:51, Keith McKay <mckaymeister@gmail.com> a
écrit :
> Hi,
>
> I have been playing about with envelopes to produce shaded paths as
> described in the new LuaMetFun manual, see page 105 therein. Using the code
> below I wanted to produce a shaded path, in this case a curve and then
> rotating it in 5 degree steps from 0 to 355 degrees to produce a kind of
> spiral. Here is the code:
>
> \startMPpage
>
> pair A,B; path p, psubPath, asPathEnvelope; A = (0cm,0cm);B = (5cm,0cm); p
> = A{dir 60} .. B; fill fullsquare scaled 12cm withcolor 0.5[blue,white]; for
> i = 0 step 5 until 355: psubPath := (subpath((0.1 * length p), (1 *
> length p) ) of p)rotated i; asPathEnvelope := envelope pensquare scaled
> 0.5mm of psubPath; fill asPathEnvelope rotated i yscaled 1
> withshademethod "linear" withshadecolors (0.5[blue,white],white) ; endfor;
> \stopMPpage
>
> I had expected to get a series of curves where the outer point of the
> curve was white, shading down to 0.5[blue,white] at the inner point of
> the curve.
>
> I was expecting the shading to remain that way, however, as the curve is
> rotated round, the shading effect slowly changes until it is reversed, and
> as it
>
> continues to be rotated it returns to it original shading. Although I
> quite like that effect, it's a nice feature, I would like to be able to
> produce the shading
>
> the way I wanted. A while back Hans explained to me why this happened and
> how I could remedy it, but unfortunately my aged memory has failed me and I
>
> cant remember how to do it. So I thought the youthful brains of the
> ConTeXt group may be able to help out, and it might be of interest in any
> case. I
>
> attach a pdf of the spiral effect.
>
> Best Wishes
>
> Keith McKay
>
>
> ___________________________________________________________________________________
> 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: 7694 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: Envelopes and shaded paths
2024-09-21 18:37 ` Florent Michel
@ 2024-09-22 15:06 ` Keith McKay
0 siblings, 0 replies; 4+ messages in thread
From: Keith McKay @ 2024-09-22 15:06 UTC (permalink / raw)
To: ntg-context, florent.m42
[-- Attachment #1.1: Type: text/plain, Size: 4182 bytes --]
Thank you Florent, this is exactly what I was looking to do. I know why
you you got twice as many lines as me. In my code in the for .. endfor;
loop I rotated the subPath by i and then rotated the asPathEnvelope by i
again in the fill statement which was my error. You correctly rotated
the subPath by i only, to get the correct number of paths. I'm going to
read, yet again, 8.3.3 in the MetaFuN manual.
Thanks for your help
Keith
On 21/09/2024 19:37, Florent Michel wrote:
> Apologies for the double email. Seems I slightly misunderstood what
> you aimed for - the corrected (assuming there is no other
> misunderstanding from me) is:
>
> \startMPpage
> pair A,B;
> path p, psubPath, asPathEnvelope;
> A = (0cm,0cm);B = (5cm,0cm);
> p = A{dir 60} .. B;
> fill fullsquare scaled 12cm withcolor 0.5[blue,white];
> for i = 0 step 5 until 355:
> psubPath := (subpath((0.1 * length p), (1 * length p) ) of p) rotated i;
> asPathEnvelope := envelope pensquare scaled 0.5mm of psubPath;
> fill asPathEnvelope
> withshade define_linear_shade((cosd(i) * 0.5cm, sind(i) * 0.5cm),
> (cosd(i) * 5cm, sind(i) * 5cm), 0.5[blue,white], white);
> endfor;
> \stopMPpage
>
> Le sam. 21 sept. 2024 à 17:51, Keith McKay <mckaymeister@gmail.com> a
> écrit :
>
> Hi,
>
> I have been playing about with envelopes to produce shaded paths
> as described in the new LuaMetFun manual, see page 105 therein.
> Using the code below I wanted to produce a shaded path, in this
> case a curve and then rotating it in 5 degree steps from 0 to 355
> degrees to produce a kind of spiral. Here is the code:
>
> \startMPpage
>
> pair A,B; path p, psubPath, asPathEnvelope; A = (0cm,0cm);B =
> (5cm,0cm); p = A{dir 60}.. B; fill fullsquare scaled 12cm
> withcolor 0.5[blue,white]; for i = 0 step 5 until 355: psubPath :=
> (subpath((0.1 * length p), (1 * length p))of p)rotated i;
> asPathEnvelope := envelope pensquare scaled 0.5mm of psubPath;
> fill asPathEnvelope rotated i yscaled 1 withshademethod "linear"
> withshadecolors (0.5[blue,white],white); endfor; \stopMPpage
>
> I had expected to get a series of curves where the outer point of
> the curve was white, shading down to 0.5[blue,white]at the inner
> point of the curve.
>
> I was expecting the shading to remain that way, however, as the
> curve is rotated round, the shading effect slowly changes until it
> is reversed, and as it
>
> continues to be rotated it returns to it original shading.
> Although I quite like that effect, it's a nice feature, I would
> like to be able to produce the shading
>
> the way I wanted. A while back Hans explained to me why this
> happened and how I could remedy it, but unfortunately my aged
> memory has failed me and I
>
> cant remember how to do it. So I thought the youthful brains of
> the ConTeXt group may be able to help out, and it might be of
> interest in any case. I
>
> attach a pdf of the spiral effect.
>
> Best Wishes
>
> Keith McKay
>
> ___________________________________________________________________________________
> 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
> ___________________________________________________________________________________
>
>
> ___________________________________________________________________________________
> 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: 11332 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
end of thread, other threads:[~2024-09-22 15:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-21 16:49 [NTG-context] Envelopes and shaded paths Keith McKay
2024-09-21 18:33 ` [NTG-context] " Florent Michel
2024-09-21 18:37 ` Florent Michel
2024-09-22 15:06 ` Keith McKay
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).