home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / lib / gimp / 2.0 / plug-ins / shadow_bevel.py < prev    next >
Encoding:
Python Source  |  2006-07-10  |  2.4 KB  |  76 lines

  1. #!/usr/bin/env python
  2.  
  3. #   Gimp-Python - allows the writing of Gimp plugins in Python.
  4. #   Copyright (C) 1997  James Henstridge <james@daa.com.au>
  5. #
  6. #   This program is free software; you can redistribute it and/or modify
  7. #   it under the terms of the GNU General Public License as published by
  8. #   the Free Software Foundation; either version 2 of the License, or
  9. #   (at your option) any later version.
  10. #
  11. #   This program is distributed in the hope that it will be useful,
  12. #   but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. #   GNU General Public License for more details.
  15. #
  16. #   You should have received a copy of the GNU General Public License
  17. #   along with this program; if not, write to the Free Software
  18. #   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19.  
  20. from gimpfu import *
  21.  
  22. def shadow_bevel(img, drawable, blur, bevel, do_shadow, drop_x, drop_y):
  23.     # disable undo for the image
  24.     img.undo_group_start()
  25.  
  26.     # copy the layer
  27.     shadow = drawable.copy(TRUE)
  28.     img.add_layer(shadow, img.layers.index(drawable)+1)
  29.     shadow.name = drawable.name + " shadow"
  30.     shadow.preserve_trans = FALSE
  31.  
  32.     # threshold the shadow layer to all white
  33.     pdb.gimp_threshold(shadow, 0, 255)
  34.  
  35.     # blur the shadow layer
  36.     pdb.plug_in_gauss_iir(img, shadow, blur, TRUE, TRUE)
  37.  
  38.     # do the bevel thing ...
  39.     if bevel:
  40.         pdb.plug_in_bump_map(img, drawable, shadow, 135, 45, 3,
  41.                              0, 0, 0, 0, TRUE, FALSE, 0)
  42.  
  43.     # make the shadow layer black now ...
  44.     pdb.gimp_invert(shadow)
  45.  
  46.     # translate the drop shadow
  47.     shadow.translate(drop_x, drop_y)
  48.  
  49.     if not do_shadow:
  50.         # delete shadow ...
  51.         gimp.delete(shadow)
  52.  
  53.     # enable undo again
  54.     img.undo_group_end()
  55.  
  56. register(
  57.     "shadow_bevel",
  58.     "Add a drop shadow to a layer, and optionally bevel it.",
  59.     "Add a drop shadow to a layer, and optionally bevel it.",
  60.     "James Henstridge",
  61.     "James Henstridge",
  62.     "1999",
  63.     "<Image>/Python-Fu/Effects/_Drop Shadow and Bevel",
  64.     "RGBA, GRAYA",
  65.     [
  66.         (PF_SLIDER, "blur",   "Shadow blur", 6, (1, 30, 1)),
  67.         (PF_BOOL,   "bevel",  "Bevel the image", TRUE),
  68.         (PF_BOOL,   "shadow", "Make a drop shadow", TRUE),
  69.         (PF_INT,    "drop_x", "Drop shadow X displacement", 3),
  70.         (PF_INT,    "drop_y", "Drop shadow Y displacement", 6)
  71.     ],
  72.     [],
  73.     shadow_bevel)
  74.  
  75. main()
  76.