[Gimp-user] Sample script was: Re Enhancement request: Transparency as a "paintable" color



I have written a short python script to do paint-with-erase (see below)
Have no idea if it has unwanted side effects.

It gives no visible feedback of the current drawing mode :(
I'd be interested to hear how I might provide this feedback.


******** Script

'''
toggle_eraser.py

toggles the current tool between eraser and paintbrush


Brendan Scott
Version: 1.20130807
7 August 2013

Copyright (C) 2013 Brendan Scott

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/



'''

from gimpfu import *
import gimp, gimpplugin
from gimpenums import *
from gimpshelf import shelf


PAINT_METHODS = ('gimp-pencil', 'gimp-paintbrush', 'gimp-eraser', 'gimp-airbrush',
                                'gimp-ink', 'gimp-clone', 'gimp-heal', 'gimp-perspective-clone',
                                'gimp-convolve', 'gimp-smudge', 'gimp-dodge-burn')  #just for reference
TOGGLE_MODES = [23, 0] # 0 = normal, 23 = erase mode

class Toggle_Eraser(gimpplugin.plugin):
    def start(self):
        gimp.main(self.init, self.quit, self.query, self._run)
def init(self):
        pass

    def quit(self):
        pass
def query(self):
        # called to find what functionality the plugin provides.
        gimp.install_procedure( "toggle_eraser",
              "Toggles current drawing mode between normal and erase",
            '''Toggles current drawing mode between normal and erase (simulates toggling eraser and 
paintbrush)''',
            "Brendan Scott",
            "Brendan Scott",
            "2013",
            "<Image>/Tools/Toggle/Eraser",
            "",
           PLUGIN,
            [(PDB_INT32, "run_mode", "Run mode")],
            [])
def toggle_eraser(self, arg1):
        current_mode = gimp.pdb.gimp_context_get_paint_mode()
if current_mode == 0:
            new_mode= 23
        elif current_mode == 23:
            new_mode=0
        else: # do nothing
            return
gimp.pdb.gimp_context_set_paint_mode(new_mode)

if __name__ == '__main__':
    Toggle_Eraser().start()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]