Gimp/plug-ins/script-fu/scripts/image-structure.scm

164 lines
7.1 KiB
Scheme
Raw Normal View History

1997-11-24 14:05:25 -08:00
;;; image-structure.scm -*-scheme-*-
;;; Time-stamp: <1998/03/28 02:46:26 narazaki@InetQ.or.jp>
1997-11-24 14:05:25 -08:00
;;; Author: Shuji Narazaki <narazaki@InetQ.or.jp>
;;; Version 0.7
; ************************************************************************
; Changed on Feb 4, 1999 by Piet van Oostrum <piet@cs.uu.nl>
; For use with GIMP 1.1.
; All calls to gimp-text-* have been converted to use the *-fontname form.
; The corresponding parameters have been replaced by an SF-FONT parameter.
; ************************************************************************
1997-11-24 14:05:25 -08:00
;;; Code:
(if (not (symbol-bound? 'script-fu-show-image-structure-new-image?
(the-environment)))
(define script-fu-show-image-structure-new-image? TRUE))
(if (not (symbol-bound? 'script-fu-show-image-structure-space
(the-environment)))
(define script-fu-show-image-structure-space 50))
(if (not (symbol-bound? 'script-fu-show-image-structure-shear-length
(the-environment)))
(define script-fu-show-image-structure-shear-length 50))
(if (not (symbol-bound? 'script-fu-show-image-structure-border
(the-environment)))
(define script-fu-show-image-structure-border 10))
(if (not (symbol-bound? 'script-fu-show-image-structure-apply-layer-mask?
(the-environment)))
(define script-fu-show-image-structure-apply-layer-mask? TRUE))
(if (not (symbol-bound? 'script-fu-show-image-structure-with-layer-name?
(the-environment)))
(define script-fu-show-image-structure-with-layer-name? TRUE))
(if (not (symbol-bound? 'script-fu-show-image-structure-with-pad?
(the-environment)))
(define script-fu-show-image-structure-with-pad? TRUE))
(if (not (symbol-bound? 'script-fu-show-image-structure-padding-color
(the-environment)))
(define script-fu-show-image-structure-padding-color '(255 255 255)))
(if (not (symbol-bound? 'script-fu-show-image-structure-padding-opacity
(the-environment)))
(define script-fu-show-image-structure-padding-opacity 25))
(if (not (symbol-bound? 'script-fu-show-image-structure-with-background?
(the-environment)))
(define script-fu-show-image-structure-with-background? TRUE))
(if (not (symbol-bound? 'script-fu-show-image-structure-background-color
(the-environment)))
(define script-fu-show-image-structure-background-color '(0 0 0)))
(define (script-fu-show-image-structure img drawable new-image? space
shear-length border apply-layer-mask?
with-layer-name? with-pad? padding-color
padding-opacity with-background?
background-color)
(if (eq? new-image? TRUE)
(begin (set! img (car (gimp-image-duplicate img)))
(gimp-display-new img)))
1997-11-24 14:05:25 -08:00
(let* ((layers (gimp-image-get-layers img))
(num-of-layers (car layers))
(old-width (car (gimp-image-width img)))
(old-height (car (gimp-image-height img)))
(new-width (+ (* 2 border) (+ old-width (* 2 shear-length))))
(new-height (+ (* 2 border) (+ old-height (* space (- num-of-layers 1)))))
(new-bg #f)
(layer-names '())
(layer #f)
(index 0))
(gimp-context-push)
1997-11-24 14:05:25 -08:00
(gimp-image-resize img new-width new-height 0 0)
(set! layers (cadr layers))
(gimp-selection-none img)
(while (< index num-of-layers)
1997-11-24 14:05:25 -08:00
(set! layer (aref layers index))
(if (equal? "Background" (car (gimp-drawable-get-name layer)))
1997-11-24 14:05:25 -08:00
(begin
(gimp-layer-add-alpha layer)
(gimp-drawable-set-name layer "Original Background")))
(set! layer-names (cons (car (gimp-drawable-get-name layer)) layer-names))
(if (not (= -1 (car (gimp-layer-get-mask layer))))
marked gimp_image_add_layer_mask() and gimp_image_remove_layer_mask() as 2003-12-08 Michael Natterer <mitch@gimp.org> * tools/pdbgen/pdb/image.pdb: marked gimp_image_add_layer_mask() and gimp_image_remove_layer_mask() as deprecated. Didnn't remove them from the PDB because the new functions' signature differs and they are used very often in scripts, but removed them from the libgimp C wrappers. * tools/pdbgen/pdb/layer.pdb: added gimp_layer_add_mask() and gimp_layer_remove_mask(). * libgimp/gimpcompat.h: added compat cruft. * app/pdb/image_cmds.c * app/pdb/internal_procs.c * app/pdb/layer_cmds.c * libgimp/gimpimage_pdb.[ch] * libgimp/gimplayer_pdb.[ch]: regenerated. * libgimp/gimpexport.c * plug-ins/common/curve_bend.c * plug-ins/common/psd.c * plug-ins/pygimp/pygimp-image.c * plug-ins/script-fu/scripts/3d-outline.scm * plug-ins/script-fu/scripts/alien-neon-logo.scm * plug-ins/script-fu/scripts/blended-logo.scm * plug-ins/script-fu/scripts/burn-in-anim.scm * plug-ins/script-fu/scripts/carve-it.scm * plug-ins/script-fu/scripts/carved-logo.scm * plug-ins/script-fu/scripts/chrome-it.scm * plug-ins/script-fu/scripts/chrome-logo.scm * plug-ins/script-fu/scripts/coolmetal-logo.scm * plug-ins/script-fu/scripts/crystal-logo.scm * plug-ins/script-fu/scripts/fade-outline.scm * plug-ins/script-fu/scripts/frosty-logo.scm * plug-ins/script-fu/scripts/image-structure.scm * plug-ins/script-fu/scripts/news-text.scm * plug-ins/script-fu/scripts/rendermap.scm * plug-ins/script-fu/scripts/slide.scm * plug-ins/script-fu/scripts/sota-chrome-logo.scm * plug-ins/script-fu/scripts/speed-text.scm * plug-ins/script-fu/scripts/starburst-logo.scm * plug-ins/script-fu/scripts/textured-logo.scm * plug-ins/script-fu/scripts/weave.scm * plug-ins/script-fu/scripts/xach-effect.scm * plug-ins/xjt/xjt.c: changed accordingly. 2003-12-08 Michael Natterer <mitch@gimp.org> * libgimp/libgimp-sections.txt * libgimp/tmpl/gimpimage.sgml * libgimp/tmpl/gimplayer.sgml: follow layer mask API change.
2003-12-08 14:33:17 -08:00
(gimp-layer-remove-mask layer
(if (= TRUE apply-layer-mask?)
MASK-APPLY
MASK-DISCARD)))
1997-11-24 14:05:25 -08:00
(if (= TRUE with-pad?)
(begin
(gimp-selection-layer-alpha layer)
1997-11-24 14:05:25 -08:00
(gimp-selection-invert img)
(gimp-layer-set-preserve-trans layer FALSE)
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 11:43:09 -07:00
(gimp-context-set-foreground padding-color)
(gimp-edit-bucket-fill layer FG-BUCKET-FILL NORMAL-MODE
padding-opacity 0 0 0 0)
1997-11-24 14:05:25 -08:00
(gimp-selection-none img)))
1997-11-24 14:05:25 -08:00
(gimp-layer-translate layer
(+ border shear-length) (+ border (* space index)))
(gimp-shear layer TRUE 0 (* (/ (car (gimp-drawable-height layer))
1997-11-24 14:05:25 -08:00
old-height)
(* -2 shear-length)))
(set! index (+ index 1)))
(set! new-bg (- num-of-layers 1))
(if (= TRUE with-background?)
(begin
(set! new-bg (car (gimp-layer-new img new-width new-height RGBA-IMAGE
"New Background" 100 NORMAL-MODE)))
1997-11-24 14:05:25 -08:00
(gimp-image-add-layer img new-bg num-of-layers)
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 11:43:09 -07:00
(gimp-context-set-background background-color)
(gimp-edit-fill new-bg BACKGROUND-FILL)))
1997-11-24 14:05:25 -08:00
(gimp-image-set-active-layer img (aref layers 0))
(if (= TRUE with-layer-name?)
(let ((text-layer #f))
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 11:43:09 -07:00
(gimp-context-set-foreground '(255 255 255))
1997-11-24 14:05:25 -08:00
(set! index 0)
(set! layer-names (nreverse layer-names))
(while (< index num-of-layers)
(set! text-layer (car (gimp-text-fontname img -1 (/ border 2)
(+ (* space index) old-height)
1997-11-24 14:05:25 -08:00
(car layer-names)
0 TRUE 14 PIXELS "Sans")))
(gimp-layer-set-mode text-layer NORMAL-MODE)
1997-11-24 14:05:25 -08:00
(set! index (+ index 1))
(set! layer-names (cdr layer-names)))))
1997-11-24 14:05:25 -08:00
(gimp-image-set-active-layer img new-bg)
(set! script-fu-show-image-structure-new-image? new-image?)
(set! script-fu-show-image-structure-space space)
(set! script-fu-show-image-structure-shear-length shear-length)
(set! script-fu-show-image-structure-border border)
(set! script-fu-show-image-structure-apply-layer-mask? apply-layer-mask?)
(set! script-fu-show-image-structure-with-layer-name? with-layer-name?)
(set! script-fu-show-image-structure-with-pad? with-pad?)
(set! script-fu-show-image-structure-padding-color padding-color)
(set! script-fu-show-image-structure-padding-opacity padding-opacity)
(set! script-fu-show-image-structure-with-background? with-background?)
(set! script-fu-show-image-structure-background-color background-color)
(gimp-displays-flush)
(gimp-context-pop)))
1997-11-24 14:05:25 -08:00
(script-fu-register
"script-fu-show-image-structure"
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-11 10:14:32 -07:00
_"<Image>/Script-Fu/Utils/Show Image _Structure..."
"Show the layer structure of the image"
"Shuji Narazaki <narazaki@InetQ.or.jp>"
"Shuji Narazaki"
"1997"
"RGB*, GRAY*"
SF-IMAGE "image" 0
SF-DRAWABLE "Drawable (unused)" 0
SF-TOGGLE _"Create new image" script-fu-show-image-structure-new-image?
SF-ADJUSTMENT _"Space between layers" (cons script-fu-show-image-structure-space '(0 1000 1 10 0 1))
SF-ADJUSTMENT _"Shear length" (cons script-fu-show-image-structure-shear-length '(1 1000 1 10 0 1))
SF-ADJUSTMENT _"Outer border" (cons script-fu-show-image-structure-border '(0 250 1 10 0 1))
SF-TOGGLE _"Apply layer mask (or discard)" script-fu-show-image-structure-apply-layer-mask?
SF-TOGGLE _"Insert layer names" script-fu-show-image-structure-with-layer-name?
SF-TOGGLE _"Padding for transparent regions" script-fu-show-image-structure-with-pad?
SF-COLOR _"Pad color" script-fu-show-image-structure-padding-color
SF-ADJUSTMENT _"Pad opacity" (cons script-fu-show-image-structure-padding-opacity '(0 100 1 10 1 0))
SF-TOGGLE _"Make new background" script-fu-show-image-structure-with-background?
SF-COLOR _"Background color" script-fu-show-image-structure-background-color
1997-11-24 14:05:25 -08:00
)
;;; image-structure.scm ends here