Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help.Wanted('Pixel region gimpPy')
#11
Not bad, but can be made simpler (and more readable):

Instead of list((A,B,C)) you can write [A,B,C]. But bytearray() accepts tuples as well as lists, and returning several elements conveniently makes the function returns a tuple, so in FindColor() lines such as

Code:
return list((0, 255-int(255*((hue%60)/60.0)), 255, opac))


can be just as well spared two levels of parentheses and written:

Code:
return 0, 255-int(255*((hue%60)/60.0)), 255, opac
.

Also, in Python it is valid to have a comma after the last element of the list, so instead of using the 80-era "comma ahead" defensive coding style:

Code:
[
      (PF_IMAGE, "image", "takes current image", None)
      , (PF_DRAWABLE, "drawable", "Input layer", None)
      , (PF_SLIDER, "alphaVal", "Alpha value", 255, [0, 255, 10])
  ],

You can put commas at the end of every line:

Code:
[
      (PF_IMAGE, "image", "takes current image", None),
      (PF_DRAWABLE, "drawable", "Input layer", None),
      (PF_SLIDER, "alphaVal", "Alpha value", 255, [0, 255, 10]),
  ],
Reply


Forum Jump: