Skip to content

3-digit hex values are parsed incorrectly for fillStyle #107

@adedomin

Description

@adedomin

Expected Behaviour

  1. ctx.fillStyle = '#999'; // should be a grey color

Expected-Picture

Actual Behaviour

  1. ctx.fillStyle = '#999'; // is actually blue-ish

Actual-Picture

Steps To Reproduce

  1. See example snippet, or set ctx.fillStyle to any 3-digit hex value

Any Relevant Code Snippets

#!/usr/bin/env node
'use strict';

const PImage = require('pureimage');
const fs = require('fs');

const canvas = PImage.make(50,50);
const ctx = canvas.getContext('2d');

ctx.fillStyle = '#999';
// ctx.fillStyle = '#999999';
ctx.fillRect(0,0,50,50);

PImage.encodePNGToStream(
    ctx.bitmap,
    fs.createWriteStream('./example.png')
).then(() => console.log('xdg-open ./example.png'));

Platform

OS: Linux Fedora 32
Node Version: v12
NPM Version: N/A
PureImage Version: 0.2.4

Any Additional Info

Already fixed it. Wasn't sure if you want a PR for it or if you want to implement the fix yourself. Let me know. Side note, would you want all the defined CSS colors to be in named_colors? I can add them and I have an interest in them being included.

https://github.com/adedomin/node-pureimage/commit/699cf606f6ba002413fedd3446682358ae319de0#

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions