ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Radial and linear gradients
@ 2022-12-14  4:46 Thangalin via ntg-context
  2022-12-14  8:45 ` Hans Hagen via ntg-context
  0 siblings, 1 reply; 4+ messages in thread
From: Thangalin via ntg-context @ 2022-12-14  4:46 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Thangalin

[-- Attachment #1: Type: text/plain, Size: 928 bytes --]

Hi there!

Any thoughts on implementing SVG gradients in MetaPost?

% SOF
\startbuffer[csvg]
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 115.669
115.669"><defs><radialGradient xlink:href="#a" id="b" cx="124.515"
cy="167.114" r="57.834" fx="124.515" fy="167.114"
gradientTransform="translate(-17.77 -18.4)"
gradientUnits="userSpaceOnUse"/><linearGradient id="a"><stop
offset="0"/><stop offset="1"
stop-opacity="0"/></linearGradient></defs><g
transform="translate(-48.91 -90.879)"><path fill="red"
fill-opacity=".5" d="M48.769 90.936H164.64V206.96H48.769z"/><circle
cx="106.745" cy="148.713" r="57.834" fill="url(#b)"
fill-rule="evenodd"/></g></svg>
\stopbuffer

\starttext
  \placefigure{}{\includesvgbuffer[csvg][conversion=mp]}
\stoptext
% EOF

See attached a comparison of the PDF generated using ConTeXt and the
PNG file generated by exporting from Inkscape.

Many thanks!

[-- Attachment #2: gradient.png --]
[-- Type: image/png, Size: 25190 bytes --]

[-- Attachment #3: gradient.pdf --]
[-- Type: application/pdf, Size: 7681 bytes --]

[-- Attachment #4: Type: text/plain, Size: 496 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Radial and linear gradients
  2022-12-14  4:46 Radial and linear gradients Thangalin via ntg-context
@ 2022-12-14  8:45 ` Hans Hagen via ntg-context
  2022-12-14 20:45   ` Thangalin via ntg-context
  0 siblings, 1 reply; 4+ messages in thread
From: Hans Hagen via ntg-context @ 2022-12-14  8:45 UTC (permalink / raw)
  To: Thangalin via ntg-context; +Cc: Hans Hagen

On 12/14/2022 5:46 AM, Thangalin via ntg-context wrote:
> Hi there!
> 
> Any thoughts on implementing SVG gradients in MetaPost?
> 
> % SOF
> \startbuffer[csvg]
> <svg xmlns="http://www.w3.org/2000/svg"
> xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 115.669
> 115.669"><defs><radialGradient xlink:href="#a" id="b" cx="124.515"
> cy="167.114" r="57.834" fx="124.515" fy="167.114"
> gradientTransform="translate(-17.77 -18.4)"
> gradientUnits="userSpaceOnUse"/><linearGradient id="a"><stop
> offset="0"/><stop offset="1"
> stop-opacity="0"/></linearGradient></defs><g
> transform="translate(-48.91 -90.879)"><path fill="red"
> fill-opacity=".5" d="M48.769 90.936H164.64V206.96H48.769z"/><circle
> cx="106.745" cy="148.713" r="57.834" fill="url(#b)"
> fill-rule="evenodd"/></g></svg>
> \stopbuffer
> 
> \starttext
>    \placefigure{}{\includesvgbuffer[csvg][conversion=mp]}
> \stoptext
> % EOF
> 
> See attached a comparison of the PDF generated using ConTeXt and the
> PNG file generated by exporting from Inkscape.
these gradients definitions get crazier by the day ... does inkscape 
output a bitmap or vector pdf

given what we do with context i'm not sure we should support everything 
that pops up (mapping all onto mp and then pdf ...)

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Radial and linear gradients
  2022-12-14  8:45 ` Hans Hagen via ntg-context
@ 2022-12-14 20:45   ` Thangalin via ntg-context
  2022-12-14 22:29     ` Hans Hagen via ntg-context
  0 siblings, 1 reply; 4+ messages in thread
From: Thangalin via ntg-context @ 2022-12-14 20:45 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Thangalin

[-- Attachment #1: Type: text/plain, Size: 3143 bytes --]

Inkscape can export the gradients to PDF.

I was hoping to eliminate Inkscape as an extra piece of software users
have to download to make sure their SVG images are rendered correctly.
By containerizing ConTeXt, MetaPost can be swapped for Inkscape, so
users won't even know. It is, however, a minor duplication to have two
programs that can convert SVG to PDF. (And Inkscape will bloat the
container size.)

For my images, at least, gradients are one of the last features needed
to render them correctly using MetaPost. The other is font rendering
in some cases will be incorrect (e.g., try using Roboto with weight
100). If we have to use Inkscape to ensure tat all SVG images are
rendered correctly, then we'd only want to use MetaPost if we know
that the images don't contain gradients, or would you recommend
avoiding MetaPost altogether for SVG conversion?

Thank you!

On Wed, Dec 14, 2022 at 12:46 AM Hans Hagen via ntg-context
<ntg-context@ntg.nl> wrote:
>
> On 12/14/2022 5:46 AM, Thangalin via ntg-context wrote:
> > Hi there!
> >
> > Any thoughts on implementing SVG gradients in MetaPost?
> >
> > % SOF
> > \startbuffer[csvg]
> > <svg xmlns="http://www.w3.org/2000/svg"
> > xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 115.669
> > 115.669"><defs><radialGradient xlink:href="#a" id="b" cx="124.515"
> > cy="167.114" r="57.834" fx="124.515" fy="167.114"
> > gradientTransform="translate(-17.77 -18.4)"
> > gradientUnits="userSpaceOnUse"/><linearGradient id="a"><stop
> > offset="0"/><stop offset="1"
> > stop-opacity="0"/></linearGradient></defs><g
> > transform="translate(-48.91 -90.879)"><path fill="red"
> > fill-opacity=".5" d="M48.769 90.936H164.64V206.96H48.769z"/><circle
> > cx="106.745" cy="148.713" r="57.834" fill="url(#b)"
> > fill-rule="evenodd"/></g></svg>
> > \stopbuffer
> >
> > \starttext
> >    \placefigure{}{\includesvgbuffer[csvg][conversion=mp]}
> > \stoptext
> > % EOF
> >
> > See attached a comparison of the PDF generated using ConTeXt and the
> > PNG file generated by exporting from Inkscape.
> these gradients definitions get crazier by the day ... does inkscape
> output a bitmap or vector pdf
>
> given what we do with context i'm not sure we should support everything
> that pops up (mapping all onto mp and then pdf ...)
>
> Hans
>
> -----------------------------------------------------------------
>                                            Hans Hagen | PRAGMA ADE
>                Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>         tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
> -----------------------------------------------------------------
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : https://contextgarden.net
> ___________________________________________________________________________________

[-- Attachment #2: inkscape-gradient.pdf --]
[-- Type: application/pdf, Size: 2606 bytes --]

[-- Attachment #3: Type: text/plain, Size: 496 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Radial and linear gradients
  2022-12-14 20:45   ` Thangalin via ntg-context
@ 2022-12-14 22:29     ` Hans Hagen via ntg-context
  0 siblings, 0 replies; 4+ messages in thread
From: Hans Hagen via ntg-context @ 2022-12-14 22:29 UTC (permalink / raw)
  To: Thangalin via ntg-context; +Cc: Hans Hagen

On 12/14/2022 9:45 PM, Thangalin via ntg-context wrote:
> Inkscape can export the gradients to PDF.
> 
> I was hoping to eliminate Inkscape as an extra piece of software users
> have to download to make sure their SVG images are rendered correctly.
> By containerizing ConTeXt, MetaPost can be swapped for Inkscape, so
> users won't even know. It is, however, a minor duplication to have two
> programs that can convert SVG to PDF. (And Inkscape will bloat the
> container size.)
> 
> For my images, at least, gradients are one of the last features needed
> to render them correctly using MetaPost. The other is font rendering
> in some cases will be incorrect (e.g., try using Roboto with weight
> 100). If we have to use Inkscape to ensure tat all SVG images are

Also in the latest?

> rendered correctly, then we'd only want to use MetaPost if we know
> that the images don't contain gradients, or would you recommend
> avoiding MetaPost altogether for SVG conversion?
dunno, but that gradient is somewhat special so it then needs to be 
intercepted ... i'm currently not in svg mode so ... (variable color 
fonts have even wierder ones).

Hans



-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-12-14 22:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-14  4:46 Radial and linear gradients Thangalin via ntg-context
2022-12-14  8:45 ` Hans Hagen via ntg-context
2022-12-14 20:45   ` Thangalin via ntg-context
2022-12-14 22:29     ` Hans Hagen 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).