anchor.diff:  ;;;; (http://antigrain.com/).
   ;;;;
   ;;;; Changelogs:
  +;;;;
  +;;;; 2007-03-11: Extended the protocol to provide a way to sweep only
  +;;;;             a rectangular zone of the resulting state. This was
  +;;;;             done with some new functions: FREEZE-STATE,
  +;;;;             SCANLINE-SWEEP, SCANLINE-Y and CELLS-SWEEP/RECTANGLE.
  +;;;;             The function CELLS-SWEEP is now based on them.
   ;;;;
   ;;;; 2007-02-25: Released under LLGPL this time. Future changes made
   ;;;;             in this file will be thus covered by this license.
  
positive.code:   "AA state. Hold all the cells generated when drawing lines."
    (current-cell (make-cell) :type cell)
    (cells nil)
    (recycling-cells (cons nil nil)))
  
  (defun state-reset (state)
  
negative.code: faster or less memory consuming to reset a state and reuse it,
  rather than creating a new state."
    (cell-reset (state-current-cell state))
    (when (state-end-of-lines state)
      ;; join back the scanlines to form a single list
      (loop for line in (rest (state-scanlines state))
         for eol in (state-end-of-lines state)
         do (setf (cdr eol) line)))
    (let ((cells (nconc (state-dropped-cells state)
                        (state-cells state))))
      (setf (state-recycling-cells state) (cons nil cells)
            (state-scanlines state) nil
            (state-end-of-lines state) nil
            (state-dropped-cells state) nil
            (state-cells state) cells)))
  
  (declaim (inline state-push-current-cell))
  (defun state-push-cell (state cell)
  