Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Auto fit brush to image?
#11
The API you can use is documented here: https://developer.gimp.org/api/3.0/libgimp/index.html

The resulting code is a lot less verbose than the PDB (or the examples auto-generated in the Python console). Of course the doc linked is C-oriented and the Python API is slightly more usable (instead of passing pointer to memory locations for results, you get the results in a returned tuple). For instance, your
Code:
def draw_brush(canvas, width, height):
  procedure = Gimp.get_pdb().lookup_procedure('gimp-paintbrush-default')
  config = procedure.create_config()
  config.set_property('drawable', canvas)
  config.set_property('strokes', [width/2, height/2])
  result = procedure.run(config)
  success = result.index(0)

is (using the documentation from here):

Code:
success=Gimp.paintbrush_default(canvas,[width/2,height/2])
Going through the PDB/config raindance is still necessary when you call plugins, but even then there are ways to make it a lot shorter by delegating all the boilerplate code to a hgeneric function.
Reply


Messages In This Thread
Auto fit brush to image? - by R Soul - 01-14-2024, 01:21 PM
RE: Auto fit brush to image? - by Ofnuts - 01-14-2024, 02:10 PM
RE: Auto fit brush to image? - by R Soul - 01-14-2024, 05:22 PM
RE: Auto fit brush to image? - by Ofnuts - 01-14-2024, 05:51 PM
RE: Auto fit brush to image? - by R Soul - 01-14-2024, 07:24 PM
RE: Auto fit brush to image? - by Ofnuts - 01-14-2024, 09:41 PM
RE: Auto fit brush to image? - by R Soul - 01-14-2024, 10:02 PM
RE: Auto fit brush to image? - by Ofnuts - 01-14-2024, 10:22 PM
RE: Auto fit brush to image? - by R Soul - 01-15-2024, 09:16 PM
RE: Auto fit brush to image? - by R Soul - 02-16-2025, 09:39 PM
RE: Auto fit brush to image? - by Ofnuts - 02-16-2025, 10:35 PM
RE: Auto fit brush to image? - by R Soul - 02-16-2025, 11:31 PM
RE: Auto fit brush to image? - by Ofnuts - 02-16-2025, 11:45 PM

Forum Jump: