Skip to content

Typescript Library - hexFromArgb - Missing Alpha #34

Open
@wojtek-viirtue

Description

@wojtek-viirtue

The hexFromArgb function is missing the alpha component in its output. This is also related to Issue: Typescript Library - argbFromHex - Incorrect Parsing #33

Input: 2147483648
Expected: #80
Actual: #000000

export const hexFromArgb = (argb: number) => {
const r = colorUtils.redFromArgb(argb);
const g = colorUtils.greenFromArgb(argb);
const b = colorUtils.blueFromArgb(argb);
const outParts = [r.toString(16), g.toString(16), b.toString(16)];
// Pad single-digit output values
for (const [i, part] of outParts.entries()) {
if (part.length === 1) {
outParts[i] = '0' + part;
}
}
return '#' + outParts.join('');
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions