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

Canvas 2.9.1: Context.createLinearGradient not working #2043

Closed
1 task done
anhnh12 opened this issue May 24, 2022 · 4 comments
Closed
1 task done

Canvas 2.9.1: Context.createLinearGradient not working #2043

anhnh12 opened this issue May 24, 2022 · 4 comments

Comments

@anhnh12
Copy link

anhnh12 commented May 24, 2022

Issue or Feature

  • Context.createLinearGradient() working no more after upgrading to 2.9.1 from 2.8.0. The background just fell back to black. Gradient background still working fine with 2.9.0

Your Environment

  • Version of node-canvas: 2.9.1
  • Environment: node v16.15.0 on MacOS Monterey 12.2
@zbjornson
Copy link
Collaborator

Can you provide a complete, reproducible example please?

@anhnh12
Copy link
Author

anhnh12 commented Jun 9, 2022

@zbjornson this following single block of code produces two different result with 2 different version (check 2 attachments).

const gradientFrom = "rgba(53,83,192,0.9)"
const gradientTo = "rgba(58,69,110,0.5)"
const canvas = Canvas.createCanvas(width, height)
const ctx = canvas.getContext("2d")
const gradient = ctx.createLinearGradient(0, 0, 0, 400)
gradient.addColorStop(0, gradientFrom)
gradient.addColorStop(1, gradientTo)

Canvas 2.9.1

image

Canvas 2.9.0

image

@zbjornson
Copy link
Collaborator

I'm getting the correct (gradient, not solid black) behavior in 2.8.0, and 2.9.1. I also don't see any changes that would be likely to have caused this. This is the code I used:

const canvas = createCanvas(200, 200);
const ctx = canvas.getContext("2d");
const gradientFrom = "rgba(53,83,192,0.9)"
const gradientTo = "rgba(58,69,110,0.5)"
const gradient = ctx.createLinearGradient(0, 0, 0, 400)
gradient.addColorStop(0, gradientFrom)
gradient.addColorStop(1, gradientTo)
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, 200, 200);

image

Are you still encountering this issue?

@zbjornson
Copy link
Collaborator

Closing without more info, but will reopen if you're still encountering this.

@zbjornson zbjornson closed this as not planned Won't fix, can't repro, duplicate, stale Sep 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants