; 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. ; ; triangle.scm: ; A super-simple script for GIMP to convert a rectangular selection to ; a triangle. The triangle always points to the right - you can ; rotate it yourself. ; ; Copy it to your $HOME/.gimp-1.2/scripts directory. ; ; Copyright (C) 2002 Gert Lombard - gert at codeblast dot com (define (script-fu-sel-triangle image drawable) (set! selection-bounds (gimp-selection-bounds image)) (set! sel-x1 (cadr selection-bounds)) (set! sel-y1 (caddr selection-bounds)) (set! sel-x2 (cadr (cddr selection-bounds))) (set! sel-y2 (caddr (cddr selection-bounds))) (set! sel-width (- sel-x2 sel-x1)) (set! sel-height (- sel-y2 sel-y1)) (set! antialias TRUE) ; Find the vertical middle of rectangle: (set! sel-ym (+ sel-y1 (/ sel-height 2))) (gimp-undo-push-group-start image) (set! points (cons-array 6 'double)) (aset points 0 sel-x1) (aset points 1 sel-y1) (aset points 2 sel-x2) (aset points 3 sel-ym) (aset points 4 sel-x1) (aset points 5 sel-y2) (gimp-free-select image 6 points REPLACE antialias FALSE 0) (gimp-undo-push-group-end image) (gimp-displays-flush) ) (script-fu-register "script-fu-sel-triangle" "/Script-Fu/Selection/Triangle" "Changes a rectangular section to a triangle" "Gert Lombard" "Copyright 2002 Gert Lombard" "July 30, 2002" "" SF-IMAGE "Image" 0 SF-DRAWABLE "Drawable" 0 )