gimp/plug-ins/script-fu/scripts/round-corners.scm

133 lines
4.3 KiB
Scheme
Raw Normal View History

1997-11-25 06:05:25 +08:00
; The GIMP -- an image manipulation program
; Copyright (C) 1995 Spencer Kimball and Peter Mattis
;
; 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.
;
;
; round-corners.scm version 1.02 1999/12/21
1998-02-17 22:27:46 +08:00
;
; CHANGE-LOG:
; 1.00 - initial release
; 1.01 - some code cleanup, no real changes
1997-11-25 06:05:25 +08:00
;
; Copyright (C) 1997-1999 Sven Neumann <sven@gimp.org>
1997-11-25 06:05:25 +08:00
;
;
; Rounds the corners of an image, optionally adding a drop-shadow and
; a background layer
;
; The script works on RGB and grayscale images that contain only
; one layer. It creates a copy of the image or can optionally work
; on the original. The script uses the current background color to
; create a background layer. It makes a call to the script drop-shadow.
;
; This script is derived from my script add-shadow, which has become
; obsolet now.
(define (script-fu-round-corners img
drawable
1997-11-25 06:05:25 +08:00
radius
shadow-toggle
shadow-x
shadow-y
shadow-blur
1997-11-25 06:05:25 +08:00
background-toggle
work-on-copy)
(let* ((shadow-blur (abs shadow-blur))
(radius (abs radius))
(diam (* 2 radius))
(width (car (gimp-image-width img)))
(height (car (gimp-image-height img)))
(type (car (gimp-drawable-type-with-alpha drawable)))
(image (cond ((= work-on-copy TRUE)
(car (gimp-image-duplicate img)))
((= work-on-copy FALSE)
1998-02-17 22:27:46 +08:00
img)))
(pic-layer (car (gimp-image-get-active-drawable image))))
1997-11-25 06:05:25 +08:00
1999-10-17 08:07:55 +08:00
(gimp-image-undo-disable image)
1997-11-25 06:05:25 +08:00
; add an alpha channel to the image
(gimp-layer-add-alpha pic-layer)
; round the edges
(gimp-selection-none image)
(gimp-rect-select image 0 0 radius radius ADD 0 0)
(gimp-ellipse-select image 0 0 diam diam SUB TRUE 0 0)
(gimp-rect-select image (- width radius) 0 radius radius ADD 0 0)
(gimp-ellipse-select image (- width diam) 0 diam diam SUB TRUE 0 0)
(gimp-rect-select image 0 (- height radius) radius radius ADD 0 0)
(gimp-ellipse-select image 0 (- height diam) diam diam SUB TRUE 0 0)
(gimp-rect-select image (- width radius) (- height radius)
1997-11-25 06:05:25 +08:00
radius radius ADD 0 0)
(gimp-ellipse-select image (- width diam) (- height diam)
1997-11-25 06:05:25 +08:00
diam diam SUB TRUE 0 0)
(gimp-edit-clear pic-layer)
1997-11-25 06:05:25 +08:00
(gimp-selection-none image)
; optionally add a shadow
(if (= shadow-toggle TRUE)
(begin
(script-fu-drop-shadow image
pic-layer
shadow-x
1997-11-25 06:05:25 +08:00
shadow-y
shadow-blur
'(0 0 0)
80
TRUE)
1997-11-25 06:05:25 +08:00
(set! width (car (gimp-image-width image)))
(set! height (car (gimp-image-height image)))))
; optionally add a background
(if (= background-toggle TRUE)
(let* ((bg-layer (car (gimp-layer-new image
width
height
type
"Background"
100
NORMAL-MODE))))
(gimp-drawable-fill bg-layer BACKGROUND-FILL)
1997-11-25 06:05:25 +08:00
(gimp-image-add-layer image bg-layer -1)
(gimp-image-raise-layer image pic-layer)
(if (= shadow-toggle TRUE)
(gimp-image-lower-layer image bg-layer))))
; clean up after the script
1999-10-17 08:07:55 +08:00
(gimp-image-undo-enable image)
(if (= work-on-copy TRUE)
(gimp-display-new image))
1997-11-25 06:05:25 +08:00
(gimp-displays-flush)))
(script-fu-register "script-fu-round-corners"
removed function gimp_menu_path_strip_uline() ... 2003-08-09 Henrik Brix Andersen <brix@gimp.org> * gimp/app/widgets/gimpwidgets-utils.[ch]: removed function gimp_menu_path_strip_uline() ... * gimp/libgimpbase/gimputils.[ch]: ... and added it here under the name gimp_strip_uline() * gimp/devel-docs/libgimpbase/libgimpbase-sections.txt: added gimp_strip_uline to gimputils section * gimp/app/plug-in/plug-in.c * gimp/app/widgets/gimpitemfactory.c * gimp/app/widgets/gimptoolbox. * gimp/app/gui/plug-in-menus.c: changed accordingly * gimp/plug-ins/script-fu/script-fu-scripts.c (script_fu_interface): use gimp_strip_uline() to strip mnemonics from script-fu menu paths * gimp/app/gui/vectors-menu.c * gimp/app/gui/templates-menu.c * gimp/app/gui/qmask-menu.c * gimp/app/gui/palettes-menu.c * gimp/app/gui/palette-editor-menu.c * gimp/app/gui/images-menu.c * gimp/app/gui/gradients-menu.c * gimp/app/gui/gradient-editor-menu.c * gimp/app/gui/documents-menu.c * gimp/app/gui/dialogs-menu.c * gimp/app/gui/colormap-editor-menu.c * gimp/app/gui/channels-menu.c * gimp/app/gui/buffers-menu.c * gimp/app/gui/brushes-menu.c * gimp/app/gui/layers-menu.c * gimp/plug-ins/pygimp/plug-ins/clothify.py * gimp/plug-ins/pygimp/plug-ins/shadow_bevel.py * gimp/plug-ins/pygimp/plug-ins/whirlpinch.py * gimp/plug-ins/pygimp/plug-ins/foggify.py * gimp/plug-ins/script-fu/scripts/*.scm * gimp/plug-ins/script-fu/script-fu.c: added mnemonics fixing more of bug #106991 * gimp/app/gui/error-console-menu.c (error_console_menu_update): updated menu item names, added mnemonics * gimp/plug-ins/common/animoptimize.c * gimp/plug-ins/common/animationplay.c: don't prepend every menu entry with "Animation"
2003-08-12 01:14:32 +08:00
_"<Image>/Script-Fu/Decor/_Round Corners..."
1997-11-25 06:05:25 +08:00
"Round the corners of an image and optionally adds a drop-shadow and a background"
"Sven Neumann <sven@gimp.org>"
1997-11-25 06:05:25 +08:00
"Sven Neumann"
"1999/12/21"
1997-11-25 06:05:25 +08:00
"RGB GRAY"
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
SF-ADJUSTMENT _"Edge Radius" '(15 0 4096 1 10 0 1)
SF-TOGGLE _"Add Drop-Shadow" TRUE
SF-ADJUSTMENT _"Shadow X Offset" '(8 -4096 4096 1 10 0 1)
SF-ADJUSTMENT _"Shadow Y Offset" '(8 -4096 4096 1 10 0 1)
SF-ADJUSTMENT _"Blur Radius" '(15 0 1024 1 10 0 1)
SF-TOGGLE _"Add Background" TRUE
SF-TOGGLE _"Work on Copy" TRUE)