Think the culprit is here:
The polygon selections create partially selected pixels. This is normal. When you cut, these partially selected pixels become partially transparent and you get a smooth cut. However, you keep that selection. So when you apply the hue-saturation, the effect of the hue-saturation on these partially selected pixels isn't as strong as on the other (fully selected) pixels and since the goal of the hue-saturation operation is to darken things, these pixels remain lighter.
The fix would be to remove the selection before you apply the hue-saturation... AFAIK H/S only applies to the RGB channels and will leave the alpha channel unchanged.
Edit: another possible fix is to to the Hue-Saturation change before the cut...
Code:
pdb.gimp_image_select_polygon(image01, CHANNEL_OP_ADD, len(polygonPoints), polygonPoints) #temp add this back
pdb.gimp_selection_invert(image01)
#~~~~~~~~~~
layerobj = layerdata[i].layerobj #-()
pdb.gimp_edit_cut(layerobj)
pdb.gimp_selection_invert(image01)
#--- darken all but the top layer -----------------------------
if i != len(layerdata)-1:
pdb.gimp_hue_saturation(layerobj, ALL_HUES, 0, layerdata[i].lumsadjust, layerdata[i].satadjust)
The polygon selections create partially selected pixels. This is normal. When you cut, these partially selected pixels become partially transparent and you get a smooth cut. However, you keep that selection. So when you apply the hue-saturation, the effect of the hue-saturation on these partially selected pixels isn't as strong as on the other (fully selected) pixels and since the goal of the hue-saturation operation is to darken things, these pixels remain lighter.
The fix would be to remove the selection before you apply the hue-saturation... AFAIK H/S only applies to the RGB channels and will leave the alpha channel unchanged.
Edit: another possible fix is to to the Hue-Saturation change before the cut...