; swirl button ; ; Original version ; Copyright (C) 2000 MARIN Laetitia ; ; Version 0.2 Raymond Ostertag 2004/09 ; - Ported to Gimp2 ; - Changed menu entry (define (create-oval-shape img sizeX sizeY) (let* ((corner-size (/ (if (< sizeX sizeY) sizeX sizeY) 5)) (offset 10) ;; rect selection size and offsets (r-size corner-size) (r-offset-x1 offset) (r-offset-x2 (- sizeX (+ offset r-size))) (r-offset-y1 offset) (r-offset-y2 (- sizeY (+ offset r-size))) ;; ellipse selection size and offsets (e-size (* 2 corner-size)) (e-offset-x1 offset) (e-offset-x2 (- sizeX (+ offset e-size))) (e-offset-y1 offset) (e-offset-y2 (- sizeY (+ offset e-size)))) (gimp-rect-select img offset offset (- sizeX (+ (* 2 offset) 1)) (- sizeY (+ (* 2 offset) 1)) CHANNEL-OP-REPLACE FALSE 0) ;; erase corners (gimp-rect-select img r-offset-x1 r-offset-y1 r-size r-size CHANNEL-OP-SUBTRACT FALSE 0) (gimp-rect-select img r-offset-x1 r-offset-y2 r-size r-size CHANNEL-OP-SUBTRACT FALSE 0) (gimp-rect-select img r-offset-x2 r-offset-y2 r-size r-size CHANNEL-OP-SUBTRACT FALSE 0) (gimp-rect-select img r-offset-x2 r-offset-y1 r-size r-size CHANNEL-OP-SUBTRACT FALSE 0) ;; add round corners (gimp-ellipse-select img e-offset-x1 e-offset-y1 e-size e-size CHANNEL-OP-ADD TRUE 0 0) (gimp-ellipse-select img e-offset-x1 e-offset-y2 e-size e-size CHANNEL-OP-ADD TRUE 0 0) (gimp-ellipse-select img e-offset-x2 e-offset-y2 e-size e-size CHANNEL-OP-ADD TRUE 0 0) (gimp-ellipse-select img e-offset-x2 e-offset-y1 e-size e-size CHANNEL-OP-ADD TRUE 0 0))) (define (script-fu-swirl size) (let* ((old-bg-color (car (gimp-palette-get-background))) (old-fg-color (car (gimp-palette-get-foreground))) (sizeX size) (sizeY size) (img (car (gimp-image-new sizeX sizeY RGB))) (background (car (gimp-layer-new img sizeX sizeY RGBA-IMAGE "background" 100 NORMAL-MODE))) (shape (car (gimp-layer-new img sizeX sizeY RGBA-IMAGE "Shape" 100 NORMAL-MODE))) (motif (car (gimp-layer-new img sizeX sizeY RGBA-IMAGE "motif" 100 DARKEN-ONLY-MODE)))) (gimp-image-undo-disable img) ;; add layers (gimp-image-add-layer img background 0) (gimp-image-add-layer img shape 0) (gimp-image-add-layer img motif 0) ;; Init layers back colors (gimp-edit-clear motif) (gimp-edit-clear shape) ;; fill white (gimp-palette-set-foreground '(255 255 255)) (gimp-edit-fill background FOREGROUND-FILL) ;; fill black, grid and whirl (gimp-palette-set-foreground '(0 0 0)) (gimp-edit-fill motif FOREGROUND-FILL) (plug-in-grid TRUE img motif 1 8 0 '(255 255 255) 255 1 8 0 '(255 255 255) 255 0 2 6 '(255 255 255) 255) (plug-in-whirl-pinch TRUE img motif 0 1 1) ;; fill seam plasma (plug-in-plasma TRUE img shape 982422720 1) (plug-in-make-seamless TRUE img shape) ;; Create shape (create-oval-shape img sizeX sizeY) (gimp-selection-invert img) (gimp-edit-clear motif) (gimp-edit-clear shape) (gimp-selection-none img) (gimp-drawable-set-visible background FALSE) (let ((merged_layer (car (gimp-image-merge-visible-layers img CLIP-TO-IMAGE)))) (plug-in-bump-map TRUE img merged_layer merged_layer 135 45 3 0 0 0 0 TRUE FALSE GRADIENT-LINEAR)) (gimp-drawable-set-visible background TRUE) (gimp-palette-set-foreground old-fg-color) (gimp-palette-set-background old-bg-color) (gimp-image-undo-enable img) (gimp-display-new img))) (script-fu-register "script-fu-swirl" "/Xtns/Script-Fu/Render/Swirl..." "swirl button" "MARIN Laetitia" "MARIN Laetitia" "Fev 2000" "" SF-VALUE "Size " "256")