mirror of
https://github.com/igorski/bitmappery.git
synced 2026-07-30 18:48:38 +02:00
code cleanups
This commit is contained in:
@@ -59,9 +59,7 @@ export const hexToRGBA = ( hex: string ): RGBA => {
|
||||
];
|
||||
};
|
||||
|
||||
export const RGBAtoHex = ( rgba: RGBA ): string => {
|
||||
const [ r, g, b, a ] = rgba;
|
||||
|
||||
export const RGBAtoHex = ( [ r, g, b, a ]: RGBA ): string => {
|
||||
const rgbHex = `#${intToHex(r)}${intToHex(g)}${intToHex(b)}`;
|
||||
|
||||
return a === 255 ? rgbHex : `${rgbHex}${intToHex(a)}`;
|
||||
|
||||
@@ -3,7 +3,7 @@ import { hexToRGBA, RGBAtoHex } from "@/utils/color-util";
|
||||
|
||||
describe( "Color utilities", () => {
|
||||
describe( "when converting hex to RGBA", () => {
|
||||
it( "should convert hex a hex value without transparency to be fully opaque", () => {
|
||||
it( "should convert a hex value without transparency to a fully opaque RGBA value", () => {
|
||||
expect( hexToRGBA( "#FF0000" )).toEqual([ 255, 0, 0, 255 ]);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user