* [NTG-context] Including SVG manipulating color or rewrite in MP
@ 2024-12-12 15:53 juh+ntg-context--- via ntg-context
2024-12-12 16:43 ` [NTG-context] " Mikael Sundqvist
0 siblings, 1 reply; 3+ messages in thread
From: juh+ntg-context--- via ntg-context @ 2024-12-12 15:53 UTC (permalink / raw)
To: mailing list for ConTeXt users; +Cc: juh+ntg-context
Dear all,
I have near to zero knowledge about MPgraphics, so I always use SVG
files from various sources.
I do something like this:
\defineoverlay[pic][\externalfigure[form.svg][width=14em]]
\defineframed
[textcircledA]
[
frame=off,
strut=yes,
rulethickness=0.0pt,
background=pic,
location=top,]
\textcircledA{\externalfigure[icon.svg][width=280px]}
The form.svg appears as background of icon.svg.
Now I want to change the stroke color in the svg.
It is very simple:
<?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="#99bcdb" stroke-linecap="round"
stroke-width="2"/>
</g>
</svg>
I can simply open it in inkscape set the color an save it under a
meaningful filename, but I would like to set the color in the context file.
I tried to define the overlay pic with \includesvgbuffer but I can't get
it to work.
\startbuffer[svg]
<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="MyColor" stroke-linecap="round"
stroke-width="2"/>
</g>
</svg>
\stopbuffer
\defineoverlay[pic][\includesvgbuffer[svg][offset=1bp]]
Nothing happens, no form appears in the overlay.
I saw an example with \startstopuseMPgraphic in the Wiki.
\startuseMPgraphic{MPtextcircle}
path p;
p := fullcircle xscaled OverlayWidth
yscaled OverlayWidth;
setbounds currentpicture to p ;
% p:= p shifted (0,StrutDepth/2.7);
draw p withpen pencircle scaled 25pt
withcolor OverlayLineColor;
\stopuseMPgraphic
\defineoverlay[OLtextcircle][\useMPgraphic{MPtextcircle}]
This works for me.
Is it possible to use a svgbuffer in a overlay definition?
Or do I have to convert the SVG code to MP?
Is there a converter?
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] 3+ messages in thread
* [NTG-context] Re: Including SVG manipulating color or rewrite in MP
2024-12-12 15:53 [NTG-context] Including SVG manipulating color or rewrite in MP juh+ntg-context--- via ntg-context
@ 2024-12-12 16:43 ` Mikael Sundqvist
2024-12-14 19:37 ` juh+ntg-context--- via ntg-context
0 siblings, 1 reply; 3+ messages in thread
From: Mikael Sundqvist @ 2024-12-12 16:43 UTC (permalink / raw)
To: mailing list for ConTeXt users
Hi,
Not sure exactly what you are after, but this could work (I saved your
svg as juh.svg)
/Mikael
\startuseMPgraphic{juh}{juhcolor}
picture juh ;
juh := lmt_svg [
filename = "juh.svg",
origin = true ] ;
draw juh ysized OverlayHeight withcolor \MPvar{juhcolor} ;
\stopuseMPgraphic
\setupMPvariables[juh][juhcolor=darkred]
\defineoverlay[juh][\useMPgraphic{juh}]
\starttext
\framed[align=normal,width=7cm,background=juh]{\samplefile{ward}}
\setupMPvariables[juh][juhcolor=darkblue]
\framed[align=normal,width=7cm,background=juh]{\samplefile{ward}}
\stoptext
On Thu, Dec 12, 2024 at 4:57 PM juh+ntg-context--- via ntg-context
<ntg-context@ntg.nl> wrote:
>
> Dear all,
>
> I have near to zero knowledge about MPgraphics, so I always use SVG
> files from various sources.
>
>
> I do something like this:
>
> \defineoverlay[pic][\externalfigure[form.svg][width=14em]]
> \defineframed
> [textcircledA]
> [
> frame=off,
> strut=yes,
> rulethickness=0.0pt,
> background=pic,
> location=top,]
>
>
> \textcircledA{\externalfigure[icon.svg][width=280px]}
>
>
> The form.svg appears as background of icon.svg.
>
> Now I want to change the stroke color in the svg.
>
> It is very simple:
>
> <?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="#99bcdb" stroke-linecap="round"
> stroke-width="2"/>
> </g>
> </svg>
>
> I can simply open it in inkscape set the color an save it under a
> meaningful filename, but I would like to set the color in the context file.
>
> I tried to define the overlay pic with \includesvgbuffer but I can't get
> it to work.
>
> \startbuffer[svg]
> <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="MyColor" stroke-linecap="round"
> stroke-width="2"/>
> </g>
> </svg>
> \stopbuffer
>
> \defineoverlay[pic][\includesvgbuffer[svg][offset=1bp]]
>
> Nothing happens, no form appears in the overlay.
>
> I saw an example with \startstopuseMPgraphic in the Wiki.
>
> \startuseMPgraphic{MPtextcircle}
> path p;
> p := fullcircle xscaled OverlayWidth
> yscaled OverlayWidth;
> setbounds currentpicture to p ;
> % p:= p shifted (0,StrutDepth/2.7);
> draw p withpen pencircle scaled 25pt
> withcolor OverlayLineColor;
> \stopuseMPgraphic
>
> \defineoverlay[OLtextcircle][\useMPgraphic{MPtextcircle}]
>
> This works for me.
>
> Is it possible to use a svgbuffer in a overlay definition?
>
> Or do I have to convert the SVG code to MP?
>
> Is there a converter?
>
> 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
> ___________________________________________________________________________________
___________________________________________________________________________________
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: Including SVG manipulating color or rewrite in MP
2024-12-12 16:43 ` [NTG-context] " Mikael Sundqvist
@ 2024-12-14 19:37 ` juh+ntg-context--- via ntg-context
0 siblings, 0 replies; 3+ messages in thread
From: juh+ntg-context--- via ntg-context @ 2024-12-14 19:37 UTC (permalink / raw)
To: mailing list for ConTeXt users; +Cc: juh+ntg-context
[-- Attachment #1.1: Type: text/plain, Size: 4599 bytes --]
Thanks a lot. Works for me.
Am 12. Dezember 2024 17:43:44 MEZ schrieb Mikael Sundqvist <mickep@gmail.com>:
>Hi,
>
>Not sure exactly what you are after, but this could work (I saved your
>svg as juh.svg)
>
>/Mikael
>
>\startuseMPgraphic{juh}{juhcolor}
>
>picture juh ;
>
>juh := lmt_svg [
> filename = "juh.svg",
> origin = true ] ;
>
>draw juh ysized OverlayHeight withcolor \MPvar{juhcolor} ;
>
>\stopuseMPgraphic
>
>\setupMPvariables[juh][juhcolor=darkred]
>
>\defineoverlay[juh][\useMPgraphic{juh}]
>
>\starttext
>
>\framed[align=normal,width=7cm,background=juh]{\samplefile{ward}}
>
>\setupMPvariables[juh][juhcolor=darkblue]
>
>\framed[align=normal,width=7cm,background=juh]{\samplefile{ward}}
>
>\stoptext
>
>On Thu, Dec 12, 2024 at 4:57 PM juh+ntg-context--- via ntg-context
><ntg-context@ntg.nl> wrote:
>>
>> Dear all,
>>
>> I have near to zero knowledge about MPgraphics, so I always use SVG
>> files from various sources.
>>
>>
>> I do something like this:
>>
>> \defineoverlay[pic][\externalfigure[form.svg][width=14em]]
>> \defineframed
>> [textcircledA]
>> [
>> frame=off,
>> strut=yes,
>> rulethickness=0.0pt,
>> background=pic,
>> location=top,]
>>
>>
>> \textcircledA{\externalfigure[icon.svg][width=280px]}
>>
>>
>> The form.svg appears as background of icon.svg.
>>
>> Now I want to change the stroke color in the svg.
>>
>> It is very simple:
>>
>> <?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="#99bcdb" stroke-linecap="round"
>> stroke-width="2"/>
>> </g>
>> </svg>
>>
>> I can simply open it in inkscape set the color an save it under a
>> meaningful filename, but I would like to set the color in the context file.
>>
>> I tried to define the overlay pic with \includesvgbuffer but I can't get
>> it to work.
>>
>> \startbuffer[svg]
>> <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="MyColor" stroke-linecap="round"
>> stroke-width="2"/>
>> </g>
>> </svg>
>> \stopbuffer
>>
>> \defineoverlay[pic][\includesvgbuffer[svg][offset=1bp]]
>>
>> Nothing happens, no form appears in the overlay.
>>
>> I saw an example with \startstopuseMPgraphic in the Wiki.
>>
>> \startuseMPgraphic{MPtextcircle}
>> path p;
>> p := fullcircle xscaled OverlayWidth
>> yscaled OverlayWidth;
>> setbounds currentpicture to p ;
>> % p:= p shifted (0,StrutDepth/2.7);
>> draw p withpen pencircle scaled 25pt
>> withcolor OverlayLineColor;
>> \stopuseMPgraphic
>>
>> \defineoverlay[OLtextcircle][\useMPgraphic{MPtextcircle}]
>>
>> This works for me.
>>
>> Is it possible to use a svgbuffer in a overlay definition?
>>
>> Or do I have to convert the SVG code to MP?
>>
>> Is there a converter?
>>
>> 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
>> ___________________________________________________________________________________
>___________________________________________________________________________________
>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: 5406 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-12-14 19:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-12 15:53 [NTG-context] Including SVG manipulating color or rewrite in MP juh+ntg-context--- via ntg-context
2024-12-12 16:43 ` [NTG-context] " Mikael Sundqvist
2024-12-14 19:37 ` juh+ntg-context--- 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).