• Radial gradient rendering issue in SVG photo images in tk 9

    From Eric Brunel@21:1/5 to All on Wed May 14 07:37:06 2025
    Hello all,

    I've encountered what looks like a rendering problem in SVG photo images
    with radial gradients. For example, with the following SVG specification:

    <?xml version="1.0" encoding="UTF-8"?>
    <svg width="600" height="300" xmlns="http://www.w3.org/2000/svg"
    xmlns:svg="http://www.w3.org/2000/svg">
    <defs>
    <radialGradient id="g" gradientUnits="objectBoundingBox"
    cx="50%" cy="50%" r="50%">
    <stop offset="0" stop-color="#0000FF"/>
    <stop offset="1" stop-color="#FF0000"/>
    </radialGradient>
    </defs>
    <rect x="0" y="0" width="600" height="300" stroke="none" fill="url(#g)"/> </svg>

    all the tools supporting SVG I could try render the gradient based on an ellipse enclosed in the 600x300 rectangle.

    But that's not what appears in a SVG photo image in tk 9: the gradient is
    based on a circle with a diameter set to the maximum size of the object's bounding box (here 600 points).

    In the man page for photo images, it is explicitly specified that setting gradientUnits to "objectBoundingBox" is supported, so it looks like a
    rendering issue. Or maybe there is a limitation on radial gradients in
    this case?

    Thanks!
    --
    Eric

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Harald Oehlmann@21:1/5 to All on Wed May 14 10:37:07 2025
    Am 14.05.2025 um 09:37 schrieb Eric Brunel:
    Hello all,

    I've encountered what looks like a rendering problem in SVG photo images
    with radial gradients. For example, with the following SVG specification:

    <?xml version="1.0" encoding="UTF-8"?>
    <svg width="600" height="300" xmlns="http://www.w3.org/2000/svg"
    xmlns:svg="http://www.w3.org/2000/svg">
    <defs>
    <radialGradient id="g" gradientUnits="objectBoundingBox"
    cx="50%" cy="50%" r="50%">
    <stop offset="0" stop-color="#0000FF"/>
    <stop offset="1" stop-color="#FF0000"/>
    </radialGradient>
    </defs>
    <rect x="0" y="0" width="600" height="300" stroke="none" fill="url(#g)"/> </svg>

    all the tools supporting SVG I could try render the gradient based on an ellipse enclosed in the 600x300 rectangle.

    But that's not what appears in a SVG photo image in tk 9: the gradient is based on a circle with a diameter set to the maximum size of the object's bounding box (here 600 points).

    In the man page for photo images, it is explicitly specified that setting gradientUnits to "objectBoundingBox" is supported, so it looks like a rendering issue. Or maybe there is a limitation on radial gradients in
    this case?

    Thanks!

    Eric,
    a bar nanosvg is used for interpretation and rendering: https://github.com/memononen/nanosvg
    The issue on radient gradients often pops-up there.

    Proposals to improve the documentation is welcomed.
    It is not that chertain drawing features are not supported, but also
    certain syntax constructs...

    AFAIK, there is a full svg renderer in the TkImg package.

    Take care,
    Harald

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)