Draw arrow

Update [11/15/2009] : Added fixed brush width and double headed error, removed bug 1) one-point-paths, 2) horizontal paths
Update [11/16/2009] : Fixed image type restriction string
Update [11/19/2009] : Added feature for absolute wing length, fixed handling gray-scale images
Update [25/01/2010]: Fixed fixed opacity bug (thanks to Richard)

This plugin enables GIMP to draw an arbitrary arrow into an image or a new layer. The plugin has reasonable default values for every paramtere but is freely adjustable to ones needs. Parameters are:

  • wing length and line width freely adjustable (relative & absolute)
  • angle between arrow tail and wing
  • optional draw arrow in new layer
  • optional filled or not filled head
  • optional notch in arrow head
  • optional delete used path
  • optional draw double headed arrow

Usage:
Create a path (usually <B>) with the head of the arrow (first anchor point) and the end of the tail (second anchor point). Then call the script which adds itself to the "Tools" menu (I use <AltGr+P> as the shortcut as "Pfeil" is the german word for arrow).

ToDo:

  • Write documentation (any one can help me with that and knows how to?)
  • Open for suggestions
  • Enable a more angularly arrow

You can also contact me via ICQ #52712314 and Jabber/XMPP Hoffmann.P@jabber.ccc.de

AttachmentSize
Description.png47.5 KB
arrow.scm11.24 KB

Comments

Works only with a brush tool

Hi,
Thank you very much for this script! I have been missing a good arrow tool very much for a long time. Moreover, the arrows that this scripts makes are really nice.

However, it was very difficult to find out how this script works. I did what you suggested: made a path and ran the script, and it did nothing. If Fill head arrow was on, a nice little head was drawn without the line of the arrow.

I never dreamed that after drawing the path I have to switch to a brush tool to get the script work as it is intended. Without the last comment, I would never found out how to use the script. Now it works, but it is pretty slow and annoying that after drawing the path, I have to choose a brush tool. If you only make one or two arrows, this may be no problem, but if you make a lot of arrows, this slows down the workflow. And I don't really see the point of it.

Anyway, the script is nice, just that it could be more straightforward.
Thanks,
Abel

Same here

Apparently, between the last updates on the script something got changed, because arrow.scm is doing the same thing with me (draws arrow head but no tail).

Brush tool problem

I have just looked at this again. If I don't have a brush type tool selected I get a 'ragged' arrow. I noticed that I get the same effect if I have a brush type tool selected with the layer mode set to dissolve. I have therefore modified the script so that it temporarily sets the brushes paint mode to Normal.

In total I added 4 extra lines of code. I added the three lines with "; 6.3.2010" in the following section:

(PreviousOpacity 100.0)
(PreviousPaintMode 0) ; 6.3.2010
)
(begin
(set! PreviousOpacity (car (gimp-context-get-opacity)))
(gimp-context-set-opacity 100.0)
(set! PreviousPaintMode (car (gimp-brushes-get-paint-mode))); 6.3.2010
(gimp-brushes-set-paint-mode NORMAL-MODE) ; 6.3.2010

; collect points for arrow-tail and draw them

(aset points 0 inPointToX) (aset points 1 inPointToY)
(aset points 2 inPointFromX) (aset points 3 inPointFromY)

and the line with "; 6.3.2010" in the following section:

(gimp-selection-none image)
))
(gimp-brushes-set-paint-mode PreviousPaintMode) ; 6.3.2010
(gimp-context-set-opacity PreviousOpacity)

(I will email the whole script to Berengar on Monday when I have his email to hand.)

Hope this helps

Works brilliantly

Thanks for the code updates, p_c. Arrow.scm is now working properly. :)

Pleased to hear that it works for you too

This removes a niggle from a script that i find very useful.

I have noticed this morning that the gimp-brushes-set-paint-mode and its companion get function are deprecated and should be replaced by the gimp-context-set-paint-mode and gimp-context-get-paint-mode functions respectively (the script still seems to work in exactly the same way).

Opacity

I am using the default settings for the script with the foreground colour set to white.

The filled in centres of the arrow-heads always appear to be at 100% opacity.

If the selected tool is the paths tool, the select by colour tool, the rectangular selection tool .... (i.e. a non-drawing tool) then the remainder of the arrow appears at less than 100% opacity.

If the selected tool is the brush, pencil, eraser ... all parts of the arrow appear to be 100% opaque.

Update 22.1.2010
The problem is caused by the context opacity not being set to 100% - what controls the context opacity at the GUI level?

Fixed

Bug Fixed :-)

Club Mate is healthy sleep in pint bottles

Great plugin

Thank you for this plugin. For me advanced arrow tool was the killer feature of Paint.NET. I hope one day this plugin will be as powerful. Very promising as for something less than 1 month old. :)

The arrow is always straight line and does not really follow the path spline.
The parameter to control thickness is very counter-intuitive. Human readable thickness number (preferably always positive) and better documentation would be nice.

I see that it is a problem

I see that it is a problem to want to offer the possibility to use relative and absolute values at once, I will have to think about a good solution. I should probably add more drop-down boxes that enable the user to decide how he wants his arrows.
I my self stumbled across the length-dependent thickness when I wanted to draw to arrows with different length into my image. Maybe the script should be redone as a plugin...
I will add the drawing of splines and not-one-line-arrows to the todo-list. Are there any more features in Paint.NET that should be included?
---
Club Mate is healthy sleep in pint bottles

Curvy arrows

count me in as someone else who wants curvy, spline-hugging arrows. Badly enough, as it is, that I started thinking about how to do it. The hardest part, I think, is how the arrow head should be drawn. I see three ways to do it:
1a: stick to straight lines for the arrow head, and orient it so that the tangent to the arrow body at the arrow tip bisects the arrow head.
1b: stick to straight lines for the arrow head, and orient it so that the arrow body intersects it at the midpoint of the base of the arrow head.
2: use curved lines for the arrow head (basically, by rotating the spline by appropriate angles (and truncating it) and (for the base of the arrow head) moving the rotated spline so it intersects the other 2 forming the arrow head in the appropriate positions.

1a and 1b are reasonably straightforward (maybe more so for 1b, because it doesn't require figuring out that tangent), but will look ugly, or at least weird, if the arrow body is very curvy (in extreme cases, the body may stick out one side of the arrow head. On the flip side, 2 would require more work (maybe significantly so) to create the boundary of the arrowhead, but I think it's worth the effort.

What do you think? Is there something I missed? (Either another way to do it or a pro or con of one or more of 1a, 1b, and 2?)

arrow head size

Hi, great script, works well. I just have one problem, the fact that the arrow head size is always relative to the size of the length of the arrow. I would like to be able to draw a set of arrows of different length, but with the same head size. as it is now if I want to draw a long arrow the head ends up being quite large, at a minimum of 1/5th the size of the arrow length.

A small other thing I don't quite understand how the line thickness in the scrip is related to line thickness of brushes. In a figure I was working on arrow thickness of 2 seemed to correspond to brush size 5-6 pixels.

Cheers, thanks for this.

Re: arrow head size

Thank you, I added the feature to set a fixed (pixel) size for the arrow head (wing length is what I called it) as it was already existing for the line thickness. Again negative values are relative to the arrow length, positive values stand for absolute pixel values.

The line thickness of the script is not connected to the active brush. The script creates a new circle shaped brush and sets it size relative to the length of the arrow or absolute - depending on the line width parameter.
---
Club Mate is healthy sleep in pint bottles

Nice!

This is a nice script.

I would, however, submit the following comments:
* There is no reason to limit the script to RGB* images; it should work fine -- and prove just as useful -- on grayscale and indexed images (or on layermasks and channels in an RGB image).
* I don't think the script should destroy the path; paths use very little memory (relatively) and the user may need it for other purposes.
* Personally, I would find it more intuitive if the arrow were drawn in the direction from the starting point of the path to the ending point. (This would probably mean that the script should use the last two points of the last stroke of a multi-stroke path.)

Re: Nice!

Thanks!

* I unlimited the script (at least I think I did so by removing the limit)
* The deletion of the path is now optional and default is off
* Now you can change the direction of the arrow, default is the old setting. I still use the two outer strokes.

Club Mate is healthy sleep in pint bottles

Slight error in script

> * I unlimited the script (at least I think I did so by removing the limit)

It appears that in doing this, an error (most likely of the "copy-n-paste" variety) cropped up. You have substituted a "(Versionhistory:..." string where the drawable constraint string (e.g., "RGB*", "Grayscale*", etc) is expected. You want to substitute an asterisk (within quotes: "*"), indicating that any image type is acceptable.

Your script still functions with the bad string (the GIMP is apparently forgiving in this instance), however, it does fail to provide the "Repeat Arrow" and "Re-show Arrow" capabilities.

Re: Slight error in script

All right, thank you for that hint! I was already wondering where that nice blank line came from ;-)

---
Club Mate is healthy sleep in pint bottles

Error

Error: division by zero

Windows Vista 32 bit, using GIMP 2.6.7

Apparently the script requires you to create an active layer before setting your two path points. It was the only way I could get the script to work.

Error: Division by zero

I asume that this error occurred in the following to events:
1) you only have one point in your path
2) you have more then one point but the outer ones are on the same horizontal line. So their y-difference is there which I need(ed) for the calculation of the angle...

So, I fixed that error. If it occurs again I might have missed s.th. pleas update!

Club Mate is healthy sleep in pint bottles

Syndicate content