Function: artist-vap-find-endpoint

artist-vap-find-endpoint is a byte-compiled function defined in artist.el.gz.

Signature

(artist-vap-find-endpoint X1 Y1 STEP-X STEP-Y ACCEPT-SET REJECT-SET)

Documentation

Find one endpoint for line through X1, Y1.

The endpoint is searched for in the direction defined by STEP-X, STEP-Y, accepting characters in the list ACCEPT-SET, stopping immediately when finding characters in the list REJECT-SET. Fuzziness, that is the number of consecutive characters not in ACCEPT-SET to allow as part of the line, is determined by the variable artist-vaporize-fuzziness. An endpoint is a cons pair, (ENDPOINT-X . ENDPOINT-Y).

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/artist.el.gz
;;
;; Vaporizing (erasing) line and lines
;;


(defun artist-vap-find-endpoint (x1 y1 step-x step-y accept-set reject-set)
  "Find one endpoint for line through X1, Y1.
The endpoint is searched for in the direction defined by STEP-X, STEP-Y,
accepting characters in the list ACCEPT-SET, stopping immediately
when finding characters in the list REJECT-SET.  Fuzziness, that is
the number of consecutive characters not in ACCEPT-SET to allow as
part of the line, is determined by the variable `artist-vaporize-fuzziness'.
An endpoint is a cons pair, (ENDPOINT-X . ENDPOINT-Y)."
  (let ((x x1)
	(y y1)
	(x-last x1)
	(y-last y1)
	(done nil))
    (while (not done)
      (let ((c (artist-get-char-at-xy-conv x y)))
	(cond ((memq c reject-set)
	       (setq done t))

	      ;; We found a character we are accepting as part of the line.
	      ;; Update position
	      ((memq c accept-set)
	       (setq x-last x
		     y-last y
		     x (+ x step-x)
		     y (+ y step-y))
	       (if (or (< x 0) (< y 0))	;stop at the edge
		   (setq done t)))

	      ;; We found a character we are not accepting as part of
	      ;; the line Search `artist-vaporize-fuzziness'
	      ;; characters away from this position in the same
	      ;; direction to see if there are any characters in the
	      ;; accept-set. If not, we have found the endpoint.
	      (t
	       (let ((fuzziness artist-vaporize-fuzziness)
		     (x-tmp x)
		     (y-tmp y))

		 ;; while we have more fuzziness left and we have not
		 ;; found a character accepted as a line, move
		 ;; forward!
		 (while (and (> fuzziness 0) (not (memq c accept-set)))
		   (setq x-tmp (+ x-tmp step-x))
		   (setq y-tmp (+ y-tmp step-y))
		   (setq c (artist-get-char-at-xy-conv x-tmp y-tmp))
		   (setq fuzziness (- fuzziness 1)))
		 (if (memq c accept-set)

		     ;; The line continues on the other side of the
		     ;; not-accepted character.
		     (setq x x-tmp
			   y y-tmp)

		   ;; Else: We couldn't find any line on the other side.
		   ;; That means we are done searching for the endpoint.
		   (setq done t)))))))
    (cons x-last y-last)))