* [NTG-context] Metapost: draw only subpath; changing thickness of line @ 2024-01-05 8:56 Emanuel Han via ntg-context 2024-01-05 13:13 ` [NTG-context] " Taco Hoekwater 0 siblings, 1 reply; 3+ messages in thread From: Emanuel Han via ntg-context @ 2024-01-05 8:56 UTC (permalink / raw) To: ntg-context; +Cc: Emanuel Han [-- Attachment #1.1: Type: text/plain, Size: 1085 bytes --] Hi all, I have this MWE. Now I want to draw only the subpath of S between gong6 and gong7 with a red line which is narrower at the two ends and thicker in the middle part. How to achieve this? Thanks! Emanuel \setuppapersize[A4,landscape] \starttext \startMPcode numeric u; u=1cm; %equiangular spiral numeric a, k ; a = 2.3; %scaling factor k = 8.61722335; path S; S = right for t=1 upto 360: .. a ** (t/50.2) * dir (-k*t) endfor; draw S; z1 = 8 dir -14; path A; A = origin -- z1 scaled 0.7u ; draw A; pair AEndPoint; AEndPoint = point 1 of A; pair gong[], times; numeric n; n = 0; for i = 1 upto length(A): for j = 1 upto length(S): times := subpath (i-1,i) of A intersectiontimes subpath (j-1,j) of S; if xpart times > -1: gong[incr n] = 1/2[point xpart times of subpath (i-1,i) of A, point ypart times of subpath (j-1,j) of S]; fi endfor endfor dotlabel.rt ("$gong6$", gong6); dotlabel.rt ("$gong7$", gong7); %Now I want to draw only the subpath of S between gong6 and gong7 with a red line which is narrower at the two ends and thicker in the middle part \stopMPcode \stoptext [-- Attachment #1.2: Type: text/html, Size: 1650 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] 3+ messages in thread
* [NTG-context] Re: Metapost: draw only subpath; changing thickness of line 2024-01-05 8:56 [NTG-context] Metapost: draw only subpath; changing thickness of line Emanuel Han via ntg-context @ 2024-01-05 13:13 ` Taco Hoekwater 2024-01-06 16:36 ` Emanuel Han via ntg-context 0 siblings, 1 reply; 3+ messages in thread From: Taco Hoekwater @ 2024-01-05 13:13 UTC (permalink / raw) To: mailing list for ConTeXt users Hi, Here is 'a' way to draw the subpath, at least. I do not have time to come up with a nice “thicker in the middle” solution. Best wishes, Taco \startMPcode numeric u; u=1cm; %equiangular spiral numeric a, k ; a = 2.3; %scaling factor k = 8.61722335; path S; S = right for t=1 upto 360: .. a ** (t/50.2) * dir (-k*t) endfor; draw S; z1 = 8 dir -14; path A; A = origin -- z1 scaled 0.7u ;% draw A; pair AEndPoint; AEndPoint = point 1 of A; pair gong[], times; numeric n; n = 0; numeric gongtimes[]; % new for i = 1 upto length(A): for j = 1 upto length(S): times := subpath (i-1,i) of A intersectiontimes subpath (j-1,j) of S; if xpart times > -1: gong[incr n] = 1[point xpart times of subpath (i-1,i) of A, point ypart times of subpath (j-1,j) of S]; gongtimes[n] = j-1 + ypart times; % new fi endfor endfor % new path H; H = subpath(gongtimes[6],gongtimes[7]) of S; lH = length(H); for i = 1 upto 100: draw (subpath((i-1)/100*lH, i/100* lH) of H) withcolor red withpen (pencircle scaled(abs(abs(i-50)-50)/10)) ; endfor; \stopMPcode > On 5 Jan 2024, at 09:56, Emanuel Han via ntg-context <ntg-context@ntg.nl> wrote: > > Hi all, > > I have this MWE. Now I want to draw only the subpath of S between gong6 and gong7 with a red line which is narrower at the two ends and thicker in the middle part. How to achieve this? > > Thanks! > Emanuel > > \setuppapersize[A4,landscape] > > \starttext > > \startMPcode > numeric u; u=1cm; > %equiangular spiral > numeric a, k ; > a = 2.3; %scaling factor > k = 8.61722335; > path S; > S = right for t=1 upto 360: .. a ** (t/50.2) * dir (-k*t) endfor; > draw S; > > z1 = 8 dir -14; > path A; A = origin -- z1 scaled 0.7u ; draw A; > pair AEndPoint; AEndPoint = point 1 of A; > pair gong[], times; numeric n; n = 0; > for i = 1 upto length(A): > for j = 1 upto length(S): > times := subpath (i-1,i) of A intersectiontimes subpath (j-1,j) of S; > if xpart times > -1: > gong[incr n] = 1/2[point xpart times of subpath (i-1,i) of A, > point ypart times of subpath (j-1,j) of S]; > fi > endfor > endfor > > dotlabel.rt ("$gong6$", gong6); > dotlabel.rt ("$gong7$", gong7); > > %Now I want to draw only the subpath of S between gong6 and gong7 with a red line which is narrower at the two ends and thicker in the middle part > > \stopMPcode > > \stoptext > ___________________________________________________________________________________ > 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 > ___________________________________________________________________________________ — Taco Hoekwater E: taco@bittext.nl genderfluid (all pronouns) ___________________________________________________________________________________ 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] 3+ messages in thread
* [NTG-context] Re: Metapost: draw only subpath; changing thickness of line 2024-01-05 13:13 ` [NTG-context] " Taco Hoekwater @ 2024-01-06 16:36 ` Emanuel Han via ntg-context 0 siblings, 0 replies; 3+ messages in thread From: Emanuel Han via ntg-context @ 2024-01-06 16:36 UTC (permalink / raw) To: Taco Hoekwater; +Cc: mailing list for ConTeXt users, Emanuel Han [-- Attachment #1.1: Type: text/plain, Size: 3300 bytes --] Hi Taco, thanks for your help. This works for me! On Jan. 5 2024, at 2:13 pm, Taco Hoekwater <taco@bittext.nl> wrote: > Hi, > > Here is 'a' way to draw the subpath, at least. I do not have time to come up with a nice “thicker in the middle” solution. > Best wishes, > Taco > > > \startMPcode > numeric u; u=1cm; > %equiangular spiral > numeric a, k ; > a = 2.3; %scaling factor > k = 8.61722335; > path S; > S = right for t=1 upto 360: .. a ** (t/50.2) * dir (-k*t) endfor; > draw S; > > z1 = 8 dir -14; > path A; A = origin -- z1 scaled 0.7u ;% draw A; > pair AEndPoint; AEndPoint = point 1 of A; > pair gong[], times; numeric n; n = 0; > numeric gongtimes[]; % new > for i = 1 upto length(A): > for j = 1 upto length(S): > times := subpath (i-1,i) of A intersectiontimes subpath (j-1,j) of S; > if xpart times > -1: > gong[incr n] = 1[point xpart times of subpath (i-1,i) of A, > point ypart times of subpath (j-1,j) of S]; > gongtimes[n] = j-1 + ypart times; % new > fi > endfor > endfor > > % new > path H; H = subpath(gongtimes[6],gongtimes[7]) of S; > lH = length(H); > for i = 1 upto 100: > draw (subpath((i-1)/100*lH, i/100* lH) of H) withcolor red withpen (pencircle scaled(abs(abs(i-50)-50)/10)) ; > endfor; > > \stopMPcode > > > On 5 Jan 2024, at 09:56, Emanuel Han via ntg-context <ntg-context@ntg.nl> wrote: > > > > Hi all, > > > > I have this MWE. Now I want to draw only the subpath of S between gong6 and gong7 with a red line which is narrower at the two ends and thicker in the middle part. How to achieve this? > > > > Thanks! > > Emanuel > > > > \setuppapersize[A4,landscape] > > > > \starttext > > > > \startMPcode > > numeric u; u=1cm; > > %equiangular spiral > > numeric a, k ; > > a = 2.3; %scaling factor > > k = 8.61722335; > > path S; > > S = right for t=1 upto 360: .. a ** (t/50.2) * dir (-k*t) endfor; > > draw S; > > > > z1 = 8 dir -14; > > path A; A = origin -- z1 scaled 0.7u ; draw A; > > pair AEndPoint; AEndPoint = point 1 of A; > > pair gong[], times; numeric n; n = 0; > > for i = 1 upto length(A): > > for j = 1 upto length(S): > > times := subpath (i-1,i) of A intersectiontimes subpath (j-1,j) of S; > > if xpart times > -1: > > gong[incr n] = 1/2[point xpart times of subpath (i-1,i) of A, > > point ypart times of subpath (j-1,j) of S]; > > fi > > endfor > > endfor > > > > dotlabel.rt ("$gong6$", gong6); > > dotlabel.rt ("$gong7$", gong7); > > > > %Now I want to draw only the subpath of S between gong6 and gong7 with a red line which is narrower at the two ends and thicker in the middle part > > > > \stopMPcode > > > > \stoptext > > ___________________________________________________________________________________ > > 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 > > ___________________________________________________________________________________ > > — > Taco Hoekwater E: taco@bittext.nl > genderfluid (all pronouns) > [-- Attachment #1.2: Type: text/html, Size: 4227 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] 3+ messages in thread
end of thread, other threads:[~2024-01-06 16:45 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-01-05 8:56 [NTG-context] Metapost: draw only subpath; changing thickness of line Emanuel Han via ntg-context 2024-01-05 13:13 ` [NTG-context] " Taco Hoekwater 2024-01-06 16:36 ` Emanuel Han via ntg-context
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).