Function: artist-ellipse-mirror-quadrant

artist-ellipse-mirror-quadrant is a byte-compiled function defined in artist.el.gz.

Signature

(artist-ellipse-mirror-quadrant POINT-LIST)

Documentation

Mirror a POINT-LIST describing first quadrant to create a complete ellipse.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/artist.el.gz
(defun artist-ellipse-mirror-quadrant (point-list)
  "Mirror a POINT-LIST describing first quadrant to create a complete ellipse."
  (let ((right-half nil)
	(left-half nil))

    ;; First, if last char in that quadrant is `/', then replace it with `)'
    ;; This way we avoids things
    ;;                      ---------                        ---------
    ;;                     /         \                      /         \
    ;; that look like:    \           /  instead we get:   (           )
    ;;                     \         /                      \         /
    ;;                      ---------                        ---------
    (let ((last-coord (car (last point-list))))
      (if (= (artist-coord-get-new-char last-coord) ?/)
	  (artist-coord-set-new-char last-coord artist-ellipse-right-char)))

    ;; Create the other part of the right half by mirroring the first part
    (setq right-half
	  (append
	   point-list
	   (mapcar
	    (lambda (coord)
	      (let ((c (artist-coord-get-new-char coord)))
		(artist-new-coord (artist-coord-get-x coord)
				  (- (artist-coord-get-y coord))
				  (cond ((= c ?/) ?\\)
					((= c ?\\) ?/)
					(t c)))))
	    ;; The cdr below is so we don't draw the middle right char twice
	    (cdr (reverse point-list)))))

    ;; Create the left half by mirroring the right half.
    (setq left-half
	  (mapcar
	   (lambda (coord)
	     (let ((c (artist-coord-get-new-char coord)))
	       (artist-new-coord (- (artist-coord-get-x coord))
				 (artist-coord-get-y coord)
				 (cond ((= c ?/)  ?\\)
				       ((= c ?\\) ?/)
				       ((= c artist-ellipse-right-char)
					artist-ellipse-left-char)
				       (t c)))))
	   ;; The cdr and butlast below is so we don't draw the middle top
	   ;; and middle bottom char twice.
	   (butlast (cdr (reverse right-half)))))
    (append right-half left-half)))