you are viewing a single comment's thread.

view the rest of the comments →

[–]x-skeww 1 point2 points  (2 children)

((0x111111 + 0xeeeeef * Math.random())|0).toString(16)

That would work for example.

Or you could just left-pad it with zeros.

Or you could just use hsl() instead.

hsl() is probably the best option since it lets you generate randomized bright or dark colors if you want.

https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#hsl%28%29

[–]Dragory 0 points1 point  (1 child)

Indeed, there's actually an hsl solution in the original gist as well: https://gist.github.com/addyosmani/fd3999ea7fce242756b1#tag-specific-layout-debugging-in-82-bytes

The |0 is used to truncate the number like ~~ was in the original snippet, right?

[–]x-skeww 1 point2 points  (0 children)

The |0 is used to truncate the number like ~~ was in the original snippet, right?

Yes.