Files
test/sexp_effects/effects/crt.sexp
gilesb 406cc7c0c7 Initial commit: video effects processing system
Add S-expression based video effects pipeline with modular effect
definitions, constructs, and recipe files.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 12:34:45 +00:00

29 lines
1.0 KiB
Common Lisp

;; CRT effect - old monitor simulation
;; @param line_spacing int [1, 10] default 2
;; @param line_opacity float [0, 1] default 0.3
;; @param vignette float [0, 1] default 0.2
(define-effect crt
((line_spacing 2) (line_opacity 0.3) (vignette_amount 0.2))
(let* ((w (width frame))
(h (height frame))
(cx (/ w 2))
(cy (/ h 2))
(max-dist (sqrt (+ (* cx cx) (* cy cy)))))
(map-pixels frame
(lambda (x y c)
(let* (;; Scanline darkening
(scanline-factor (if (= 0 (mod y line_spacing))
(- 1 line_opacity)
1))
;; Vignette
(dx (- x cx))
(dy (- y cy))
(dist (sqrt (+ (* dx dx) (* dy dy))))
(vignette-factor (- 1 (* (/ dist max-dist) vignette_amount)))
;; Combined
(factor (* scanline-factor vignette-factor)))
(rgb (* (red c) factor)
(* (green c) factor)
(* (blue c) factor)))))))