draw_arrow
result = draw_arrow(img, x0, y0, x1, y1, color=, [thickness=1], [head_size=10])
Input: img, x0, y0, x1, y1, color, thickness, head_size · Output: result
What it is
img is an Image; draws a draw_line-style shaft from (x0,y0) to (x1,y1), plus an arrowhead: two more strokes from the tip back along the reversed shaft direction, splayed +/-30 degrees, each head_size pixels long (a two-stroke arrowhead, not a filled triangle — chosen so the head reuses the exact same line rasterizer and thickness as the shaft). A zero-length shaft draws only the (single-point) shaft, with no head, since it has no defined direction.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = draw_arrow(img, x0, y0, x1, y1, color=, [thickness=1], [head_size=10]) | img Imageimg is an Image.x0 —draws a draw_line-style shaft from (x0,y0) to (x1,y1), plus an arrowhead: two more strokes from the tip back along the reversed shaft direction, splayed +/-30 degrees, each head_size pixels long (a two-stroke arrowhead, not a filled triangle — chosen so the head reuses the exact same line rasterizer and thickness as the shaft).y0 —draws a draw_line-style shaft from (x0,y0) to (x1,y1), plus an arrowhead: two more strokes from the tip back along the reversed shaft direction, splayed +/-30 degrees, each head_size pixels long (a two-stroke arrowhead, not a filled triangle — chosen so the head reuses the exact same line rasterizer and thickness as the shaft).x1 —draws a draw_line-style shaft from (x0,y0) to (x1,y1), plus an arrowhead: two more strokes from the tip back along the reversed shaft direction, splayed +/-30 degrees, each head_size pixels long (a two-stroke arrowhead, not a filled triangle — chosen so the head reuses the exact same line rasterizer and thickness as the shaft).y1 —draws a draw_line-style shaft from (x0,y0) to (x1,y1), plus an arrowhead: two more strokes from the tip back along the reversed shaft direction, splayed +/-30 degrees, each head_size pixels long (a two-stroke arrowhead, not a filled triangle — chosen so the head reuses the exact same line rasterizer and thickness as the shaft).color —not documented yetthickness optional (default 1)draws a draw_line-style shaft from (x0,y0) to (x1,y1), plus an arrowhead: two more strokes from the tip back along the reversed shaft direction, splayed +/-30 degrees, each head_size pixels long (a two-stroke arrowhead, not a filled triangle — chosen so the head reuses the exact same line rasterizer and thickness as the shaft).head_size optional (default 10)draws a draw_line-style shaft from (x0,y0) to (x1,y1), plus an arrowhead: two more strokes from the tip back along the reversed shaft direction, splayed +/-30 degrees, each head_size pixels long (a two-stroke arrowhead, not a filled triangle — chosen so the head reuses the exact same line rasterizer and thickness as the shaft). | result Image | Returns a new Image, same dimensions as img. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
img = image_new(300, 200, r=20, g=20, b=20)
img = draw_line(img, 10, 10, 290, 10, color="yellow", thickness=2)
img = draw_rect(img, 20, 30, 60, 40, color="cyan", thickness=2)
img = draw_circle(img, 150, 100, 30, color="magenta", filled=true)
img = draw_arrow(img, 200, 150, 260, 180, color="white", head_size=12)
# A 100 px bar labeled "50 um" when pixel_size = 0.5 um/px.
img = draw_scale_bar(img, 50, pixel_size=0.5, unit="um", position="bottom-right", color="white")
save_image("/tmp/annotated.bmp", img)
from images
How it works
draw_arrow(img, x0, y0, x1, y1, color=, [thickness=1], [head_size=10]) -- a draw_line shaft plus a two-stroke arrowhead splayed +/-30 degrees back from the tip. See Image::draw_arrow's own doc comment for the exact geometry.
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.