Files
gimp/plug-ins/script-fu/scripts/round-corners.scm
Kevin Cozens 6239dddda3 With this commit we finally say goodbye to SIOD. This large set of changes
2006-10-15  Kevin Cozens  <kcozens@cvs.gnome.org>

	With this commit we finally say goodbye to SIOD. This large set of
	changes updates the Script-Fu plug-in to use the TinyScheme Scheme
	interpreter. These changes originated with changes originally made
	to Script-Fu which created Tiny-Fu (aka. the gimp-tiny-fu module).

	* plug-ins/script-fu/Makefile.am
	* plug-ins/script-fu/script-fu-console.c
	* plug-ins/script-fu/script-fu-interface.c
	* plug-ins/script-fu/script-fu-scripts.c
	* plug-ins/script-fu/script-fu-scripts.h
	* plug-ins/script-fu/script-fu-server.c
	* plug-ins/script-fu/script-fu-text-console.c
	* plug-ins/script-fu/script-fu.c: Updated with the changes made to
	these files as part of the work on the Tiny-Fu project.

	* plug-ins/script-fu/scheme-wrapper.c
	* plug-ins/script-fu/scheme-wrapper.h: Renamed from siod-wrapper.[ch]
	and updated based on differences to ts-wrapper.[ch] from gimp-tiny-fu.

	* plug-ins/script-fu/ftx/*
	* plug-ins/script-fu/re/*
	* plug-ins/script-fu/tinyscheme/*
	* plug-ins/script-fu/scripts/script-fu.init
	* plug-ins/script-fu/scripts/script-fu-compat.init
	* plug-ins/script-fu/scripts/contactsheet.scm
	* plug-ins/script-fu/scripts/script-fu-set-cmap.scm
	* plug-ins/script-fu/scripts/script-fu-util-setpt.scm
	* plug-ins/script-fu/scripts/ts-helloworld.scm: Added all of these
	files and directories from Tiny-Fu. Updated the Makefile.am files
	of ftx, re, and tinyscheme now they are in the GIMP source tree.

	* plug-ins/script-fu/scripts/*.scm: All scripts have been updated as
	needed to ensure they will work with the TinyScheme interpreter. Most
	of the files have been reformatted making it easier to see the syntax
	of Scheme and making them easier to read.

	* plug-ins/script-fu/scripts/Makefile.am: Updated script file lists.

	* plug-ins/script-fu/siod-wrapper.c
	* plug-ins/script-fu/siod-wrapper.h
	* plug-ins/script-fu/siod/*: Removed obsolete files.

	* configure.in: Updated list of files in AC_CONFIG_FILES. Changed
	--disable-script-fu to --without-script-fu which it should have
	been when originally added.

	* INSTALL: Updated to show change to --without-script-fu.
2006-10-16 01:08:54 +00:00

147 lines
5.4 KiB
Scheme

; 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
;
; CHANGE-LOG:
; 1.00 - initial release
; 1.01 - some code cleanup, no real changes
;
; Copyright (C) 1997-1999 Sven Neumann <sven@gimp.org>
;
;
; 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
; obsolete now.
(define (script-fu-round-corners img
drawable
radius
shadow-toggle
shadow-x
shadow-y
shadow-blur
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)
img)))
(pic-layer (car (gimp-image-get-active-drawable image))))
(if (= work-on-copy TRUE)
(gimp-image-undo-disable image)
(gimp-image-undo-group-start image)
)
(gimp-image-undo-disable image)
; 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 CHANNEL-OP-ADD 0 0)
(gimp-ellipse-select image 0 0 diam diam CHANNEL-OP-SUBTRACT TRUE 0 0)
(gimp-rect-select image (- width radius) 0 radius radius CHANNEL-OP-ADD 0 0)
(gimp-ellipse-select image (- width diam) 0 diam diam CHANNEL-OP-SUBTRACT TRUE 0 0)
(gimp-rect-select image 0 (- height radius) radius radius CHANNEL-OP-ADD 0 0)
(gimp-ellipse-select image 0 (- height diam) diam diam CHANNEL-OP-SUBTRACT TRUE 0 0)
(gimp-rect-select image (- width radius) (- height radius)
radius radius CHANNEL-OP-ADD 0 0)
(gimp-ellipse-select image (- width diam) (- height diam)
diam diam CHANNEL-OP-SUBTRACT TRUE 0 0)
(gimp-edit-clear pic-layer)
(gimp-selection-none image)
; optionally add a shadow
(if (= shadow-toggle TRUE)
(begin
(script-fu-drop-shadow image
pic-layer
shadow-x
shadow-y
shadow-blur
'(0 0 0)
80
TRUE)
(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)
(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
(if (= work-on-copy TRUE)
(gimp-image-undo-enable image)
(gimp-image-undo-group-end image)
)
(if (= work-on-copy TRUE)
(gimp-display-new image))
(gimp-displays-flush))
)
(script-fu-register "script-fu-round-corners"
_"_Round Corners..."
_"Round the corners of an image and optionally add a drop-shadow and background"
"Sven Neumann <sven@gimp.org>"
"Sven Neumann"
"1999/12/21"
"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
)
(script-fu-menu-register "script-fu-round-corners"
"<Image>/Filters/Decor")