• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

A categorical programming language


Commit MetaInfo

Revisiónf2b642544a0a8ad2ab38de9723667a363e849eba (tree)
Tiempo2021-10-18 12:43:58
AutorCorbin <cds@corb...>
CommiterCorbin

Log Message

Multisample to antialias drawings.

Cambiar Resumen

Diferencia incremental

--- a/hive/demo/mandelbrot.cammy
+++ b/hive/demo/mandelbrot.cammy
@@ -1,7 +1,7 @@
11 (comp
22 (comp
33 (pair v2/mandelbrot (comp (fun/const f-zero) fun/dup))
4- fun/app-20)
4+ fun/app-40)
55 (comp
66 (comp (pair v2/norm (fun/const f/2)) f-lt)
77 (comp
--- a/stub.scm
+++ b/stub.scm
@@ -108,6 +108,24 @@
108108 (let ((w (modulo i width)) (h (/ i width)))
109109 (cons (sw (+ dw (* iw w))) (sh (+ dh (* ih h))))))))
110110
111+(define f-sum (fold f-zero f-add))
112+(define (f-average xs) (/ (f-sum xs) (length xs)))
113+
114+(define ((multisample radius program) p)
115+ (let*
116+ ((px (car p))
117+ (py (cdr p))
118+ (c0 (program p))
119+ (c1 (program (cons (+ px radius) py)))
120+ (c2 (program (cons (- px radius) py)))
121+ (c3 (program (cons px (+ py radius))))
122+ (c4 (program (cons px (- py radius))))
123+ (l (list c0 c1 c2 c3 c4))
124+ (red (f-average (map car l)))
125+ (blue (f-average (map (comp cdr car) l)))
126+ (green (f-average (map (comp cdr cdr) l))))
127+ (cons red (cons blue green))))
128+
111129 (define (finish-channel c)
112130 (inexact->exact (round (* 255 (max 0.0 (min 1.0 c))))))
113131
@@ -122,9 +140,10 @@
122140 (define (draw-png program filename window width height)
123141 (let*
124142 ((vp (viewport window width height))
125- (drawable (draw-pixel program vp))
126143 (size (* width height))
144+ (radius 0.000001)
127145 (channels 3)
146+ (drawable (draw-pixel (multisample radius program) vp))
128147 (pixels
129148 (do ((buf (make-u8vector (* size channels)))
130149 (i 0 (+ i 1)))