fix: pr-bug-scan findings from #1564 (#1610)

Restored proportional-alpha fade for antialiased magenta-key edges by replacing the hard g>=60 gate with a dominance-floor (dom>0.4) check while keeping purples/pinks rejected.

### Findings addressed
-  [medium] src/renderer/src/components/pet/pet-blob-cache.ts:130 — Magenta key no longer fades antialiased edges, leaving halos

Rebased onto current main; bot's intended file (sidekick-blob-cache.ts) maps to current main's pet-blob-cache.ts (sidekick rename hasn't landed).

Co-authored-by: orca-bot <bot@stably.ai>
This commit is contained in:
buf0-bot[bot]
2026-05-09 04:10:33 -07:00
committed by GitHub
co-authored by orca-bot
parent e6e45dc22a
commit 616dbb3117
@@ -133,10 +133,16 @@ function magentaScore(r: number, g: number, b: number): number {
// (saturated R+B, very low G) so legitimate purples and pinks (e.g.
// 128,0,128 or 255,128,200) aren't keyed out of imported sprite art.
const minRB = Math.min(r, b)
if (minRB <= 200 || g >= 60) {
if (g >= minRB) {
return 0
}
const dom = (minRB - g) / 255 // how much R and B dominate green
// Why: require a strong R+B dominance over G so purples/pinks (e.g.
// 128,0,128 or 255,128,200) aren't keyed, while still letting antialiased
// edge pixels (e.g. 255,128,255 → dom≈0.5) fade with proportional alpha.
if (dom <= 0.4) {
return 0
}
return Math.max(0, Math.min(1, dom * 1.4))
}