Function: artist-find-direction
artist-find-direction is a byte-compiled function defined in
artist.el.gz.
Signature
(artist-find-direction X1 Y1 X2 Y2)
Documentation
Find the direction from point X1,Y1 to X2,Y2.
Returns a DIRECTION, a number 0--7, coded as follows:
5 6 7
\ | /
4 - * - 0
/ | \
3 2 1
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/artist.el.gz
;; artist-find-direction
;;
;;
;;
(defun artist-find-direction (x1 y1 x2 y2)
"Find the direction from point X1,Y1 to X2,Y2.
Returns a DIRECTION, a number 0--7, coded as follows:
5 6 7
\\ | /
4 - * - 0
/ | \\
3 2 1"
(let ((delta-x (- x2 x1))
(delta-y (- y2 y1)))
(cond ((>= delta-x (* 2 (abs delta-y))) 0)
((>= delta-y (* 2 (abs delta-x))) 2)
((>= (- delta-x) (* 2 (abs delta-y))) 4)
((>= (- delta-y) (* 2 (abs delta-x))) 6)
((and (>= delta-x 0) (>= delta-y 0)) 1)
((and (<= delta-x 0) (>= delta-y 0)) 3)
((and (<= delta-x 0) (<= delta-y 0)) 5)
((and (>= delta-x 0) (<= delta-y 0)) 7))))