1#!/usr/local/bin/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 3 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, see <https://www.gnu.org/licenses/>. 18 19from gimpfu import * 20import time 21 22gettext.install("gimp20-python", gimp.locale_directory, unicode=True) 23 24def foggify(img, layer, name, colour, turbulence, opacity): 25 26 gimp.context_push() 27 img.undo_group_start() 28 29 if img.base_type is RGB: 30 type = RGBA_IMAGE 31 else: 32 type = GRAYA_IMAGE 33 fog = gimp.Layer(img, name, 34 layer.width, layer.height, type, opacity, NORMAL_MODE) 35 fog.fill(FILL_TRANSPARENT) 36 img.insert_layer(fog) 37 38 gimp.set_background(colour) 39 pdb.gimp_edit_fill(fog, FILL_BACKGROUND) 40 41 # create a layer mask for the new layer 42 mask = fog.create_mask(0) 43 fog.add_mask(mask) 44 45 # add some clouds to the layer 46 pdb.plug_in_plasma(img, mask, int(time.time()), turbulence) 47 48 # apply the clouds to the layer 49 fog.remove_mask(MASK_APPLY) 50 51 img.undo_group_end() 52 gimp.context_pop() 53 54register( 55 "python-fu-foggify", 56 N_("Add a layer of fog"), 57 "Adds a layer of fog to the image.", 58 "James Henstridge", 59 "James Henstridge", 60 "1999,2007", 61 N_("_Fog..."), 62 "RGB*, GRAY*", 63 [ 64 (PF_IMAGE, "image", "Input image", None), 65 (PF_DRAWABLE, "drawable", "Input drawable", None), 66 (PF_STRING, "name", _("_Layer name"), _("Clouds")), 67 (PF_COLOUR, "colour", _("_Fog color"), (240, 180, 70)), 68 (PF_SLIDER, "turbulence", _("_Turbulence"), 1.0, (0, 10, 0.1)), 69 (PF_SLIDER, "opacity", _("Op_acity"), 100, (0, 100, 1)), 70 ], 71 [], 72 foggify, 73 menu="<Image>/Filters/Decor", 74 domain=("gimp20-python", gimp.locale_directory) 75 ) 76 77main() 78