Function: artist-draw-circle
artist-draw-circle is a byte-compiled function defined in
artist.el.gz.
Signature
(artist-draw-circle X1 Y1 X2 Y2)
Documentation
Draw a circle 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-circle (x1 y1 x2 y2)
"Draw a circle 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 drawing our circle, we want it to through the cursor
;; just as when drawing the ellipse, but we have to take
;; care for the aspect-ratio.
;; 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
;; together with the relationship
;; a = aspect-ratio * b
;; gives
;; a = sqrt( x^2 + (aspect-ratio * y)^2 ) and
;; b = a / aspect-ratio
(x-radius (round (sqrt (+ (* width width)
(* (* artist-aspect-ratio height)
(* artist-aspect-ratio height))))))
(y-radius (round (/ x-radius artist-aspect-ratio))))
(artist-draw-ellipse-general x1 y1 x-radius y-radius)))