Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
length of a path
#2
I wrote this piece of code, it seems to work. Is it OK?

Code:
#!/usr/bin/env python
from gimpfu import *
def TestPathLength (inImage, inLayer) :
   
   activevectors = pdb.gimp_image_get_active_vectors (inImage)
   totallength = 0
   (nrs, ids) = pdb.gimp_vectors_get_strokes (activevectors)
   for stroke in ids:
       length = pdb.gimp_vectors_stroke_get_length (activevectors, stroke, 1.00)
       gimp.message ("length = "+str(length))
       totallength = totallength+length
   gimp.message ("total length = "+str(totallength))
   pdb.gimp_displays_flush
   return(totallength)

register(
   "TestPathLength", "TestPathLength", "TestPathLength",
   "Diego", "Diego Nassetti ", "May 2017",
   "TestPathLength",
   "RGB*,GRAY*",
   [
     (PF_IMAGE, "image", "Input image", None),
     (PF_DRAWABLE, "idrawable", "Input drawable", None),
   ],
   [
     (PF_FLOAT, "tplength", "Total path length", 0.0),
   ],
   TestPathLength,
   menu="<Image>/Diego/Test",
   )

main()    
Reply


Messages In This Thread
length of a path - by dinasset - 05-19-2017, 03:54 AM
RE: length of a path - by dinasset - 05-19-2017, 05:08 AM
RE: length of a path - by Ofnuts - 05-19-2017, 06:19 AM
RE: length of a path - by dinasset - 05-19-2017, 08:02 AM
RE: length of a path - by Ofnuts - 05-19-2017, 11:50 AM
RE: length of a path - by dinasset - 05-20-2017, 05:08 PM

Forum Jump: