;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
pro drawcircle, ima_in, x_cntr, y_cntr, radius, ptyp, psiz, color
;; Draw a circle of given radius and given center on a frame
;; Created by M.B on 31/01/94 : LAS  v1.0
;; Modified by M.B on 17/02/94 : LAS
;; inputs :
;;         ima_in           image that receives the picture
;;         x_cntr, y_cntr   center coordinates of the drawn circle
;;         radius           radius of the drawn circle
;;         ptyp             selected drawn points (0 --> 9)
;;         psiz             heigth of the drawn points (scale*1.)
;;         color            color of the drawn points (0(black) --> 255(white))
;; outputs :
;;         on the selected window, the picture appears
;------------------------------------------------------------------------------
;
xcntr = round1(x_cntr)
ycntr = round1(y_cntr)
radius = round1(radius)
;
xstart = xcntr - radius
ystart = ycntr - radius
if xstart < 0 then xstart = 0
if ystart < 0 then ystart = 0
xend = xstart + radius
yend = ystart + radius
if xend > 512 then xend = 511
if yend > 512 then yend = 511
;
j = 0.
radius = float(radius)
for j=ystart+1,yend-1 do begin $
  yc = float(ycntr - j)
  xc = sqrt(radius*radius - yc*yc)
  i1 = FIX(xcntr - round1(xc)*1.)
  i2 = FIX(xcntr + round1(xc)*1.)
  j1 = FIX(j + 2.*yc)
;
plots,[i1,i1+1],[j,j+1],color=color,/device,/continue,psym=ptyp,symsize=psiz
plots,[i2,i2+1],[j,j+1],color=color,/device,/continue,psym=ptyp,symsize=psiz
plots,[i1,i1+1],[j1,j1+1],color=color,/device,/continue,psym=ptyp,symsize=psiz
plots,[i2,i2+1],[j1,j1+1],color=color,/device,/continue,psym=ptyp,symsize=psiz
endfor
;
i = 0.
for i = xstart+1,xend-1 do begin $
  xc = float(xcntr - i)
  yc = sqrt(radius*radius - xc*xc)
  j1 = FIX(ycntr - round1(yc)*1.)
  j2 = FIX(ycntr + round1(yc)*1.)
  i1 = FIX(i + 2.*xc)
;
plots,[i,i+1],[j1,j1+1],color=color,/device,/continue,psym=ptyp,symsize=psiz
plots,[i,i+1],[j2,j2+1],color=color,/device,/continue,psym=ptyp,symsize=psiz
plots,[i1,i+1],[j1,j1+1],color=color,/device,/continue,psym=ptyp,symsize=psiz
plots,[i1,i+1],[j2,j2+1],color=color,/device,/continue,psym=ptyp,symsize=psiz
endfor
;
return
end
