Files
rose-ash/artdag/l1/sexp_effects/effects/mosaic.sexp
giles 1a74d811f7
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m33s
Incorporate art-dag-mono repo into artdag/ subfolder
Merges full history from art-dag/mono.git into the monorepo
under the artdag/ directory. Contains: core (DAG engine),
l1 (Celery rendering server), l2 (ActivityPub registry),
common (shared templates/middleware), client (CLI), test (e2e).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

git-subtree-dir: artdag
git-subtree-mainline: 1a179de547
git-subtree-split: 4c2e716558
2026-02-27 09:07:23 +00:00

31 lines
956 B
Common Lisp

;; Mosaic effect - built from primitive xector operations
;;
;; Uses:
;; pool-frame - downsample to cell averages
;; cell-indices - which cell each pixel belongs to
;; gather - look up cell value for each pixel
(require-primitives "xector")
(define-effect mosaic
:params (
(cell-size :type int :default 16 :range [4 64] :desc "Size of mosaic cells")
)
(let* (
;; Pool frame to get average color per cell (returns r,g,b,lum xectors)
(pooled (pool-frame frame cell-size))
(cell-r (nth pooled 0))
(cell-g (nth pooled 1))
(cell-b (nth pooled 2))
;; For each output pixel, get its cell index
(cell-idx (cell-indices frame cell-size))
;; Gather: look up cell color for each pixel
(out-r (gather cell-r cell-idx))
(out-g (gather cell-g cell-idx))
(out-b (gather cell-b cell-idx)))
;; Reconstruct frame
(rgb out-r out-g out-b)))