mirror of
https://github.com/donlucasx/xscapes.git
synced 2026-10-20 08:43:32 +02:00
Lucas asked for more cat in the face and for solid colours, pointing at Claude's own mascot. Both are in, as options rather than as a change -- NewCat still returns exactly what shipped, so nothing moves until he picks. WHY THE DETAIL IS OVERLAYS AND NOT PIXELS. The head is four character rows: ears, forehead, eyes, chin. The eyes already own their row. And the bitmap ORs its rows in PAIRS before quadranting, so a one-row detail is erased by the row above it -- which is not a hypothetical: CatBody has carried a muzzle gap since the day it was drawn and it has never once reached the screen, because the solid row above it fills it in. Overlays are plotted after the body at cell precision and do not have that problem. Four faces: plain, + nose, + whiskers, + inner ears and cheek tufts. The nose is one rose cell below the eyes; the whiskers use the empty cells beside the head, so they cost no face area, and they droop when something is broken -- expression out of geometry that is already on screen. Five coats: cream, Claude's terracotta, ginger, slate, charcoal. The eyes stay bright in every coat deliberately. They carry the companion's state, and a dark mascot-style eye would look right and cost the channel that matters most. Also fixes the boost from the last commit, which the terracotta exposed. It multiplied chroma, which is unbounded, so it did nothing useful to a colour that was already saturated and a great deal of damage: Claude's terracotta went neon on 256 because 2.6x of a vivid orange clips every channel it can. It now lifts TOWARD a target of 100 chroma instead -- enough to clear the grey ramp, past which there is no gain and only distortion. Measured: the sea glyph goes 80 -> 96, terracotta and the worried amber are left untouched. The test for it also had the wrong denominator and I nearly believed it. It counted every glyph, including foam, fur, stars and the moon, which are near-neutral BY DESIGN and belong in the greys -- so it reported 59.3% and read as a regression. Measured against the glyphs actually meant to carry colour it is 100%, up from 76% unboosted. Default is 2.6x, which is the value Lucas picked from the rendered sweep. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AU2ieNpECMF7S4go2CwcDX
65 lines
2.1 KiB
Go
65 lines
2.1 KiB
Go
package term
|
|
|
|
import "testing"
|
|
|
|
// The boost exists to get glyphs off the greyscale ramp on a 256-colour
|
|
// terminal. It must not do that by recolouring things that are meant to be
|
|
// white -- the companion is the obvious one, and a peach cat is worse than a
|
|
// grey sea.
|
|
func TestBoostLeavesNeutralsAlone(t *testing.T) {
|
|
neutral := []struct {
|
|
n string
|
|
c RGB
|
|
}{
|
|
{"cat fur", RGB{236, 228, 210}},
|
|
{"moon", RGB{240, 236, 214}},
|
|
{"foam", RGB{214, 232, 238}},
|
|
}
|
|
for _, e := range neutral {
|
|
for _, k := range []float64{1.5, 2.2, 3.0, 6.0} {
|
|
if got := e.c.Saturate(k); got != e.c {
|
|
t.Errorf("%s moved at %.1fx: rgb(%d,%d,%d) -> rgb(%d,%d,%d)",
|
|
e.n, k, e.c.R, e.c.G, e.c.B, got.R, got.G, got.B)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// And it must actually work on the things that are meant to be colours.
|
|
func TestBoostRescuesColoursFromTheGreyRamp(t *testing.T) {
|
|
for _, e := range []struct {
|
|
n string
|
|
c RGB
|
|
}{
|
|
{"sea glyph", RGB{120, 170, 200}},
|
|
{"deep sea glyph", RGB{70, 110, 150}},
|
|
} {
|
|
if e.c.Index256() < 232 {
|
|
continue // already fine unboosted
|
|
}
|
|
if got := e.c.Saturate(GlyphBoost).Index256(); got >= 232 {
|
|
t.Errorf("%s still lands on the grey ramp after the boost: index %d", e.n, got)
|
|
}
|
|
}
|
|
}
|
|
|
|
// Brightness must broadly survive the boost, or the scene changes exposure
|
|
// rather than gaining colour.
|
|
//
|
|
// The tolerance is 20 rather than 0 because a colour already near the edge of
|
|
// the gamut cannot gain chroma without clipping: the worried amber pushes red
|
|
// past 255, the clamp holds it, and the result lands 15.5 luma darker. That is
|
|
// a bounded, one-sided cost on the most saturated colours in the palette, and
|
|
// worth it -- but it should stay bounded, which is what this asserts.
|
|
func TestBoostPreservesBrightness(t *testing.T) {
|
|
luma := func(c RGB) float64 {
|
|
return 0.30*float64(c.R) + 0.59*float64(c.G) + 0.11*float64(c.B)
|
|
}
|
|
for _, c := range []RGB{{120, 170, 200}, {244, 176, 96}, {70, 110, 150}} {
|
|
before, after := luma(c), luma(c.Saturate(GlyphBoost))
|
|
if d := after - before; d > 20 || d < -20 {
|
|
t.Errorf("rgb(%d,%d,%d) changed brightness by %.1f", c.R, c.G, c.B, d)
|
|
}
|
|
}
|
|
}
|