gimp/plug-ins/script-fu/scripts/addborder.scm

183 lines
5.4 KiB
Scheme
Raw Normal View History

1997-11-24 22:05:25 +00: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.
;
; Copyright (C) 1997 Andy Thomas alt@picnic.demon.co.uk
;
; Version 0.2 10.6.97 Changed to new script-fu interface in 0.99.10
; Delta the colour by the given amount. Check for boundary conditions
; If < 0 set to zero
; If > 255 set to 255
; Return the new value
(define (deltacolour col delta)
(let* ((newcol (+ col delta)))
(if (< newcol 0) (set! newcol 0))
(if (> newcol 255) (set! newcol 255))
newcol)
)
(define (adjcolour col delta)
(mapcar (lambda (x) (deltacolour x delta)) col)
)
(define (gen_top_array xsize ysize owidth oheight width height)
(let* ((n_array (cons-array 10 'double)))
(aset n_array 0 0 )
(aset n_array 1 0 )
(aset n_array 2 xsize)
(aset n_array 3 ysize)
(aset n_array 4 (+ xsize owidth))
(aset n_array 5 ysize)
(aset n_array 6 width)
(aset n_array 7 0 )
(aset n_array 8 0 )
(aset n_array 9 0 )
n_array)
)
(define (gen_left_array xsize ysize owidth oheight width height)
(let* ((n_array (cons-array 10 'double)))
(aset n_array 0 0 )
(aset n_array 1 0 )
(aset n_array 2 xsize)
(aset n_array 3 ysize)
(aset n_array 4 xsize)
(aset n_array 5 (+ ysize oheight))
(aset n_array 6 0 )
(aset n_array 7 height )
(aset n_array 8 0 )
(aset n_array 9 0 )
n_array)
)
(define (gen_right_array xsize ysize owidth oheight width height)
(let* ((n_array (cons-array 10 'double)))
(aset n_array 0 width )
(aset n_array 1 0 )
(aset n_array 2 (+ xsize owidth))
(aset n_array 3 ysize)
(aset n_array 4 (+ xsize owidth))
(aset n_array 5 (+ ysize oheight))
(aset n_array 6 width)
(aset n_array 7 height)
(aset n_array 8 width )
(aset n_array 9 0 )
n_array)
)
(define (gen_bottom_array xsize ysize owidth oheight width height)
(let* ((n_array (cons-array 10 'double)))
(aset n_array 0 0 )
(aset n_array 1 height)
(aset n_array 2 xsize)
(aset n_array 3 (+ ysize oheight))
(aset n_array 4 (+ xsize owidth))
(aset n_array 5 (+ ysize oheight))
(aset n_array 6 width)
(aset n_array 7 height)
(aset n_array 8 0 )
(aset n_array 9 height)
n_array)
)
(define (script-fu-addborder aimg adraw xsize ysize colour dvalue)
renamed gimp_drawable_image() to gimp_drawable_get_image() for symmetry 2003-12-04 Michael Natterer <mitch@gimp.org> * tools/pdbgen/pdb/drawable.pdb: renamed gimp_drawable_image() to gimp_drawable_get_image() for symmetry with gimp_drawable_set_image(). * libgimp/gimpchannel.h: removed gimp_channel_get_image_id #define. * libgimp/gimpdrawable.h: removed gimp_drawable_image_id #define. * libgimp/gimplayer.h:: removed gimp_layer_get_image_id #define. * libgimp/gimpcompat.h: added the old stuff here. * app/pdb/drawable_cmds.c * libgimp/gimpdrawable_pdb.[ch]: regenerated. * libgimp/gimpmiscui.c * plug-ins/Lighting/lighting_main.c * plug-ins/MapObject/mapobject_main.c * plug-ins/common/curve_bend.c * plug-ins/common/film.c * plug-ins/common/newsprint.c * plug-ins/common/pixelize.c * plug-ins/common/ps.c * plug-ins/common/sample_colorize.c * plug-ins/common/smooth_palette.c * plug-ins/common/warp.c * plug-ins/imagemap/imap_cmd_gimp_guides.c * plug-ins/imagemap/imap_main.c * plug-ins/imagemap/imap_preview.c * plug-ins/maze/maze.c * plug-ins/pygimp/pygimp-drawable.c * plug-ins/rcm/rcm_misc.c * plug-ins/script-fu/scripts/addborder.scm * plug-ins/script-fu/scripts/carve-it.scm * plug-ins/script-fu/scripts/weave.scm: changed accordingly. * plug-ins/maze/maze.c: completely reindented. * plug-ins/script-fu/siod/trace.c: removed trailing whitespace. 2003-12-04 Michael Natterer <mitch@gimp.org> * libgimp/libgimp-sections.txt * libgimp/tmpl/gimpchannel.sgml * libgimp/tmpl/gimpdrawable.sgml * libgimp/tmpl/gimplayer.sgml: updated after gimp_drawable_get_image() cleanup.
2003-12-04 13:21:27 +00:00
(let* ((img (car (gimp-drawable-get-image adraw)))
1997-11-24 22:05:25 +00:00
(owidth (car (gimp-image-width img)))
(oheight (car (gimp-image-height img)))
(width (+ owidth (* 2 xsize)))
(height (+ oheight (* 2 ysize)))
(layer (car (gimp-layer-new img
width height
(car (gimp-drawable-type-with-alpha adraw))
"Border-Layer" 100 NORMAL-MODE))))
1997-11-24 22:05:25 +00:00
;Add this for debugging (verbose 4)
(gimp-context-push)
(gimp-image-undo-group-start img)
(gimp-drawable-fill layer TRANSPARENT-FILL)
(gimp-image-add-layer img layer 0)
(gimp-image-resize img
width
1997-11-24 22:05:25 +00:00
height
xsize
ysize)
tools/pdbgen/Makefile.am tools/pdbgen/groups.pl removed the "Palette" pdb 2004-09-22 Michael Natterer <mitch@gimp.org> * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/palette.pdb: removed the "Palette" pdb group... * tools/pdbgen/pdb/context.pdb: and added its functions to the "Context" namespace instead. * app/pdb/Makefile.am * app/pdb/palette_cmds.c: removed. * app/pdb/procedural_db.c: added them to the pdb_compat hash table. * libgimp/Makefile.am * libgimp/gimppalette_pdb.[ch]: removed. * libgimp/gimppalette.[ch]: new files holding compat functions which call gimp_context_*() functions. * libgimp/gimp.h * libgimp/gimpui.c: changed accordingly. * app/pdb/context_cmds.c * app/pdb/internal_procs.c * libgimp/gimp_pdb.h * libgimp/gimpcontext_pdb.[ch]: regenerated. * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_preview.c * plug-ins/common/apply_lens.c * plug-ins/common/blinds.c * plug-ins/common/borderaverage.c * plug-ins/common/checkerboard.c * plug-ins/common/colortoalpha.c * plug-ins/common/cubism.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/gif.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/mblur.c * plug-ins/common/mng.c * plug-ins/common/mosaic.c * plug-ins/common/papertile.c * plug-ins/common/png.c * plug-ins/common/polar.c * plug-ins/common/semiflatten.c * plug-ins/common/sinus.c * plug-ins/common/sparkle.c * plug-ins/common/vpropagate.c * plug-ins/common/warp.c * plug-ins/common/whirlpinch.c * plug-ins/gfig/gfig-style.c * plug-ins/gfli/gfli.c * plug-ins/ifscompose/ifscompose.c * plug-ins/maze/handy.c * plug-ins/pagecurl/pagecurl.c * plug-ins/pygimp/gimpmodule.c * plug-ins/script-fu/scripts/*.scm: changed accordingly.
2004-09-22 18:43:09 +00:00
(gimp-context-set-background (adjcolour colour dvalue))
1997-11-24 22:05:25 +00:00
(gimp-free-select img
10
(gen_top_array xsize ysize owidth oheight width height)
CHANNEL-OP-REPLACE
1997-11-24 22:05:25 +00:00
0
0
0.0)
(gimp-edit-fill layer BACKGROUND-FILL)
tools/pdbgen/Makefile.am tools/pdbgen/groups.pl removed the "Palette" pdb 2004-09-22 Michael Natterer <mitch@gimp.org> * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/palette.pdb: removed the "Palette" pdb group... * tools/pdbgen/pdb/context.pdb: and added its functions to the "Context" namespace instead. * app/pdb/Makefile.am * app/pdb/palette_cmds.c: removed. * app/pdb/procedural_db.c: added them to the pdb_compat hash table. * libgimp/Makefile.am * libgimp/gimppalette_pdb.[ch]: removed. * libgimp/gimppalette.[ch]: new files holding compat functions which call gimp_context_*() functions. * libgimp/gimp.h * libgimp/gimpui.c: changed accordingly. * app/pdb/context_cmds.c * app/pdb/internal_procs.c * libgimp/gimp_pdb.h * libgimp/gimpcontext_pdb.[ch]: regenerated. * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_preview.c * plug-ins/common/apply_lens.c * plug-ins/common/blinds.c * plug-ins/common/borderaverage.c * plug-ins/common/checkerboard.c * plug-ins/common/colortoalpha.c * plug-ins/common/cubism.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/gif.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/mblur.c * plug-ins/common/mng.c * plug-ins/common/mosaic.c * plug-ins/common/papertile.c * plug-ins/common/png.c * plug-ins/common/polar.c * plug-ins/common/semiflatten.c * plug-ins/common/sinus.c * plug-ins/common/sparkle.c * plug-ins/common/vpropagate.c * plug-ins/common/warp.c * plug-ins/common/whirlpinch.c * plug-ins/gfig/gfig-style.c * plug-ins/gfli/gfli.c * plug-ins/ifscompose/ifscompose.c * plug-ins/maze/handy.c * plug-ins/pagecurl/pagecurl.c * plug-ins/pygimp/gimpmodule.c * plug-ins/script-fu/scripts/*.scm: changed accordingly.
2004-09-22 18:43:09 +00:00
(gimp-context-set-background (adjcolour colour (/ dvalue 2)))
1997-11-24 22:05:25 +00:00
(gimp-free-select img
10
(gen_left_array xsize ysize owidth oheight width height)
CHANNEL-OP-REPLACE
1997-11-24 22:05:25 +00:00
0
0
0.0)
(gimp-edit-fill layer BACKGROUND-FILL)
tools/pdbgen/Makefile.am tools/pdbgen/groups.pl removed the "Palette" pdb 2004-09-22 Michael Natterer <mitch@gimp.org> * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/palette.pdb: removed the "Palette" pdb group... * tools/pdbgen/pdb/context.pdb: and added its functions to the "Context" namespace instead. * app/pdb/Makefile.am * app/pdb/palette_cmds.c: removed. * app/pdb/procedural_db.c: added them to the pdb_compat hash table. * libgimp/Makefile.am * libgimp/gimppalette_pdb.[ch]: removed. * libgimp/gimppalette.[ch]: new files holding compat functions which call gimp_context_*() functions. * libgimp/gimp.h * libgimp/gimpui.c: changed accordingly. * app/pdb/context_cmds.c * app/pdb/internal_procs.c * libgimp/gimp_pdb.h * libgimp/gimpcontext_pdb.[ch]: regenerated. * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_preview.c * plug-ins/common/apply_lens.c * plug-ins/common/blinds.c * plug-ins/common/borderaverage.c * plug-ins/common/checkerboard.c * plug-ins/common/colortoalpha.c * plug-ins/common/cubism.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/gif.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/mblur.c * plug-ins/common/mng.c * plug-ins/common/mosaic.c * plug-ins/common/papertile.c * plug-ins/common/png.c * plug-ins/common/polar.c * plug-ins/common/semiflatten.c * plug-ins/common/sinus.c * plug-ins/common/sparkle.c * plug-ins/common/vpropagate.c * plug-ins/common/warp.c * plug-ins/common/whirlpinch.c * plug-ins/gfig/gfig-style.c * plug-ins/gfli/gfli.c * plug-ins/ifscompose/ifscompose.c * plug-ins/maze/handy.c * plug-ins/pagecurl/pagecurl.c * plug-ins/pygimp/gimpmodule.c * plug-ins/script-fu/scripts/*.scm: changed accordingly.
2004-09-22 18:43:09 +00:00
(gimp-context-set-background (adjcolour colour (- 0 (/ dvalue 2))))
1997-11-24 22:05:25 +00:00
(gimp-free-select img
10
(gen_right_array xsize ysize owidth oheight width height)
CHANNEL-OP-REPLACE
1997-11-24 22:05:25 +00:00
0
0
0.0)
(gimp-edit-fill layer BACKGROUND-FILL)
tools/pdbgen/Makefile.am tools/pdbgen/groups.pl removed the "Palette" pdb 2004-09-22 Michael Natterer <mitch@gimp.org> * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl * tools/pdbgen/pdb/palette.pdb: removed the "Palette" pdb group... * tools/pdbgen/pdb/context.pdb: and added its functions to the "Context" namespace instead. * app/pdb/Makefile.am * app/pdb/palette_cmds.c: removed. * app/pdb/procedural_db.c: added them to the pdb_compat hash table. * libgimp/Makefile.am * libgimp/gimppalette_pdb.[ch]: removed. * libgimp/gimppalette.[ch]: new files holding compat functions which call gimp_context_*() functions. * libgimp/gimp.h * libgimp/gimpui.c: changed accordingly. * app/pdb/context_cmds.c * app/pdb/internal_procs.c * libgimp/gimp_pdb.h * libgimp/gimpcontext_pdb.[ch]: regenerated. * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_preview.c * plug-ins/common/apply_lens.c * plug-ins/common/blinds.c * plug-ins/common/borderaverage.c * plug-ins/common/checkerboard.c * plug-ins/common/colortoalpha.c * plug-ins/common/cubism.c * plug-ins/common/exchange.c * plug-ins/common/film.c * plug-ins/common/gif.c * plug-ins/common/grid.c * plug-ins/common/mapcolor.c * plug-ins/common/mblur.c * plug-ins/common/mng.c * plug-ins/common/mosaic.c * plug-ins/common/papertile.c * plug-ins/common/png.c * plug-ins/common/polar.c * plug-ins/common/semiflatten.c * plug-ins/common/sinus.c * plug-ins/common/sparkle.c * plug-ins/common/vpropagate.c * plug-ins/common/warp.c * plug-ins/common/whirlpinch.c * plug-ins/gfig/gfig-style.c * plug-ins/gfli/gfli.c * plug-ins/ifscompose/ifscompose.c * plug-ins/maze/handy.c * plug-ins/pagecurl/pagecurl.c * plug-ins/pygimp/gimpmodule.c * plug-ins/script-fu/scripts/*.scm: changed accordingly.
2004-09-22 18:43:09 +00:00
(gimp-context-set-background (adjcolour colour (- 0 dvalue)))
1997-11-24 22:05:25 +00:00
(gimp-free-select img
10
(gen_bottom_array xsize ysize owidth oheight width height)
CHANNEL-OP-REPLACE
1997-11-24 22:05:25 +00:00
0
0
0.0)
(gimp-edit-fill layer BACKGROUND-FILL)
1997-11-24 22:05:25 +00:00
(gimp-selection-none img)
(gimp-image-undo-group-end img)
1997-11-24 22:05:25 +00:00
(gimp-displays-flush)
(gimp-context-pop)))
1997-11-24 22:05:25 +00:00
(script-fu-register "script-fu-addborder"
_"Add _Border..."
1997-11-24 22:05:25 +00:00
"Add a border around an image"
"Andy Thomas <alt@picnic.demon.co.uk>"
"Andy Thomas"
"6/10/97"
"*"
SF-IMAGE "Input image" 0
SF-DRAWABLE "Input drawable" 0
SF-ADJUSTMENT _"Border X size" '(12 1 250 1 10 0 1)
SF-ADJUSTMENT _"Border Y size" '(12 1 250 1 10 0 1)
SF-COLOR _"Border color" '(38 31 207)
SF-ADJUSTMENT _"Delta value on color" '(25 1 255 1 10 0 1))
(script-fu-menu-register "script-fu-addborder"
_"<Image>/Script-Fu/Decor")