;;;; Copyright (c) 2007 Jeremy English <jhe@jeremyenglish.org>
;;;;
;;;; Permission to use, copy, modify, distribute, and sell this software and its
;;;; documentation for any purpose is hereby granted without fee, provided that
;;;; the above copyright notice appear in all copies and that both that
;;;; copyright notice and this permission notice appear in supporting
;;;; documentation.  No representations are made about the suitability of this
;;;; software for any purpose.  It is provided "as is" without express or
;;;; implied warranty.
;;;;
;;;; Created: 25-June-2007

(in-package :chess-trace)

(defun put-sprite-on-canvas (sprite canvas x-offset y-offset)
  (let ((w (width sprite))
        (h (height sprite)))
    (dotimes (x w)
      (dotimes (y h)
        (setf (pixel-ref canvas (+ x x-offset) (+ y y-offset) ) (pixel-ref sprite x y ))))))

(defun copy-area (can &key (x 0) (y 0) width height)
  "Copy an area of one canvas to a new canvas."
  (let ((ncan (make-canvas :width width :height height)))
    (dotimes (xi width)
      (dotimes (yi height)
        (setf (pixel-ref ncan xi yi) (pixel-ref can (+ xi x) (+ yi y)))))
    ncan))