Random Diverging Color Scale Generator

Generate a two-ended diverging sRGB color scale with 2 through 32 entries using injected randomness.

Description

A diverging scale uses two color branches around a light midpoint.

A diverging scale uses two color branches around a light midpoint. This generator varies HSL lightness toward the center while switching hue branches.

The tool returns colors (colors). These are generated fixtures or selected identifiers; the result does not replace the caller’s choice of repertoire, dataset or intended use.

When to use Random Diverging Color Scale Generator

Use Random Diverging Color Scale Generator when you already have count and want colors. Use the stated ranges and distribution for a synthetic fixture, then keep the generating parameters with the result.

How to use Random Diverging Color Scale Generator and understand its results

  1. Enter count using the field table below. Match the units, ordering and data boundaries described in the calculation.
  2. Run the tool after checking the stated bounds and matching paired observations or categories. A malformed request gives a tool error rather than a usable measurement.
  3. Read colors. Use the calculation and interpretation below to distinguish amounts, ratios, signs and decision flags where applicable.
  4. Run again for another fixture. Preserve caller-supplied dataset metadata or separate exercise answers from prompts where present.
Input fieldMeaningValue type and boundsRequirement
countColor countinteger; minimum 2; maximum 32Required

Draw two hues in [0,360) and one saturation in [45,90). For 2–32 colors, use the first hue through the midpoint and the second afterward; convert HSL to sRGB hex.

lightness[i] = 35+60×(1−|2i/(count−1)−1|)

The symbols refer to the supplied quantities or generated values described above; unit conversions and comparison boundaries follow the stated implementation.

json
{
  "input": {
    "count": 3
  },
  "randomDraw": 0.25,
  "output": {
    "colors": [
      "#598B27",
      "#F2F9EB",
      "#598B27"
    ]
  }
}

Limitations and assumptions

The hues can coincide. Even counts lack a sample exactly at the center, and perceptual uniformity, contrast and color-vision accessibility are not verified.

Random draws use context.random when injected and otherwise Math.random. No seed input or cryptographic randomness guarantee is provided. Consumed draws must be finite and in [0,1); repeated runs can repeat results.

Alternative or Complementary methods

Random Evenly Spaced Hue Palette Generator: Generate 2 through 32 sRGB hex colors using one random anchor and evenly spaced hue offsets and injected randomness. Random Color Palette Generator: Generate 2 through 32 random sRGB hex colors from bounded HSL coordinates using injected randomness.

Methodological background: CSS Color Module Level 4.1

References

  1. CSS Color Module Level 4 — World Wide Web Consortium

Similar or alternative tools

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies