Files
celery/sexp_effects/effects/xector_threshold.sexp
gilesb fc9597456f
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m28s
Add JAX typography, xector primitives, deferred effect chains, and GPU streaming
- Add JAX text rendering with font atlas, styled text placement, and typography primitives
- Add xector (element-wise/reduction) operations library and sexp effects
- Add deferred effect chain fusion for JIT-compiled effect pipelines
- Expand drawing primitives with font management, alignment, shadow, and outline
- Add interpreter support for function-style define and require
- Add GPU persistence mode and hardware decode support to streaming
- Add new sexp effects: cell_pattern, halftone, mosaic, and derived definitions
- Add path registry for asset resolution
- Add integration, primitives, and xector tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-06 17:41:19 +00:00

28 lines
891 B
Common Lisp
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
;; Threshold effect using xector operations
;; Demonstrates where (conditional select) and β (reduction) for normalization
(require-primitives "xector")
(define-effect xector_threshold
:params (
(threshold :type float :default 0.5 :range [0 1] :desc "Brightness threshold (0-1)")
(invert :type bool :default false :desc "Invert the threshold")
)
(let* (
;; Get grayscale luminance as xector
(luma (gray frame))
;; Normalize to 0-1 range
(luma-norm (α/ luma 255))
;; Create boolean mask: pixels above threshold
(mask (if invert
(α< luma-norm threshold)
(α>= luma-norm threshold)))
;; Use where to select: white (255) if above threshold, black (0) if below
(out (where mask 255 0)))
;; Output as grayscale (same value for R, G, B)
(rgb out out out)))