* [NTG-context] Clip an image with a svg
@ 2025-01-03 15:53 juh+ntg-context--- via ntg-context
2025-01-03 16:57 ` [NTG-context] " Wolfgang Schuster
0 siblings, 1 reply; 2+ messages in thread
From: juh+ntg-context--- via ntg-context @ 2025-01-03 15:53 UTC (permalink / raw)
To: mailing list for ConTeXt users; +Cc: juh+ntg-context
Dear all,
I found this example in the garden.
\startMPclip{circleclip}
clip currentpicture to fullcircle shifted (.5,.5)
xscaled \width yscaled \height ;
\stopMPclip
\clip[nx=1,ny=1,mp=circleclip]{\externalfigure[hacker.png]}
Aside from the fact that I failed to understand the shifted argument by
playing around with values, I wonder if it is possible to use a SVG as
clip for an image.
The SVG is something like this:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg width="20.887mm" height="17.613mm" version="1.1" viewBox="0 0
20.887 17.613" xmlns="http://www.w3.org/2000/svg">
<g transform="translate(152.66 -101.94)">
<path d="m-150.94 114.93c-0.5424-1.3121-0.58209-2.9382 0.18256-5.2163
2.3566-7.0175 11.139-8.7098 15.878-3.0594 7.6978 8.7032-11.506
16.052-16.06 8.2756" fill="none" stroke="#dd4901" stroke-linecap="round"
stroke-width="2"/>
</g>
</svg>
I guess that there might be a way to translate this to Metafun or
Metapost, if I can't use SVG directly.
In my real life use case I want to have a bleeding image at the top or
the bottom of the page which can be clipped by the form while size and
position of the form relative to the image and relative to the page
shall be set by parameters either in \clip or in the definition of the
MPclip.
TIA
juh
___________________________________________________________________________________
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] 2+ messages in thread
* [NTG-context] Re: Clip an image with a svg
2025-01-03 15:53 [NTG-context] Clip an image with a svg juh+ntg-context--- via ntg-context
@ 2025-01-03 16:57 ` Wolfgang Schuster
0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Schuster @ 2025-01-03 16:57 UTC (permalink / raw)
To: ntg-context
Am 03.01.2025 um 16:53 schrieb juh+ntg-context--- via ntg-context:
> Dear all,
>
> I found this example in the garden.
>
> \startMPclip{circleclip}
> clip currentpicture to fullcircle shifted (.5,.5)
> xscaled \width yscaled \height ;
> \stopMPclip
>
> \clip[nx=1,ny=1,mp=circleclip]{\externalfigure[hacker.png]}
>
> Aside from the fact that I failed to understand the shifted argument by
> playing around with values, I wonder if it is possible to use a SVG as
> clip for an image.
In the following example the yellow square is your picture, when you use
fullcircle without the shift you clipped image shows only the bottom
left corner (the part where the red circle and yellow square overlap).
To get the center of the picture you can either ship fullcircle by .5 in
the x and y direction or use unitcircle.
%%%% begin example
\startMPpage[offset=1cm]
fill unitsquare scaled 5cm withcolor "yellow" ;
draw hlingrid(0, 10, 1, 10cm, 10cm) shifted(-5cm,-5cm) ;
draw vlingrid(0, 10, 1, 10cm, 10cm) shifted(-5cm,-5cm) ;
draw origin withpen pencircle scaled 10 ;
draw fullcircle scaled 5cm withcolor "red" withpen pencircle scaled 5;
draw unitcircle scaled 5cm withcolor "green" withpen pencircle scaled 5;
\stopMPpage
%%%% end example
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] 2+ messages in thread
end of thread, other threads:[~2025-01-03 16:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-03 15:53 [NTG-context] Clip an image with a svg juh+ntg-context--- via ntg-context
2025-01-03 16:57 ` [NTG-context] " 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).