1
; The GIMP -- an image manipulation program
2
; Copyright (C) 1995 Spencer Kimball and Peter Mattis
4
; This program is free software; you can redistribute it and/or modify
5
; it under the terms of the GNU General Public License as published by
6
; the Free Software Foundation; either version 2 of the License, or
7
; (at your option) any later version.
9
; This program is distributed in the hope that it will be useful,
10
; but WITHOUT ANY WARRANTY; without even the implied warranty of
11
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
; GNU General Public License for more details.
14
; You should have received a copy of the GNU General Public License
15
; along with this program; if not, write to the Free Software
16
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
; round-corners.scm version 1.02 1999/12/21
22
; 1.00 - initial release
23
; 1.01 - some code cleanup, no real changes
25
; Copyright (C) 1997-1999 Sven Neumann <sven@gimp.org>
28
; Rounds the corners of an image, optionally adding a drop-shadow and
31
; The script works on RGB and grayscale images that contain only
32
; one layer. It creates a copy of the image or can optionally work
33
; on the original. The script uses the current background color to
34
; create a background layer. It makes a call to the script drop-shadow.
36
; This script is derived from my script add-shadow, which has become
41
(define (script-fu-round-corners img
50
(let* ((shadow-blur (abs shadow-blur))
53
(width (car (gimp-image-width img)))
54
(height (car (gimp-image-height img)))
55
(type (car (gimp-drawable-type-with-alpha drawable)))
56
(image (cond ((= work-on-copy TRUE)
57
(car (gimp-image-duplicate img)))
58
((= work-on-copy FALSE)
60
(pic-layer (car (gimp-image-get-active-drawable image))))
62
(cond ((= work-on-copy TRUE)
63
(gimp-image-undo-disable image))
64
((= work-on-copy FALSE)
65
(gimp-image-undo-group-start image)))
67
; add an alpha channel to the image
68
(gimp-layer-add-alpha pic-layer)
71
(gimp-selection-none image)
72
(gimp-rect-select image 0 0 radius radius CHANNEL-OP-ADD 0 0)
73
(gimp-ellipse-select image 0 0 diam diam CHANNEL-OP-SUBTRACT TRUE 0 0)
74
(gimp-rect-select image (- width radius) 0 radius radius CHANNEL-OP-ADD 0 0)
75
(gimp-ellipse-select image (- width diam) 0 diam diam CHANNEL-OP-SUBTRACT TRUE 0 0)
76
(gimp-rect-select image 0 (- height radius) radius radius CHANNEL-OP-ADD 0 0)
77
(gimp-ellipse-select image 0 (- height diam) diam diam CHANNEL-OP-SUBTRACT TRUE 0 0)
78
(gimp-rect-select image (- width radius) (- height radius)
79
radius radius CHANNEL-OP-ADD 0 0)
80
(gimp-ellipse-select image (- width diam) (- height diam)
81
diam diam CHANNEL-OP-SUBTRACT TRUE 0 0)
82
(gimp-edit-clear pic-layer)
83
(gimp-selection-none image)
85
; optionally add a shadow
86
(if (= shadow-toggle TRUE)
88
(script-fu-drop-shadow image
96
(set! width (car (gimp-image-width image)))
97
(set! height (car (gimp-image-height image)))))
99
; optionally add a background
100
(if (= background-toggle TRUE)
101
(let* ((bg-layer (car (gimp-layer-new image
108
(gimp-drawable-fill bg-layer BACKGROUND-FILL)
109
(gimp-image-add-layer image bg-layer -1)
110
(gimp-image-raise-layer image pic-layer)
111
(if (= shadow-toggle TRUE)
112
(gimp-image-lower-layer image bg-layer))))
114
; clean up after the script
115
(cond ((= work-on-copy TRUE)
116
(gimp-image-undo-enable image))
117
((= work-on-copy FALSE)
118
(gimp-image-undo-group-end image)))
120
(if (= work-on-copy TRUE)
121
(gimp-display-new image))
122
(gimp-displays-flush)))
124
(script-fu-register "script-fu-round-corners"
126
"Round the corners of an image and optionally adds a drop-shadow and a background"
127
"Sven Neumann <sven@gimp.org>"
132
SF-DRAWABLE "Drawable" 0
133
SF-ADJUSTMENT _"Edge radius" '(15 0 4096 1 10 0 1)
134
SF-TOGGLE _"Add drop-shadow" TRUE
135
SF-ADJUSTMENT _"Shadow X offset" '(8 -4096 4096 1 10 0 1)
136
SF-ADJUSTMENT _"Shadow Y offset" '(8 -4096 4096 1 10 0 1)
137
SF-ADJUSTMENT _"Blur radius" '(15 0 1024 1 10 0 1)
138
SF-TOGGLE _"Add background" TRUE
139
SF-TOGGLE _"Work on copy" TRUE)
141
(script-fu-menu-register "script-fu-round-corners"
142
_"<Image>/Script-Fu/Decor")