Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Arrow Script
#71
@BugsBunnySan

I still couldn't replicate the problem until I realised that the "Resize layers" control in "Image/Canvas Size.." has to be set to "None". Having done this the problem shows when the arrow is drawn on the original layer just as you said.

What you have found is not a bug in the script, it is an obscure bug in GIMP and only seems to happen in the circumstances that you describe. The problem looks like it lies in the gimp-paintbrush-default function. It still happens in V2.99.12 (note that the script will not run in V2.99.12 unless you produce your own version that reinstates the function gimp-image-get-active-vectors)

As a work-around I have modified the script so that it always draws the arrow on a new layer but merges this layer down onto the original layer at the end if the option to draw the arrow on a new layer is not selected.

Try the updated version:

http://programmer97.byethost10.com/Files/arrow.zip

I will produce a simple script that can be used to demonstrate the problem and then submit a GIMP fault report.

Note that with the set-up that you described the drawable passed to the arrowhead drawing function has an offset of 40,40 whether the drawable is a new layer or the original layer - hence my saying that it is a problem with GIMP. If one of the methods had no offset then it would have been a problem with the script but as it is the script can't know whether or not to remove the offset.
Reply
#72
(10-11-2022, 04:44 PM)programmer_ceds Wrote: @BugsBunnySan

I still couldn't replicate the problem until I realised that the "Resize layers" control in "Image/Canvas Size.." has to be set to "None". Having done this the problem shows when the arrow is drawn on the original layer just as you said.

What you have found is not a bug in the script, it is an obscure bug in GIMP and only seems to happen in the circumstances that you describe. The problem looks like it lies in the gimp-paintbrush-default function. It still happens in V2.99.12 (note that the script will not run in V2.99.12 unless you produce your own version that reinstates the function gimp-image-get-active-vectors)

As a work-around I have modified the script so that it always draws the arrow on a new layer but merges this layer down onto the original layer at the end if the option to draw the arrow on a new layer is not selected.

Try the updated version:

http://programmer97.byethost10.com/Files/arrow.zip

I will produce a simple script that can be used to demonstrate the problem and then submit a GIMP fault report.

Note that with the set-up that you described the drawable passed to the arrowhead drawing function has an offset of 40,40 whether the drawable is a new layer or the original layer - hence my saying that it is a problem with GIMP. If one of the methods had no offset then it would have been a problem with the script but as it is the script can't know whether or not to remove the offset.

The paintbrush paints with coordinates 0, 0 being the top left corner of the drawable (layer in this case).

Whereas the arrow gets it in relation to the path, so in relation to the top left corner of the image canvass.

So I would have thought a fix is to deduct the drawable's x and y offsets from the x and y coordinates that are taken from the path to be used to position the arrowheads.

I tried some of the other ways a layer might get to have an offset that's not 0, 0, by moving the layer or cropping just the layer and then running the arrow script and unsurprisingly the arrowhead was drawn with the same offset problem in those cases too.
Reply
#73
@teapot
You are correct - it is a problem with the script. Yesterday I thought I saw an offset of 40,40 both when the arrow was being drawn directly on the drawable and when it was being drawn on a new layer. Rechecking today I'm seeing an offset of 0,0 when the arrow is being drawn on to a new layer. The easiest course of action is still to always draw the arrow on a new layer and then to merge this down to the original layer if the user deselects the option to draw the arrow on a new layer (this avoids having to apply the offset to a number of points. I have modified the comments in the script slightly and uploaded the revised code. Hopefully no more problems now.
Reply
#74
(10-12-2022, 04:46 PM)programmer_ceds Wrote: @teapot
You are correct - it is a problem with the script. Yesterday I thought I saw an offset of 40,40 both when the arrow was being drawn directly on the drawable and when it was being drawn on a new layer. Rechecking today I'm seeing an offset of 0,0 when the arrow is being drawn on to a new layer. The easiest course of action is still to always draw the arrow on a new layer and then to merge this down to the original layer if the user deselects the option to draw the arrow on a new layer (this avoids having to apply the offset to a number of points. I have modified the comments in the script slightly and uploaded the revised code. Hopefully no more problems now.

Hm, I tried the script just now and now the arrowhead appears in the correct location, but in return, the layer that it is drawn onto is resized to the full image size. Probably because the new intermediate layer for the arrow is the full image size by default on creating it and merging it down onto the layer the arrow should be in makes that layer full sized also... Maybe if the intermediate layer that the arrow is drawn on and then merged down where the same size and location in the image as the layer the arrow should be in?
Reply
#75
(10-12-2022, 04:46 PM)programmer_ceds Wrote: @teapot You are correct - it is a problem with the script. Yesterday I thought I saw an offset of 40,40 both when the arrow was being drawn directly on the drawable and when it was being drawn on a new layer. Rechecking today I'm seeing an offset of 0,0 when the arrow is being drawn on to a new layer.

Thanks for the clarification.

(10-12-2022, 04:46 PM)programmer_ceds Wrote: The easiest course of action is still to always draw the arrow on a new layer and then to merge this down to the original layer if the user deselects the option to draw the arrow on a new layer (this avoids having to apply the offset to a number of points.

I see what you mean, use of theStrokePoints is scattered throughout.  However it's only populated once by a call to gimp-vectors-stroke-get-points, so straight after that you could modify it by deducting the offsets from all it's points. Then the rest of the code won't need to change.

(10-12-2022, 09:11 PM)BugsBunnySan Wrote: Hm, I tried the script just now and now the arrowhead appears in the correct location, but in return, the layer that it is drawn onto is resized to the full image size. Probably because the new intermediate layer for the arrow is the full image size by default on creating it and merging it down onto the layer the arrow should be in makes that layer full sized also... Maybe if the intermediate layer that the arrow is drawn on and then merged down where the same size and location in the image as the layer the arrow should be in?

Also if the original layer isn't visible when the script is run the new arrow layer will be merged down to the first visible layer below it or there will be an error if there isn't a visible layer to merge down to.
Reply
#76
@teapot @BugsBunnySan
Thanks for checking the script and spotting the problems. I'll go back to the pre 10.7.2022 version of the script and apply the offset (which may be 0,0).

I hope to post the new version later today or tomorrow.
Reply
#77
I have uploaded a new version at:

http://programmer97.byethost10.com/Files/arrow.zip

This applies the layer offset to the coordinates of the path - this fixed everything apart from the filling of the arrowheads which then appeared in the wrong places as they are drawn relative to the image (since they use a selection) rather than relative to the layer. This has been fixed as well.

I have also added a line to the script to remove any existing selection(s) before it starts otherwise some or all of the arrow would not be drawn.

Let me know if there are still problems.
Reply
#78
programmer_ceds, It's working well here, thank you.

   
Reply
#79
(10-13-2022, 01:13 PM)programmer_ceds Wrote: I have uploaded a new version at:

http://programmer97.byethost10.com/Files/arrow.zip

This applies the layer offset to the coordinates of the path - this fixed everything apart from the filling of the arrowheads which then appeared in the wrong places as they are drawn relative to the image (since they use a selection) rather than relative to the layer. This has been fixed as well.

I have also added a line to the script to remove any existing selection(s) before it starts otherwise some or all of the arrow would not be drawn.

Let me know if there are still problems.

Cool, now it works perfectly! thanks Big Grin
Reply
#80
@teapot and @BugsBunnySan

Thanks for reporting back.

(I hadn't thought of using arrows as a font - nice touch)
Reply


Forum Jump: