fix hex color string padding

This commit is contained in:
dank074 2022-03-23 04:15:27 -05:00
parent 1c8c404d3e
commit 01a77db0fd

View File

@ -7,7 +7,16 @@ export class ColorUtils
public static makeColorNumberHex(color: number): string public static makeColorNumberHex(color: number): string
{ {
return ( '#' + color.toString(16)); let val = color.toString(16);
if(val.length < 6)
{
const diff = 6 - val.length;
for(let i = 0; i < diff; i++)
{
val = '0' + val;
}
}
return ( '#' + val);
} }
public static convertFromHex(color: string): number public static convertFromHex(color: string): number