; ; Un script pour dessiner une horloge à aiguille ; (define (script-fu-horloge-analogique rayon heure minutes) (let* ( ; define our local vars (pi 3.14159265359) ; (rayon 200) (petit (* 0.15 rayon)) (grand (* 1.5 petit)) (rpetit petit) (rgrand petit) (lgrand (- rayon grand)) (lpetit (* 0.5 lgrand)) (taille (+ (* 0.1 rayon) grand (* 2 rayon))) (theImage (car (gimp-image-new taille taille RGB) ) ) (cadran (car (gimp-layer-new theImage taille taille RGBA_IMAGE "cadran" 100 NORMAL) )) (grande-aiguille (car (gimp-layer-new theImage taille taille RGBA_IMAGE "grande_aiguille" 100 NORMAL) )) (petite-aiguille (car (gimp-layer-new theImage taille taille RGBA_IMAGE "petite_aiguille" 100 NORMAL) )) ) (gimp-image-add-layer theImage cadran 0) (gimp-image-add-layer theImage grande-aiguille 1) (gimp-image-add-layer theImage petite-aiguille 2) (gimp-selection-all theImage) (gimp-edit-clear cadran) (gimp-edit-clear grande-aiguille) (gimp-edit-clear petite-aiguille) (gimp-selection-none theImage) ; Les ronds (gimp-palette-set-foreground '(255 255 255)) (set! index 0) (while (< index 12) (set! angle (* (/ (* 2 pi) 12) index)) (set! x (+ (/ taille 2) (* rayon (cos angle)))) (set! y (+ (/ taille 2) (* rayon (sin angle)))) (cond ((or (= index 0) (= index 3) (= index 6) (= index 9)) (set! rond grand)) (TRUE (set! rond petit)) ) (gimp-ellipse-select theImage (- x (/ rond 2)) (- y (/ rond 2)) rond rond ADD TRUE 0 0) (set! index (+ index 1)) ) (gimp-edit-fill cadran 0) (gimp-selection-none theImage) ; petite aiguille (set! x (- (/ taille 2) (/ rpetit 2))) (set! y x) (set! y1 (- y lpetit)) (set! y2 (+ y1 (/ rpetit 2))) (gimp-ellipse-select theImage x y rpetit rpetit ADD TRUE 0 0) (gimp-ellipse-select theImage x y1 rpetit rpetit ADD TRUE 0 0) (gimp-rect-select theImage x y2 rpetit lpetit ADD 0 0) (gimp-edit-fill petite-aiguille 0) (gimp-selection-none theImage) (gimp-rotate petite-aiguille TRUE (* (/ pi 6) (+ heure (/ minutes 60))) ) ; grande aiguille (set! x (- (/ taille 2) (/ rgrand 2))) (set! y x) (set! y1 (- y lgrand)) (set! y2 (+ y1 (/ rgrand 2))) (gimp-ellipse-select theImage x y rgrand rgrand ADD TRUE 0 0) (gimp-ellipse-select theImage x y1 rgrand rgrand ADD TRUE 0 0) (gimp-rect-select theImage x y2 rgrand lgrand ADD 0 0) (gimp-edit-fill grande-aiguille 0) (gimp-selection-none theImage) (gimp-rotate grande-aiguille TRUE (* (/ pi 30) minutes)) (gimp-display-new theImage) (gimp-selection-none theImage) (gimp-image-clean-all theImage) )) ; Register the function with the GIMP: (script-fu-register "script-fu-horloge-analogique" "/Xtns/Script-Fu/Misc/Horloge Analogique..." "Dessine une horloge à aiguilles" "Jean-Sebastien Roy" "2002, Jean-Sebastien Roy (js@jeannot.org)" "10 mai 2002" "" SF-VALUE "Rayon:" "200" SF-VALUE "Heure:" "7" SF-VALUE "Minutes:" "20" )