If this becomes an issue for random color selection, example 2 shows one way to compensate. Black text on a blue background - or blue over black - is harder to read in comparison to other colors. In that case, we can use padStart or padEnd to ensure that the string length is at least 6. The human eye is least sensitive to the color blue. The code above will generate a random color but, there may be a chance that the string length will be less than 6. Pseudo random colours generator in javascript. A lightness value of 0% creates black no matter what the hue and saturation values are. Javascript random color generator, but with favouritism to strong colors. A saturation value of 0% creates a grey-scale tone based on lightness alone.Ĭolors blend with black as lightness decreases below 50%. A lightness value of 100% creates white regardless of what the values of hue and saturation are.Ĭolors blend with grey as the saturation decreases and become more washed out depending on how low the saturation gets. In HSL color space, bright colors are represented by a hue based on their position on the color wheel with 100% saturation and a lightness value of 50%:Ĭolors blend with white - and become more "pastel" as lightness increases above 50%. "Bright" colors refer to the colors of an RGB color wheel formed by starting at red and then blending pure red into green, pure green into blue, and finally pure blue back into red again. Where hue is in range 0-360 (without a unit marker when using degrees), and both saturation and lightness are percentages 0-100 with a trailing % sign. HSL color values are specified in CSS as hsl( hue, saturation%, lightness%) Using HSL Colors colors may be the easiest.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |