;;;
;;; draw-circle.scm
;;;
;;;
;;;  Arch. Giuseppe Conte <http://space.tin.it/edicola/lwcon/>

;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 2 of the License, or
;;; (at your option) any later version.
;;; 
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;; 
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

;;; Richard McLean edits:
;;;
;;; 20.2.2017 Updated for GIMP V2.9.5
;;; 21.2.2017 Moved to Filters/Draw Circle
;;; 18.4.2021 Deprecated function gimp-edit-stroke changed to gimp-drawable-edit-stroke-selection
;;;
;;; Define the function:

(define (script-fu-draw-hollow-circle inImage inLayer cx cy Radius)
	(let* (
		(sx (- cx Radius))
		(sy (- cy Radius))
		(diameter (* Radius 2))
		(dx diameter)
		(dy diameter)	
		)
	
  (gimp-image-undo-group-start inImage)
  (gimp-context-push)

  (gimp-image-select-ellipse inImage CHANNEL-OP-REPLACE sx sy dx dy)
   
  (gimp-drawable-edit-stroke-selection inLayer)		    
  (gimp-selection-none inImage)

  (gimp-context-pop)
  (gimp-image-undo-group-end inImage)  

  (gimp-displays-flush)
  ) ;;let
) ;;def

(script-fu-register
 "script-fu-draw-hollow-circle"
 "Hollow circle"
 "Draw a hollow circle."
 "Arch. Giuseppe Conte"
 "2003, Giuseppe Conte"
 "13 Agosto 2003 - 72026 San Pancrazio Salentino (BR) - ITALY "
 "*"
 SF-IMAGE "The Image" 0
 SF-DRAWABLE "The Layer" 0
 SF-ADJUSTMENT "Center X" '(0 0 9999 1 10 0 1)
 SF-ADJUSTMENT "Center Y" '(0 0 9999 1 10 0 1)
 SF-ADJUSTMENT "Radius" '(0 0 9999 1 10 0 1)
)
(script-fu-menu-register "script-fu-draw-hollow-circle" "<Image>/Filters/Draw Circle/Draw Hollow Circle")
