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 / clothify.py < prev    next >
Encoding:
Python Source  |  2006-07-10  |  2.5 KB  |  68 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. import math
  21. from gimpfu import *
  22.  
  23. def python_clothify(timg, tdrawable, bx=9, by=9,
  24.                     azimuth=135, elevation=45, depth=3):
  25.     width = tdrawable.width
  26.     height = tdrawable.height
  27.     img = gimp.Image(width, height, RGB)
  28.     img.disable_undo()
  29.     layer_one = gimp.Layer(img, "X Dots", width, height, RGB_IMAGE,
  30.                            100, NORMAL_MODE)
  31.     img.add_layer(layer_one, 0)
  32.     pdb.gimp_edit_fill(layer_one, BACKGROUND_FILL)
  33.     pdb.plug_in_noisify(img, layer_one, 0, 0.7, 0.7, 0.7, 0.7)
  34.     layer_two = layer_one.copy()
  35.     layer_two.mode = MULTIPLY_MODE
  36.     layer_two.name = "Y Dots"
  37.     img.add_layer(layer_two, 0)
  38.     pdb.plug_in_gauss_rle(img, layer_one, bx, 1, 0)
  39.     pdb.plug_in_gauss_rle(img, layer_two, by, 0, 1)
  40.     img.flatten()
  41.     bump_layer = img.active_layer
  42.     pdb.plug_in_c_astretch(img, bump_layer)
  43.     pdb.plug_in_noisify(img, bump_layer, 0, 0.2, 0.2, 0.2, 0.2)
  44.     pdb.plug_in_bump_map(img, tdrawable, bump_layer, azimuth,
  45.                          elevation, depth, 0, 0, 0, 0, TRUE, FALSE, 0)
  46.     gimp.delete(img)
  47.  
  48. register(
  49.         "python_fu_clothify",
  50.         "Make the specified layer look like it is printed on cloth",
  51.         "Make the specified layer look like it is printed on cloth",
  52.         "James Henstridge",
  53.         "James Henstridge",
  54.         "1997-1999",
  55.         "<Image>/Python-Fu/Alchemy/_Clothify",
  56.         "RGB*, GRAY*",
  57.         [
  58.                 (PF_INT, "x_blur", "X blur", 9),
  59.                 (PF_INT, "y_blur", "Y blur", 9),
  60.                 (PF_INT, "azimuth", "Azimuth", 135),
  61.                 (PF_INT, "elevation", "Elevation", 45),
  62.                 (PF_INT, "depth", "Depth", 3)
  63.         ],
  64.         [],
  65.         python_clothify)
  66.  
  67. main()
  68.