From 331c5c2deae09c5861db6519fc485db79018d7c6 Mon Sep 17 00:00:00 2001 From: David Schmenk Date: Fri, 13 Dec 2024 13:32:44 -0800 Subject: [PATCH] Calc true NTSC color wheel values for RGB --- src/dhgr.tk/utils/dhgrrgb.pla | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/dhgr.tk/utils/dhgrrgb.pla b/src/dhgr.tk/utils/dhgrrgb.pla index fea0d3b..445dc4c 100644 --- a/src/dhgr.tk/utils/dhgrrgb.pla +++ b/src/dhgr.tk/utils/dhgrrgb.pla @@ -73,12 +73,20 @@ def luv2rgb(l, u, v)#3 // l = fix 1.7, u, v = fix s.15; return fix 0.8 * 3 end def calcChroma(angle)#0 - var r, g, b + var l, r, g, b byte i + l = 256 - contrast for i = 0 to 3 // Calculate and NTSC RGB for this DHGR pixel - r, g, b = luv2rgb(256 - contrast, cos(angle), sin(angle)) + // According to what I could find out about the NTSC color wheel: + // Red maxes at 103.5 degrees + // Green maxes at 240.7 degrees + // Blue maxes at 347.1 degrees + r = max(0, l + (cos(angle - 104) >> 7)) + g = max(0, l + (cos(angle - 241) >> 7)) + b = max(0, l + (cos(angle - 347) >> 7)) + //r, g, b = luv2rgb(256 - contrast, cos(angle), sin(angle)) ntscChroma[i*3 + RED] = (r + 2) >> 2 ntscChroma[i*3 + GRN] = (g + 2) >> 2 ntscChroma[i*3 + BLU] = (b + 2) >> 2