feat(theme): Implement comprehensive CRT Filter (scanlines, vignette, noise)

This commit is contained in:
2026-03-09 01:19:16 -04:00
parent 9facecb7a5
commit e635c2925d
3 changed files with 88 additions and 28 deletions
+23 -3
View File
@@ -1,8 +1,9 @@
import time
import math
import random
from imgui_bundle import imgui
class ScanlineOverlay:
class CRTFilter:
def __init__(self):
self.enabled = True
@@ -10,9 +11,28 @@ class ScanlineOverlay:
if not self.enabled:
return
draw_list = imgui.get_foreground_draw_list()
color = imgui.get_color_u32((0.0, 0.0, 0.0, 0.06))
# Scanlines
scanline_color = imgui.get_color_u32((0.0, 0.0, 0.0, 0.06))
for y in range(0, int(height), 2):
draw_list.add_line((0.0, float(y)), (float(width), float(y)), color, 1.0)
draw_list.add_line((0.0, float(y)), (float(width), float(y)), scanline_color, 1.0)
# Subtle Vignette
v_steps = 15
for i in range(v_steps):
alpha = (i / v_steps) ** 2.0 * 0.15
v_color = imgui.get_color_u32((0.0, 0.0, 0.0, alpha))
inset = (v_steps - i) * 6.0
if width > inset * 2.0 and height > inset * 2.0:
draw_list.add_rect((inset, inset), (width - inset, height - inset), v_color, 40.0, 0, 10.0)
# Subtle Random Noise
for _ in range(30):
nx = random.uniform(0.0, width)
ny = random.uniform(0.0, height)
n_alpha = random.uniform(0.01, 0.03)
n_color = imgui.get_color_u32((1.0, 1.0, 1.0, n_alpha))
draw_list.add_rect_filled((nx, ny), (nx + 1.0, ny + 1.0), n_color)
class StatusFlicker:
def get_alpha(self) -> float: