Description
Generate distinct random hex colors meeting a caller WCAG luminance contrast ratio against one fixed opaque hex background, with a finite attempt budget; this is not a complete accessibility audit.
Procedural artwork expresses a visual idea through coordinates, repeated motifs, colors, or explicit placement constraints. A coordinate plan can be checked and reproduced before rendering, while physical material behavior and fabrication require separate information.
Generate distinct random hex colors meeting a caller WCAG luminance contrast ratio against one fixed opaque hex background, with a finite attempt budget; this is not a complete accessibility audit.
When to use this tool
Use this generator to create reproducible contrast constrained palette cases from the supplied model or bank. Inspect the returned evidence before using cases in a test or exercise.
How to use the tool and how it works
- Supply count, background, minimumContrast, maximumAttempts in the field shapes below. Set seed when you need an explicit replay.
- Run the tool and correct any input error. For generated controls, distinguish a successful fixture containing an invalid case from failure to generate the fixture.
- Read colors, contrastRatios, attempts. Use the conventions below. Keep answer-bearing fields separate when presenting an exercise.
Draw distinct RGB colors, delegate relative-luminance contrast against the supplied background, and accept only ratios at least minimumContrast. Return accepted colors, corresponding ratios, and attempts consumed within maximumAttempts.1
| Input field | Meaning and units | Accepted input |
|---|---|---|
| count | Count | Required. Safe integer; minimum 2; maximum 32. |
| background | Background | Required. Text; minimum UTF-16 length 7; maximum UTF-16 length 7. |
| minimumContrast | Minimum Contrast | Required. Finite number; minimum 1; maximum 21. |
| maximumAttempts | Maximum Attempts | Required. Safe integer; minimum 2; maximum 8192. |
| seed | Optional numeric seed; takes precedence over context randomness. Without either, use the fixed tool.io default seed. | Optional. Safe integer. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| colors | Colors | Required. Array of Text; minimum UTF-16 length 7; maximum UTF-16 length 7.; minimum items 2; maximum items 32. |
| contrastRatios | Contrast Ratios | Required. Array of Finite number; minimum 1; maximum 21.; minimum items 2; maximum items 32. |
| attempts | Attempts | Required. Safe integer; minimum 2; maximum 8192. |
| randomness | Replay source and normalized 32-bit seed, or null seed for an advancing context source. | Required. Object; no unknown keys. |
| randomness.seed | Optional safe-integer replay seed; normalization and precedence are explained below. | Required. Safe integer. or Null. |
| randomness.source | Source | Required. Text; one of "context", "seed". |
An explicit safe-integer seed takes precedence over injected context randomness and is normalized to an unsigned 32-bit integer. With no seed and no context source, replay uses the fixed tool.io default seed. A context source must return finite values from zero inclusive to one exclusive; its advancing state must be retained separately. randomness records the source and normalized seed, or null for context. These generators are not cryptographic random sources.
{
"input": {
"count": 3,
"background": "#FFFFFF",
"minimumContrast": 4.5,
"maximumAttempts": 256,
"seed": 42
},
"output": {
"colors": [
"#DA3B32",
"#327F3A",
"#802FCE"
],
"contrastRatios": [
4.513480177756666,
4.961643701943919,
6.53047781897449
],
"attempts": 16,
"randomness": {
"seed": 42,
"source": "seed"
}
}
} Limitations and assumptions
- The constraint is each color against the background, not every palette pair. A finite rejection budget can fail without proving impossibility. Numeric contrast alone does not establish complete accessibility or suitability for a particular text size.
- A replay requires the same complete input and implementation. The stated sampling convention applies within its eligible space. A finite draw does not exhaust all possible outputs; repeats remain possible unless a distinct-selection rule is explicit.
- The field tables state structural bounds; cross-field constraints and bounded search or output budgets also apply. Unknown keys are rejected where the object contract disallows them. Input errors are distinct from null fields and deliberate invalid controls in a successful output.
Alternative or Complementary methods
For a supplied example, inspect the returned construction or delegated check directly. To evaluate a consumer, also test cases chosen for its own boundaries; a generated finite corpus does not establish exhaustive coverage.
References
Similar or alternative tools
- Random Categorical Color Palette Generator
Assign generated distinct hex colors to distinct supplied category labels under a caller OKLab distance threshold and finite attempt limit; assignments preserve category order and do not imply universal distinguishability.
- Random Color Vision Deficiency Palette Generator
Generate distinct sRGB hex colors separated by a caller threshold in OKLab after each existing full-severity protan/deutan/tritan simulation, with a finite attempt limit and no individual accessibility guarantee.