; 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. ; ; Copyright (C) 2004 Kevin Payne paynekj@hotmail.com ; ; Version 0.1 14.04.2004 First Go ; A debug routine to place some text into the image (define (place_comment img adraw xpos ypos text) (set! text-float (car (gimp-text-fontname img adraw xpos ypos text 0 1 20 0 "-*-*courier*-*-r-*-*-*-*-*-*-*-*-*-*"))) (gimp-floating-sel-anchor text-float) ) ; this is the main routine (define (script-fu-grad_kp aimg adraw colour grad_rev) (let* ( (rval (/ (* 1.0 (car colour)) 255.0)) (gval (/ (* 1.0 (car (cdr colour))) 255.0)) (bval (/ (* 1.0 (car (cdr (cdr colour)))) 255.0)) (old-bg-colour (car (gimp-palette-get-background))) (old-fg-colour (car (gimp-palette-get-foreground))) (old-gradient (car (gimp-gradients-get-gradient))) (height (car (gimp-drawable-height adraw))) ) (gimp-image-undo-group-start aimg) ; (place_comment img adraw 10 40 "got here") ; Create a duplicate of the original layer and re-name it (set! new-layer (car (gimp-layer-copy adraw TRUE))) (gimp-image-add-layer aimg new-layer 0) (gimp-drawable-set-name new-layer "Filtered layer") ; (place_comment img adraw 10 40 (number->string rval 10)) ; (place_comment img adraw 10 80 (number->string gval 10)) ; (place_comment img adraw 10 120 (number->string bval 10)) ; filter the colours of the new layer (plug-in-colors-channel-mixer 1 aimg new-layer FALSE rval 0 0 0 gval 0 0 0 bval) ; create a layer mask (set! l-mask (car (gimp-layer-create-mask new-layer 0))) (gimp-layer-add-mask new-layer l-mask) ; set the foreground and background colours to their default values of black and white (gimp-palette-set-default-colors) ; apply a gradient to the layer mask (gimp-gradients-set-gradient "FG to BG (RGB)") (gimp-edit-blend l-mask 0 0 0 100.0 0.0 0 grad_rev FALSE 0 0.0 TRUE 0 0 0 height) ; reset the foreground and background colours and the gradient (gimp-palette-set-foreground old-fg-colour) (gimp-palette-set-background old-bg-colour) (gimp-gradients-set-gradient old-gradient) ; flush the image (gimp-displays-flush) (gimp-image-undo-group-end aimg) ) ) (script-fu-register "script-fu-grad_kp" _"/Script-Fu/Kevin/Grad Filter..." "Add a graduated filter of an image" "Kevin Payne " "Kevin Payne" "14/04/2004" "RGB*" SF-IMAGE "Input Image" 0 SF-DRAWABLE "Input Drawable" 0 SF-COLOR _"Filter Colour" '(255 204 153) SF-TOGGLE _"Gradient Reverse" TRUE )