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

RGB functions do not support real numbers #2339

Open
michaeljherrmann opened this issue Jan 18, 2024 · 0 comments
Open

RGB functions do not support real numbers #2339

michaeljherrmann opened this issue Jan 18, 2024 · 0 comments

Comments

@michaeljherrmann
Copy link

Issue

RGB colors that contain a real number are not supported, while in browsers this works.
The official spec defines real numbers as a valid argument for the modern spec and browsers have supported this for several years so it would be nice to have consistency.

Steps to Reproduce

const { Canvas } = require('canvas');
const canvas = new Canvas();
const ctx = canvas.getContext('2d');

ctx.fillStyle = 'rgb(127,127.0,255)';
console.log(ctx.fillStyle); // output: #000000

ctx.fillStyle = 'rgb(127,127,255)';
console.log(ctx.fillStyle); // output: #7f7fff

I think this parsing may just have to be changed to floats?

Your Environment

  • Version of node-canvas: canvas@2.11.2
  • Environment: node v20.2.0 on macOS 14.2.1 (e.g. node 20.9.0 on macOS 14.1.1):
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