mirror of
https://github.com/donlucasx/xscapes.git
synced 2026-10-20 08:43:32 +02:00
The fix the last session proposed was wrong, and it was U+2580 in disguise.
"Pick the half-block ORIENTATION per cell, so every gap is painted in the
colour it sits against" cannot work: Menlo's block ink runs 4.6 to 29.4 of a
30px row, so a cell has exactly two achievable partitions and BOTH leave the
background showing.
U+2584 up[0,17] down[17,29.4] UP[29.4,30] -- 0.6px wrong at the bottom
U+2580 DOWN[0,4.6] up[4.6,17] down[17,30] -- 4.6px wrong at the top
Making the sliver match what is below forces bg = the lower colour, which
means U+2580 everywhere -- the glyph term.LowerHalf exists to avoid. There is
no third glyph either: every block element shares that ink box, so the bottom
0.6px of any cell that draws one is its background. The leak is the terminal,
not the renderer.
What is actually wrong is the RUN, not the pixel. notes/rulecount rasterises
a frame at Terminal.app's geometry and counts rules AND their widths. His own
crop calibrates it: at the disc's centre column, 17px of sky (50,95,131), 12px
of rim (165,137,136), ONE px of (100,113,134) -- and 0.43*rim + 0.57*sky is
(96,112,133), within two counts on every channel. So inkBot 29.4 and an alpha
of 0.43 are measured off his screen, not assumed.
At his own 128x27 the whole frame carries four rules and all four are on the
disc: two FIVE cells wide at the flat top and bottom caps, two one cell wide
at the shoulders. A split cell whose neighbour's edge falls in the same cell
on the same side is on a horizontal stretch of the silhouette -- it buys no
roundness at all, and the only thing it draws is seventy pixels of rule.
Shore.FlatCaps gives those cells a whole cell and leaves the sloped ones
split, which is where the curve lives. Over 6 widths x 7 heights x 48
half-hours: longest rule run 5 cells -> 1, rule cells 12920 -> 4922. The
silhouette's width profile is IDENTICAL; only the cap's fill goes from half a
row to a whole one. Gated on term.NoSplitCells, so Ghostty keeps the full
half-row edge everywhere.
Two things about the tests. TestTheMoonIsRoundAtEveryHeight was running at
this suite's zero values, which are GHOSTTY'S -- NoSplitCells false, the very
switch the collapse is gated on -- so it was clearing a disc nobody ships. It
now runs both flag states. And TestNoRuleRunsAcrossTheDiscsCap was checked to
FAIL with FlatCaps off (60x16, two cells of rule side by side) before being
trusted, because a test that passes either way proves nothing.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015GQLYhGnSpasru9xeJbJry
124 lines
4.3 KiB
Go
124 lines
4.3 KiB
Go
package scape
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/donlucasx/xscapes/internal/canvas"
|
|
"github.com/donlucasx/xscapes/internal/term"
|
|
)
|
|
|
|
// The moon is a disc at every height, never a rectangle.
|
|
//
|
|
// His report, 2026-09-04, from a 124x52 window: "the moon looks worse than
|
|
// before". Measured (notes/moonprobe): at the 22 or 23 rows that window gives
|
|
// the scape, the disc's radius is 1.92 rows -- just under two -- so the rows
|
|
// that would have been its narrow tips fall outside it and the three that
|
|
// remain are all seven cells wide. A rectangle. At 27 rows the radius is two
|
|
// and the tips come back. The gradient work had not touched it; the shape was
|
|
// a function of the window height alone, and it was wrong at his.
|
|
//
|
|
// Read from the rendered frame: a cell counts as moon if it is brighter than
|
|
// the sky beside it, and a split cell (U+2580) counts by the half that is.
|
|
//
|
|
// ⚠ Both flag states, and that is not decoration. This suite's zero values are
|
|
// Ghostty's, and PRODUCTION on his machine is Terminal.app: NoSplitCells true,
|
|
// which is the switch the flat-cap collapse is gated on. Running only the zero
|
|
// values would clear a disc nobody ships. That is the s13 lesson -- a harness
|
|
// pinned to a non-production mode exonerates falsely -- and it cost four wrong
|
|
// answers the first time.
|
|
func TestTheMoonIsRoundAtEveryHeight(t *testing.T) {
|
|
for _, flat := range []bool{false, true} {
|
|
t.Run(map[bool]string{false: "ghostty", true: "terminal.app"}[flat], func(t *testing.T) {
|
|
prev, prevHalf := term.NoSplitCells, term.LowerHalf
|
|
term.NoSplitCells, term.LowerHalf = flat, flat
|
|
defer func() { term.NoSplitCells, term.LowerHalf = prev, prevHalf }()
|
|
moonRoundAtEveryHeight(t)
|
|
})
|
|
}
|
|
}
|
|
|
|
func moonRoundAtEveryHeight(t *testing.T) {
|
|
t.Helper()
|
|
for h := 18; h <= 30; h++ {
|
|
c := canvas.New(124, h, canvas.AlphaFar, canvas.AlphaMid, canvas.AlphaNear)
|
|
sh := NewShore(7, false)
|
|
sh.MoonX = 0.28
|
|
sh.Update(c, 3.0, Activity{Working: true, Level: 0.55, TimeOfDay: 0.0245, ContextUsed: 0.06})
|
|
mx, my := sh.MoonPos()
|
|
bright := func(col term.RGB, y int) bool {
|
|
ref := lumaOf(c.BGAt(2, y))
|
|
return lumaOf(col)-ref > 40
|
|
}
|
|
// Moon coverage per row, in half-cells, over a box wider than any disc;
|
|
// and per row how many cells are FULL moon and how many are halves.
|
|
var rows, fulls, halves []int
|
|
var ys []int
|
|
for y := my - 5; y <= my+5; y++ {
|
|
if y < 0 || y >= c.H {
|
|
continue
|
|
}
|
|
n, full, half := 0, 0, 0
|
|
for x := mx - 10; x <= mx+10; x++ {
|
|
if x < 0 || x >= c.W {
|
|
continue
|
|
}
|
|
ch, fg, bg := c.ResolveAt(x, y, term.Profile256)
|
|
// ▄ counts as a half cell too: under LowerHalf the same split is
|
|
// drawn the other way up, and this suite runs at LowerHalf's
|
|
// zero value, so counting only ▀ would report a Terminal.app
|
|
// disc as having no half cells at all.
|
|
if ch == '▄' {
|
|
fg, bg = bg, fg
|
|
ch = '▀'
|
|
}
|
|
switch {
|
|
case ch == '▀':
|
|
if bright(fg, y) != bright(bg, y) {
|
|
half++
|
|
}
|
|
if bright(fg, y) {
|
|
n++
|
|
}
|
|
if bright(bg, y) {
|
|
n++
|
|
}
|
|
case bright(bg, y):
|
|
n += 2
|
|
full++
|
|
}
|
|
}
|
|
if n > 0 {
|
|
rows = append(rows, n)
|
|
fulls = append(fulls, full)
|
|
halves = append(halves, half)
|
|
ys = append(ys, y)
|
|
}
|
|
}
|
|
if len(rows) < 3 {
|
|
t.Errorf("h=%d: the moon covers only %d rows (%v) -- too small to be a disc", h, len(rows), rows)
|
|
continue
|
|
}
|
|
widest := 0
|
|
for _, n := range rows {
|
|
if n > widest {
|
|
widest = n
|
|
}
|
|
}
|
|
top, bottom := rows[0], rows[len(rows)-1]
|
|
t.Logf("h=%d: moon rows %v (half-cells per row, rows %d..%d)", h, rows, ys[0], ys[len(ys)-1])
|
|
if top >= widest || bottom >= widest {
|
|
t.Errorf("h=%d: the moon's top row is %d half-cells wide and its bottom %d against a widest of %d -- that is a rectangle, not a disc",
|
|
h, top, bottom, widest)
|
|
}
|
|
// No pip: a tip row made of half cells must not carry a lone full
|
|
// cell in its middle (the second report, 133x27: "the moon not
|
|
// looking so good"). A flat top of several full cells with half-cell
|
|
// shoulders is a disc; one full cell between halves is a spike.
|
|
for _, k := range []int{0, len(rows) - 1} {
|
|
if fulls[k] == 1 && halves[k] > 0 {
|
|
t.Errorf("h=%d: row %d of the moon is one full cell between %d half cells -- a pip, not a curve", h, ys[k], halves[k])
|
|
}
|
|
}
|
|
}
|
|
}
|