Gimp-Forum.net
Draw a path by script-fu - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP)
+---- Forum: Scripting questions (https://www.gimp-forum.net/Forum-Scripting-questions)
+---- Thread: Draw a path by script-fu (/Thread-Draw-a-path-by-script-fu)



Draw a path by script-fu - andreadc - 01-23-2021

Hi! Is it possible to draw a path by script-fu? Can u link me a tutorial or documentations?


RE: Draw a path by script-fu - Ofnuts - 01-23-2021

I don't use script-fu so I cannot tell you the exact syntax, but in python it goes likes this:

Code:
pdb.gimp_context_set_line_width(self.lineWidth)
pdb.gimp_context_set_line_cap_style(self.capStyle)
pdb.gimp_context_set_line_join_style(self.joinStyle)
pdb.gimp_context_set_line_miter_limit(float(self.miterLimit))
pdb.gimp_context_set_antialias(self.antiAlias)
pdb.gimp_context_set_stroke_method(STROKE_LINE)  # requires 2.10!
pdb.gimp_edit_stroke_vectors(layer,path)

The really important bits are gimp_context_set_stroke_method(STROKE_LINE) (so it uses the Line mode instead of painting ti the brush), and gimp_edit_stroke_vectors(layer,path) to do the actual operation. The rest may or may not be useful.

For script-fu, drop pdb. and replace the underscores with dashes (so pdb.gimp_context_set_line_miter_limit becomes gimp-context-set-line-miter-limit)