Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GIMP 2.10 a brush in the filter parameters
#1
Hi,
in my activity of porting my filters to 2.10, I faced a strange behavior:
- there is a filter (running on 2.8) which as a "brush" parameter in the definition  
- trying to see it under 2.10 it was in the menu but not showing its menu when launched
- after some trials I discovered that removing the filter name from the parameters it was showing, but..
  only once (unless resetting all the filters)

So I decided to write a couple of test filters, one with the brush parameter (but set to None), the other one which uses the active brush.
The behavior was confirmed:
- using the first one I can see it and run only once (unless resetting the filters)
- using the second one I can see it and run as many times as I like

Ther same 2 filters included in my 2.8, show up and run always.

Hence I post here these 2 small filters; if someone is so kind to double-check them, I will appreciate 
The first one
Code:
#!/usr/bin/env python
from gimpfu import *
import random


def testBrushAsParm (inImage, inDrawable, inBrush, Run) :

   pdb.gimp_context_push
   pdb.gimp_image_undo_group_start(inImage)
   
   # set parameters for drawing the lines
   pdb.gimp_context_set_brush (inBrush)
   distance=100
   count=int(inDrawable.height/distance)
   h=0
   for h in range(count):
       x1 = 0                                  
       x2 = inDrawable.width                
       y1 = 25+(h*distance)              
       y2 = y1
       #info_msg ("x1, x2, y1, y2, Dw, Rh = "+str(x1)+",  "+str(x2)+",  "+str(y1)+",  "+str(y2)+",  "+str(Dw)+",  "+str(Rh))
       pdb.gimp_paintbrush (inDrawable, 0, 4,
                (x1, y1, x2, y2), PAINT_CONSTANT, 0)  
       h+=1
       
   pdb.gimp_image_undo_group_end(inImage)
   return()

# This is the plugin registration function
register(
   "testBrushAsParm",    
   "To test a Brush As Parameter",  
   "This script tests a Brush in the Parameters.",
   "Diego",
   "Diego Nassetti ",
   "2018",
   "testBrushAsParm",
   "RGB*",
   [
     (PF_IMAGE, "image", "Input image", None),
     (PF_DRAWABLE, "drawable", "Input drawable", None),
     (PF_BRUSH, "brush", "Brush to use", None),      
     (PF_TOGGLE, "test", "Does it run more than once?", False),    # fake parameter !
   ],
   [
     (PF_DRAWABLE, "odrawable", "Output drawable", None),
   ],
   testBrushAsParm,
   menu="<Image>/Test",
   )

main()
The second one


Code:
#!/usr/bin/env python
from gimpfu import *
import random


def testBrushAsNoParm (inImage, inDrawable, Run) :

   pdb.gimp_context_push
   pdb.gimp_image_undo_group_start(inImage)
   
   # set parameters for drawing the lines
   distance=100
   count=int(inDrawable.height/distance)
   h=0
   for h in range(count):
       x1 = 0                                  
       x2 = inDrawable.width                
       y1 = 25+(h*distance)              
       y2 = y1
       #info_msg ("x1, x2, y1, y2, Dw, Rh = "+str(x1)+",  "+str(x2)+",  "+str(y1)+",  "+str(y2)+",  "+str(Dw)+",  "+str(Rh))
       pdb.gimp_paintbrush (inDrawable, 0, 4,
                (x1, y1, x2, y2), PAINT_CONSTANT, 0)  
       h+=1
       
   pdb.gimp_image_undo_group_end(inImage)
   return()

# This is the plugin registration function
register(
   "testBrushAsNoParm",    
   "To test a Brush Not As Parameter",  
   "This script tests a Brush Not in the Parameters.",
   "Diego",
   "Diego Nassetti ",
   "2018",
   "testBrushAsNoParm",
   "RGB*",
   [
     (PF_IMAGE, "image", "Input image", None),
     (PF_DRAWABLE, "drawable", "Input drawable", None),
######(PF_BRUSH, "brush", "Brush to use", None),       # removed from the parameters
     (PF_TOGGLE, "test", "Does it run more than once?", True), # fake parameter !
   ],
   [
     (PF_DRAWABLE, "odrawable", "Output drawable", None),
   ],
   testBrushAsNoParm,
   menu="<Image>/Test",
   )

main()
Reply


Messages In This Thread
GIMP 2.10 a brush in the filter parameters - by dinasset - 05-04-2018, 12:27 PM

Forum Jump: