promptdojo_

Fifty assets, one brand — locks, seeds, and the QA filter — step 8 of 9

The real palette check: each asset reports its dominant color as a hex value, and you measure how far that sits from the nearest kit color. Distance metric: convert both hexes to RGB and take the largest absolute per-channel difference (so a color that matches red and green but misses blue by 100 is distance 100, not an average that hides it).

Color-science footnote: this is not perceptual distance — the studio-grade metric is Delta E in LAB space. Max-channel RGB is the cheap disqualifier: crude, fast, and plenty to catch a rogue purple.

Write two functions:

  • channel_distance(h1, h2) — max of abs(a - b) across the three channels (hex_to_rgb is provided).
  • nearest_brand_color(dominant) — returns (distance, name) for the closest color in PALETTE.

An asset is on-brand when the distance is 32 or less. The harness prints the verdicts. Expected output:

B01: on-brand  (d=4, nearest=terracotta)
B02: off-brand (d=81, nearest=deep teal)
B03: on-brand  (d=7, nearest=deep teal)
B04: off-brand (d=126, nearest=terracotta)

full-screen editor opens — close anytime to keep reading.