# Colour curves

> Custom curves with Y, R, G and B channels over a histogram, and hue-versus-saturation with its hue band: a plot with a grid, control points, and the input and output of the selected point in numbers.

Source: https://kwark.space/designSystem/components/colour-curves

## Usage

### What it is
Curves remap one value to another. The **custom** curve maps input level to output level per channel; a gentle S adds contrast. **Hue versus saturation** maps each hue to a saturation multiplier: the specimen pulls cyan down (the monitor's spill on the wall) and leaves skin alone.

### When to use
- After primaries, for shaped contrast, a soft roll-off in the highlights, or one hue band.

### When not to
- For overall balance: use the [Colour wheels](https://kwark.space/designSystem/components/colour-wheels.md). Curves move fast and break skin easily.

### Behaviour
- Click the line to add a point; drag to move; Delete removes; double-click the plot resets the channel.
- Y edits luma only; R, G, B edit one channel. The link button edits all three together.
- The selected point's input and output are always written under the plot.
- Hue curves wrap: the left and right edges are the same red.

**Do:** An S on luma with five points, the selected point reading *In 0.550 · Out 0.551*.

**Don't:** A curve with no grid, no numbers and no way to know which channel it changes.

## Style

### Anatomy

1. **Head** (28px): curve name, channel switch Y R G B (R G B carry a 6px dot), link toggle or reset.
2. **Plot**: square on `--k-pro-lane`, grid at quarters in `--k-pro-line`, the identity as a 1px dashed line, the curve at 1.5px in `--k-text` (or the channel's scope colour).
3. **Points**: 8px squares, 1.5px `--k-text` border; selected point filled.
4. **Histogram** (custom only): the clip's luma behind the grid at 18%.
5. **Hue band** (hue curves only): 6px band under the plot, the same hues as the wheel ring.
6. **Read-out** (24px): selected point's input and output, three decimals or degrees.

### Tokens

| Token | Light | Dark |
|---|---|---|
| `--k-pro-panel` | #f6f7f9 | #19191b |
| `--k-pro-control` | #ffffff | #2a2a2e |
| `--k-pro-line` | #d3d9e0 | rgba(255, 255, 255, .09) |
| `--k-text` | #0f172a | #e3e3e3 |
| `--k-text-2` | #5b6779 | #9ca3af |
| `--k-scope-r` | #ff6a5c |  |
| `--k-scope-g` | #5fd889 |  |
| `--k-scope-b` | #5fa0ff |  |
| `--k-hue-r` | #d4574b |  |
| `--k-hue-c` | #4fb8c4 |  |

### Numbers
| Part | Value |
|---|---|
| Plot | square, up to 240px; two plots side by side from 520px |
| Curve stroke | 1.5px |
| Point | 8 × 8px, hit area 20px |
| Read-out | 12px words, 11px figures |

## Code

### React

Use the HTML below with `kwark.css`. The example shows the markup and styling. Supply any application behavior described on this page.

### HTML and CSS

Works anywhere with `kwark.css`.

```html
<section class="kw-pro kw-pro-panel kw-pro-curves" aria-label="Curves, node 02 Contrast">
  <div class="kw-pro-bar"><strong>Curves</strong><span class="kw-pro-dim kw-pro-ellip">Clip 04 · node 02 Contrast</span></div>
  <div class="kw-pro-curves__row">
    <div class="kw-pro-curves__cell"><div class="kw-pro-curves__head"><span>Custom</span><div class="kw-pro-seg kw-pro-seg--text kw-pro-chan" role="group" aria-label="Channel"><button type="button" aria-pressed="true">Y</button><button type="button" aria-pressed="false" data-c="r">R</button><button type="button" aria-pressed="false" data-c="g">G</button><button type="button" aria-pressed="false" data-c="b">B</button></div><button class="kw-pro-btn" type="button" aria-pressed="true" aria-label="Edit R, G and B together" title="Edit R, G and B together"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 13a4.5 4.5 0 0 0 6.4 0l3-3a4.5 4.5 0 0 0-6.4-6.4l-1 1M14 11a4.5 4.5 0 0 0-6.4 0l-3 3a4.5 4.5 0 0 0 6.4 6.4l1-1"/></svg></button></div>
      <div class="kw-pro-plot" role="group" aria-label="Custom curve, luma, 5 points"><svg viewBox="0 0 100 100" preserveAspectRatio="none" aria-hidden="true"><path class="kw-pro-hist" d="M0 100L0.0 95.9L1.6 93.8L3.1 90.3L4.7 85.0L6.3 77.8L7.8 68.9L9.4 59.5L10.9 51.0L12.5 45.0L14.1 43.0L15.6 45.4L17.2 51.6L18.8 60.2L20.3 69.6L21.9 78.3L23.4 85.3L25.0 90.3L26.6 93.3L28.1 94.7L29.7 95.0L31.3 94.3L32.8 92.9L34.4 90.8L35.9 88.3L37.5 85.5L39.1 82.5L40.6 79.8L42.2 77.7L43.8 76.3L45.3 76.0L46.9 76.8L48.4 78.5L50.0 80.9L51.6 83.7L53.1 86.6L54.7 89.4L56.3 91.8L57.8 93.7L59.4 95.2L60.9 96.3L62.5 97.0L64.1 97.4L65.6 97.7L67.2 97.8L68.8 97.9L70.3 98.0L71.9 98.0L73.4 98.0L75.0 97.9L76.6 97.5L78.1 96.6L79.7 94.8L81.3 92.5L82.8 90.5L84.4 90.1L85.9 91.4L87.5 93.7L89.1 95.8L90.6 97.1L92.2 97.7L93.8 97.9L95.3 98.0L96.9 98.0L98.4 98.0L100.0 98.0L100 100Z"/><path class="kw-pro-g" d="M25 0V100M50 0V100M75 0V100M0 25H100M0 50H100M0 75H100" vector-effect="non-scaling-stroke"/><path class="kw-pro-diag" d="M0 100L100 0" vector-effect="non-scaling-stroke"/><path class="kw-pro-curve" d="M0 96C10 92 18 84 25 77S45 55 55 45 72 26 82 18 96 4 100 2" vector-effect="non-scaling-stroke"/></svg>
    <span class="kw-pro-pt" style="left:0%;top:96%"></span><span class="kw-pro-pt" style="left:25%;top:77%"></span><span class="kw-pro-pt" data-on style="left:55%;top:45%"></span><span class="kw-pro-pt" style="left:82%;top:18%"></span><span class="kw-pro-pt" style="left:100%;top:2%"></span></div>
      <div class="kw-pro-curves__read"><span>Point 3</span><span>In <b>0.550</b></span><span>Out <b>0.551</b></span><span class="kw-pro-sp"></span><span class="kw-pro-dim">Soft clip 0.98</span></div></div>
    <div class="kw-pro-curves__cell"><div class="kw-pro-curves__head"><span>Hue vs saturation</span><span class="kw-pro-sp"></span><button class="kw-pro-btn" type="button" aria-label="Reset hue vs saturation" title="Reset hue vs saturation"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 12a9 9 0 1 0 2.7-6.4L3 8M3 3v5h5"/></svg></button></div>
      <div class="kw-pro-plot" role="group" aria-label="Hue versus saturation, 5 points"><svg viewBox="0 0 100 100" preserveAspectRatio="none" aria-hidden="true"><path class="kw-pro-g" d="M25 0V100M50 0V100M75 0V100M0 25H100M0 50H100M0 75H100" vector-effect="non-scaling-stroke"/><path class="kw-pro-diag" d="M0 50H100" vector-effect="non-scaling-stroke"/><path class="kw-pro-curve" d="M0 50C6 50 7 41 9 40S13 47 18 50 40 50 46 50 50 64 54 64 60 51 66 50 100 50 100 50" vector-effect="non-scaling-stroke"/></svg>
    <span class="kw-pro-pt" style="left:9%;top:40%"></span><span class="kw-pro-pt" style="left:18%;top:50%"></span><span class="kw-pro-pt" style="left:46%;top:50%"></span><span class="kw-pro-pt" data-on style="left:54%;top:64%"></span><span class="kw-pro-pt" style="left:66%;top:50%"></span><span class="kw-pro-hueband" aria-hidden="true"></span></div>
      <div class="kw-pro-curves__read"><span>Point 4 · cyan</span><span>Hue <b>196°</b></span><span>Saturation <b>0.72×</b></span></div></div>
  </div>
</section>
```

## Accessibility

### Keyboard
| Key | Does |
|---|---|
| Tab | Next point |
| Arrows | Move the point by 0.005 (⇧ ×10) |
| + / Delete | Add a point at the next free input / remove the point |
| Y, R, G, B | Switch channel while the plot has focus |

### ARIA
- The plot is a `group` labelled with its curve, channel and point count; each point is a slider pair announced as *Point 3, input 0.550, output 0.551*.
- The channel switch is a toggle group with `aria-pressed`.

## For agents

### Rules

- **Must** show the selected point's input and output as numbers.
- **Always** draw the identity line so the change is visible against it.
- **Must** wrap hue curves at the red edge.
- **Never** tint the whole plot by the channel; mark the channel by its letter and dot.

### AI readiness test

**Task:** Add a hue-versus-luminance curve next to hue-versus-saturation.

**Give the agent:** Colour curves, Colour wheels, Video scopes.

**Constraint:** Same plot size and hue band; keyboard editing.

**A reliable answer:**
- Square plot with grid and identity line
- Hue band
- Wrap at red
- Points move by arrows
- Selected point read-out in degrees and multiplier
