imagesvgtcltk-toolkittksvg

tcl svg gradient transformation not working - gradient silently ignored


I'm using tksvg 0.7.4 and noticed that the gradient transformation isn't working. Despite some features are not supported (yet) by , this feature is explicitly mentioned as supported in TIP 507 and as far as I know this package is just about to be included in tk 8.7.

I use the following data:

<svg width="120" height="240" version="1.1" xmlns="http://www.w3.org/2000/svg">
  <defs>
    <linearGradient id="Gradient1">
      <stop offset="0%" stop-color="red" />
      <stop offset="50%" stop-color="black" stop-opacity="0" />
      <stop offset="95%" stop-color="blue" />
    </linearGradient>
    <linearGradient id="Gradient2" x1="0" x2="0" y1="0" y2="1">
      <stop offset="0%" stop-color="red" />
      <stop offset="50%" stop-color="black" stop-opacity="0" />
      <stop offset="95%" stop-color="blue" />
    </linearGradient>
  </defs>

  <rect id="rect1" x="10" y="10" rx="15" ry="15"
      width="100" height="100" fill="url(#Gradient1)"/>
  <rect
    x="10"
    y="120"
    rx="15"
    ry="15"
    width="100"
    height="100"
    fill="url(#Gradient2)" />
</svg>

and tried unsuccessfully to alternate the data with the following line in the body and included it in the header as I found elsewhere in a tutorial.

<gradientTransform="rotate(90)" \>  

While the TIP is marked as done I think it should work already. I'm using Windows 11 by the way.

enter image description here


Update: All of the gradient attributes do not work


Solution

  • This is intentional. The library "svgnano" is used. The rasterizer does not support gradients.

    Here is the parent project:

    https://github.com/memononen/nanosvg

    You may also look to the wiki page with some hints:

    https://wiki.tcl-lang.org/svg