Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Radial gradient has no effect on SKSvgCanvas #3095

Open
1 task done
nandor23 opened this issue Dec 3, 2024 · 3 comments
Open
1 task done

[BUG] Radial gradient has no effect on SKSvgCanvas #3095

nandor23 opened this issue Dec 3, 2024 · 3 comments
Labels

Comments

@nandor23
Copy link

nandor23 commented Dec 3, 2024

Description

Hello,

The radial gradient shader is not applied when drawing on SKSvgCanvas, but the linear gradient works without issues. There is no error at all, the radial gradient shader is treated as if it wasn't defined at all.

Code

Sample repo: https://github.com/nandor23/skiasharp-gradient-sample

The code as well:

using SkiaSharp;

const float size = 1000;

LinearGradient();
RadialGradient();

void LinearGradient()
{
    using var fileStream = new FileStream("linear_gradient.svg", FileMode.Create);
    using var canvas = SKSvgCanvas.Create(new SKRect(0f, 0f, size, size), fileStream);
    using var paint = new SKPaint
    {
        Shader = SKShader.CreateLinearGradient(
            new SKPoint(0, 0),
            new SKPoint(size, size),
            [SKColors.CornflowerBlue, SKColors.YellowGreen],
            null,
            SKShaderTileMode.Clamp
        )
    };
    canvas.DrawPaint(paint);
    canvas.Flush();
}


// Does not work
void RadialGradient()
{
    using var fileStream = new FileStream("radial_gradient.svg", FileMode.Create);
    using var canvas = SKSvgCanvas.Create(new SKRect(0f, 0f, size, size), fileStream);
    using var paint = new SKPaint
    {
        Shader = SKShader.CreateRadialGradient(
            new SKPoint(size / 2, size / 2),
            size / 2,
            [SKColors.CornflowerBlue, SKColors.YellowGreen],
            null,
            SKShaderTileMode.Clamp
        )
    };
    canvas.DrawPaint(paint);
    canvas.Flush();
}

Expected Behavior

No response

Actual Behavior

No response

Version of SkiaSharp

2.88.9 (Current)

Last Known Good Version of SkiaSharp

No idea

IDE / Editor

Other (Please indicate in the description)

Platform / Operating System

Linux

Platform / Operating System Version

No response

Devices

No response

Relevant Screenshots

Linear gradient output:

image

Radial gradient output:
image

Relevant Log Output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@yrymrr
Copy link

yrymrr commented Dec 5, 2024

FYI It was never implemented in Skia svg canvas. They left a "TODO" in that section of the code. You might want to report the issue there instead. https://github.com/google/skia/blob/main/src/svg/SkSVGDevice.cpp#L449

@nandor23
Copy link
Author

nandor23 commented Dec 5, 2024

Thank you, it looks like there is no Issues or Discussions tab on that project where this could be pointed out.
It's up to their needs whether this will ever be implemented.

@yrymrr
Copy link

yrymrr commented Dec 5, 2024

Thank you, it looks like there is no Issues or Discussions tab on that project where this could be pointed out. It's up to their needs whether this will ever be implemented.

Seems they don't use GitHub for issue tracking on that project but it could be reported elsewhere. https://skia.org/docs/dev/contrib/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: New
Development

No branches or pull requests

2 participants