Function: artist-draw-ellipse
artist-draw-ellipse is a byte-compiled function defined in
artist.el.gz.
Signature
(artist-draw-ellipse X1 Y1 X2 Y2)
Documentation
Draw an ellipse with center at X1, Y1 and point X2,Y2.
Output is an ellipse, which is a list (END-POINT-1 END-POINT-2 SHAPE-INFO).
END-POINT-1 and END-POINT-2 are two-element vectors on the form [X Y]. SHAPE-INFO is a two-element vector on the form [POINT-LIST FILL-INFO].
POINT-LIST is a list of vectors on the form [X Y SAVED-CHAR NEW-CHAR]. FILL-INFO is a list of vectors on the form [X Y ELLIPSE-WIDTH-ON-THIS-LINE].
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/artist.el.gz
(defun artist-draw-ellipse (x1 y1 x2 y2)
"Draw an ellipse with center at X1, Y1 and point X2,Y2.
Output is an ellipse, which is a list (END-POINT-1 END-POINT-2 SHAPE-INFO).
END-POINT-1 and END-POINT-2 are two-element vectors on the form [X Y].
SHAPE-INFO is a two-element vector on the form [POINT-LIST FILL-INFO].
POINT-LIST is a list of vectors on the form [X Y SAVED-CHAR NEW-CHAR].
FILL-INFO is a list of vectors on the form [X Y ELLIPSE-WIDTH-ON-THIS-LINE]."
(let* ((artist-line-char (artist-compute-line-char))
(artist-line-char-set artist-line-char)
(width (abs (- x2 x1)))
(height (abs (- y2 y1)))
;;
;; When we draw our ellipse, we want it to go through the cursor
;; position, but since x1,y1, x2,y2 marks the corners of one
;; of the quadrants, we have to enlarge the ellipse a bit.
;; Ok, so then why by sqrt(2)?
;; It comes from the equation for the ellipse (where a is the
;; x-radius and b is the y-radius):
;; f(x,y) = x^2 / a^2 + y^2 / b^2 - 1 = 0
;; and the fact that we want the enlarged ellipse to have the
;; same proportions as the smaller square, therefore we have:
;; a/b = x/y
;; Solving this yields a-in-larger-ellipse = a-in-smaller * sqrt(2)
(x-radius (round (* width (sqrt 2))))
(y-radius (round (* height (sqrt 2))))
(x x1)
(y y1))
(if (and (= y1 y2) (not (= x1 x2)))
(artist-draw-ellipse-with-0-height x y x-radius y-radius)
(artist-draw-ellipse-general x y x-radius y-radius))))