anchor.diff:  (in-package :mandelbrot)
   
   (defun hue-to-rgb (h)
  -  (let* ((h* (/ (rem h 360.0) 60.0))
  -         (x (- 1 (abs (- (mod h* 2) 1)))))
  +  (declare (optimize (speed 3) (safety 0))
  +           (type single-float h))
  +  (let* ((h* (/ (rem h 360.0f0) 60.0f0))
  +         (x (- 1 (abs (- (mod h* 2.0f0) 1.0f0)))))
  +    (declare (type single-float h* x))
       (cond
  -      ((< h* 1) (values 1 x 0))
  -      ((< h* 2) (values x 1 0))
  -      ((< h* 3) (values 0 1 x))
  -      ((< h* 4) (values 0 x 1))
  -      ((< h* 5) (values x 0 1))
  -      ((< h* 6) (values 1 0 x)))))
  +      ((< h* 1.0f0) (values 1.0f0 x     0.0f0))
  +      ((< h* 2.0f0) (values x     1.0f0 0.0f0))
  +      ((< h* 3.0f0) (values 0.0f0 1.0f0 x))
  +      ((< h* 4.0f0) (values 0.0f0 x     1.0f0))
  +      ((< h* 5.0f0) (values x     0.0f0 1.0f0))
  +      ((< h* 6.0f0) (values 1.0f0 0.0f0 x)))))
   
   (defun m (cr ci iterations)
  -  (let ((zr 0) (zi 0))
  +  (declare (optimize (speed 3) (safety 0))
  +           (type single-float cr ci)
  +           (type fixnum iterations))
  +  (let ((zr 0.0f0) (zi 0.0f0))
  +    (declare (type single-float zr zi))
       (dotimes (i iterations nil)
  +      (declare (type fixnum i))
         (let ((zr2 (* zr zr))
               (zi2 (* zi zi)))
  -      (psetf zr (+ cr (- zr2 zi2))
  -             zi (+ ci (* zi zr) (* zr zi)))
  -      (when (> (+ zr2 zi2) 4)
  -        (return (* (/ i iterations) 360)))))))
  +        (declare (type single-float zr2 zi2))
  +        (psetf zr (+ cr (- zr2 zi2))
  +               zi (+ ci (* zi zr) (* zr zi)))
  +        (when (> (+ zr2 zi2) 4.0f0)
  +          (return (* (/ (float i 0.0f0) (float iterations 0.0f0)) 360.0f0)))))))
   
   (defun render-mandelbrot (x y width height hue-offset)
     "Render one pixel."
  -  (let* ((scale (/ 4 width))
  -         (x^ (- x (/ width 2)))
  -         (y^ (- y (/ height 2)))
  -         (r 0) (g 0) (b 0))
  +  (declare (optimize (speed 3) (safety 0))
  +           (type single-float x y width height hue-offset))
  +  (let* ((scale (/ 4.0f0 width))
  +         (x^ (- x (/ width 2.0f0)))
  +         (y^ (- y (/ height 2.0f0)))
  +         (r 0.0f0) (g 0.0f0) (b 0.0f0))
  +    (declare (type single-float scale x^ y^ r g b))
       (flet ((frag (x y)
  -             (let ((hue (m (- (* scale x) 0.5)
  +             (declare (type single-float x y))
  +             (let ((hue (m (- (* scale x) 0.5f0)
                              (* scale y)
                              25)))
                  (when hue
                    (multiple-value-bind (r* g* b*)
  -                     (hue-to-rgb (+ hue-offset hue))
  +                     (hue-to-rgb (+ hue-offset (the single-float hue)))
  +                   (declare (type single-float r* g* b*))
                      (incf r r*)
                      (incf g g*)
                      (incf b b*))))))
  -      (frag    x^         y^)
  -      (frag (+ x^ 0.5)    y^)
  -      (frag    x^      (+ y^ 0.5))
  -      (frag (+ x^ 0.5) (+ y^ 0.5))
  -      (mezzano.gui:make-colour (/ r 4) (/ g 4) (/ b 4)))))
  +      (frag    x^           y^)
  +      (frag (+ x^ 0.5f0)    y^)
  +      (frag    x^        (+ y^ 0.5f0))
  +      (frag (+ x^ 0.5f0) (+ y^ 0.5f0))
  +      (mezzano.gui:make-colour (/ r 4.0f0) (/ g 4.0f0) (/ b 4.0f0)))))
   
   (defgeneric dispatch-event (frame event)
     (:method (f e)))
  
positive.code:         (hue-offset (rem (get-universal-time) 360)))
      (dotimes (y height)
        (dotimes (x width)
          (setf (mezzano.gui:surface-pixel framebuffer x y) (render-mandelbrot x y width height hue-offset))))
      framebuffer))
  
  (defun mandelbrot-main (width height)
  
negative.code:                 ;; More than one thread, even.
                  (dotimes (y height)
                    (dotimes (x width)
                      (setf (mezzano.gui:surface-pixel framebuffer (+ left x) (+ top y))
                            (render-mandelbrot (float x) (float y) (float width) (float height) (float hue-offset))))
                    (mezzano.gui.compositor:damage-window window left (+ top y) width 1)
                    (loop
                       (let ((evt (mezzano.supervisor:fifo-pop fifo nil)))
  