Search code examples
pythongimppython-fu

How can I draw with my current brush size in gimp python-fu?


I'm writing a GIMP python-fu script that essentially just draws a black circle on the current layer, filling up the layer. The problem I'm having is that gimp_pencil() continues to use the default brush size even after gimp_context_set_brush_size() sets the active brush size to the size of the image (when I run the script from GIMP, the brush size slider changes to the width of the layer, but the mark that is made remains the default of 50x50) Here's my code:

def Circle(image, tdrawable):
    layer  = image.active_layer
    width  = tdrawable.width
    height = tdrawable.height
    pdb.gimp_context_set_brush_size(width)
    pdb.gimp_pencil(layer,2,(width/2,height/2))

What am I doing wrong?


Solution

  • This seens to work in the current development version of GIMP (compiled from GIT master) - if you are hang this behavior on the latest GIMP stable (2.8.14) you've hit a program bug.

    However, this is a hacky way to draw a circle, even if it works (ok if you wnat to use it for other brushes rather than circular ones) - but for circles, you should instead: 1) Make an ellipse selection centered on the image center and with radius min(width, layer)/2 2) Fill the selection.