Automattic/node-canvas

RGB functions do not support real numbers

Open

#2.339 geöffnet am 18. Jan. 2024

Auf GitHub ansehen
 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)JavaScript (1.140 Forks)batch import
Good first issueHelp wanted

Repository-Metriken

Stars
 (9.524 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 34T 18h) (2 gemergte PRs in 30 T)

Beschreibung

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):

Contributor Guide