Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
dynamics not working in gimp-drawable-edit-stroke-item
#1
I want to draw perpendicular lines to a path within a selection. This can be done in gimp by selecting the right brush with the correct settings and then stroking a path with the the paintbrush or pencil. When I try to use the same settings in python-fu the stroked portion simply stays vertical. I have noted that during the manual stroke selection there is an "Emulate brush dynamics" option which is selected. I cannot find a similar setting in the python-fu api.
There might be some other issues in the script since this is my second python-fu script:

Code:
#!/usr/bin/env python

# GIMP Python plug-in template.

from gimpfu import *

def hay_selection(img, layer) :
    gimp.progress_init("Finding next tree ring " + layer.name + "...")

    # Set up an undo group, so the operation will be undone in one step.
    pdb.gimp_undo_push_group_start(img)

    # Do stuff here.
    pdb.gimp_context_push()
    # Base grey color
    pdb.gimp_context_set_foreground(gimpcolor.RGB(224,224,224))
    pdb.gimp_drawable_edit_fill(layer, FOREGROUND_FILL)
    # Path around selection
    pdb.plug_in_sel2path(img, layer)
    np = pdb.gimp_image_get_active_vectors(img)
    pdb.gimp_context_set_foreground(gimpcolor.RGB(0,0,0))
    pdb.gimp_context_set_paint_method("gimp-paintbrush")
    pdb.gimp_context_set_brush("2. Block 03")
    pdb.gimp_context_set_dynamics("Track Direction")
    pdb.gimp_context_set_brush_aspect_ratio(-20)
    pdb.gimp_context_set_brush_size(15)
    pdb.gimp_context_set_brush_angle(0)
    pdb.gimp_context_set_brush_spacing(10)
    pdb.gimp_context_set_brush_hardness(1)
    pdb.gimp_context_set_stroke_method(1)
    pdb.gimp_message("Dynamics: " + pdb.gimp_context_get_dynamics())
    pdb.gimp_drawable_edit_stroke_item(layer,np)
    # Fill interior with Hay Small
    pdb.gimp_context_set_pattern("Hay Small")
    pdb.gimp_selection_shrink(img,7)
    pdb.gimp_drawable_edit_fill(layer, PATTERN_FILL)    

    # Cleanup
#    pdb.gimp_image_remove_vectors(img,np)
    pdb.gimp_context_pop()

    # Close the undo group.
    pdb.gimp_undo_push_group_end(img)

register(
    "python_fu_hay_selection",
    "Selection to Hay",
    "Adds edge and fill to selection for hay.",
    "jonker",
    "jonker",
    "2024",
    "<Image>/Python-Fu/Selection to Hay...",
    "*",      # Alternately use RGB, RGB*, GRAY*, INDEXED etc.
    [],
    [],
    hay_selection)

main()
Reply


Messages In This Thread
dynamics not working in gimp-drawable-edit-stroke-item - by jonker - 02-28-2024, 09:53 PM

Forum Jump: