Hiding a part of a path
Dear all, I’d like to hide a part of a path. I can do that after changing it into an image, but it is not clearly erased. Is there a way to do that not changing it into an image? Thank you for reading. Best regards, Dalyoung \startMPcode path p,q; picture pic; numeric u; u:= 1cm; p := origin--(2u,0)--(3u,u)--(3u,0)--(4u,0); q := (3u,u)--(3u,0); pic := image(draw p; draw q withcolor white;); draw pic; \stopMPcode
Hi
On Mon, Dec 2, 2024 at 1:57 PM Jeong Dal via ntg-context
Dear all,
I’d like to hide a part of a path.
I can do that after changing it into an image, but it is not clearly erased. Is there a way to do that not changing it into an image? Thank you for reading.
Best regards,
Dalyoung
\startMPcode path p,q; picture pic; numeric u; u:= 1cm;
p := origin--(2u,0)--(3u,u)--(3u,0)--(4u,0); q := (3u,u)--(3u,0); pic := image(draw p; draw q withcolor white;);
draw pic; \stopMPcode
It is not clear how general you want this to be. For your example you can draw only the parts of p you need. \startMPpage[offset=1DK] path p,q; picture pic; numeric u; u:= 1cm; p := origin--(2u,0)--(3u,u)--(3u,0)--(4u,0); q := (3u,u)--(3u,0); % pic := image(draw p; draw q withcolor white;); % draw pic; draw p withpen pencircle scaled 4 ; draw subpath (0,2) of p && subpath (3,4) of p withpen pencircle scaled 2 withcolor yellow ; \stopMPpage If you need to "cut" in a more advanced way, I suggest to give such an example. /Mikael
Dear Mikael, As you said, it might be good to use image. Since I want not to draw a part of the path, I’d like to use the following code. pic := image(origin--(2u,0)--(3u,u); (3u,0)--(4u,0);); Thank you for the reply. Best regards, Dalyoung
2024. 12. 2. 오후 10:13, Mikael Sundqvist
작성: Hi
On Mon, Dec 2, 2024 at 1:57 PM Jeong Dal via ntg-context
mailto:ntg-context@ntg.nl> wrote: Dear all,
I’d like to hide a part of a path.
I can do that after changing it into an image, but it is not clearly erased. Is there a way to do that not changing it into an image? Thank you for reading.
Best regards,
Dalyoung
\startMPcode path p,q; picture pic; numeric u; u:= 1cm;
p := origin--(2u,0)--(3u,u)--(3u,0)--(4u,0); q := (3u,u)--(3u,0); pic := image(draw p; draw q withcolor white;);
draw pic; \stopMPcode
It is not clear how general you want this to be. For your example you can draw only the parts of p you need.
\startMPpage[offset=1DK] path p,q; picture pic; numeric u; u:= 1cm;
p := origin--(2u,0)--(3u,u)--(3u,0)--(4u,0); q := (3u,u)--(3u,0); % pic := image(draw p; draw q withcolor white;); % draw pic; draw p withpen pencircle scaled 4 ; draw subpath (0,2) of p && subpath (3,4) of p withpen pencircle scaled 2 withcolor yellow ; \stopMPpage
If you need to "cut" in a more advanced way, I suggest to give such an example.
/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 ___________________________________________________________________________________
Hi Dalyong,
I’d like to use the following code.
pic := image(origin--(2u,0)--(3u,u); (3u,0)--(4u,0););
You won’t be able to use that code, because the syntax is wrong. The image must contain drawing commands, but in your code it only contains paths. I’m not sure what you want. Your original example made an image and colored white over part of the path. It doesn’t look great. It can be improved by making the white pen bigger: pic := image(draw p; draw q withpen pencircle scaled 0.6 withcolor white;); I’m not sure this gives what you want at the ends, but it certainly hides part of the path. Mikael’s solution is neat because he doesn’t just hide part of the path, he makes a new path with that part completely removed. If you name that path, you can do whatever you want with it — draw it, scale it, put it in an image() command, etc. \startMPpage[offset=1DK] path p,pM; % pM will be Mikael’s path numeric u; u:= 1cm; p := origin--(2u,0)--(3u,u)--(3u,0)--(4u,0); pM := subpath (0,2) of p && subpath (3,4) of p ; % Mikael's path has two disconnected pieces! draw pM ; \stopMPpage If neither of those is what you need, please provide an example that shows more of what you are trying to do. Gavin
participants (3)
-
Gavin
-
Jeong Dal
-
Mikael Sundqvist