~ubuntu-branches/ubuntu/maverick/gimp/maverick-updates

« back to all changes in this revision

Viewing changes to plug-ins/pygimp/plug-ins/foggify.py

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2005-12-09 19:44:52 UTC
  • Revision ID: james.westby@ubuntu.com-20051209194452-yggpemjlofpjqyf4
Tags: upstream-2.2.9
ImportĀ upstreamĀ versionĀ 2.2.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
import time
 
22
 
 
23
def python_foggify(img, layer, name, colour, turbulence, opacity):
 
24
    img.undo_group_start()
 
25
 
 
26
    fog = gimp.Layer(img, name, layer.width, layer.height, RGBA_IMAGE,
 
27
                     opacity, NORMAL_MODE)
 
28
    img.add_layer(fog, 0)
 
29
    oldbg = gimp.get_background()
 
30
    gimp.set_background(colour)
 
31
    pdb.gimp_edit_fill(fog, BACKGROUND_FILL)
 
32
    gimp.set_background(oldbg)
 
33
 
 
34
    # create a layer mask for the new layer
 
35
    mask = fog.create_mask(0)
 
36
    fog.add_mask(mask)
 
37
        
 
38
    # add some clouds to the layer
 
39
    pdb.plug_in_plasma(img, mask, int(time.time()), turbulence)
 
40
        
 
41
    # apply the clouds to the layer
 
42
    fog.remove_mask(MASK_APPLY)
 
43
 
 
44
    img.undo_group_end()
 
45
 
 
46
register(
 
47
    "python_fu_foggify",
 
48
    "Add a layer of fog to the image",
 
49
    "Add a layer of fog to the image",
 
50
    "James Henstridge",
 
51
    "James Henstridge",
 
52
    "1999",
 
53
    "<Image>/Python-Fu/Effects/Add _fog",
 
54
    "RGB*, GRAY*",
 
55
    [
 
56
        (PF_STRING, "name", "The new layer name", "Clouds"),
 
57
        (PF_COLOUR, "colour", "The colour of the fog", (240,180,70)),
 
58
        (PF_SLIDER, "turbulence", "The turbulence", 1.0, (0, 10, 0.1)),
 
59
        (PF_SLIDER, "opacity", "The opacity", 100, (0, 100, 1)),
 
60
    ],
 
61
    [],
 
62
    python_foggify)
 
63
 
 
64
main()