Function | Package: cg | ToC | DocOverview | CGDoc | RelNotes | FAQ | Index | PermutedIndex
| Allegro CL version 9.0 Unrevised from 8.2 to 9.0. 8.2 version

## draw-arrowhead

Arguments: stream from-pos to-pos &key (length 20) (width 10) fill

draw-arrowhead draws a simple arrowhead at to-pos for a line that was drawn between from-pos and to-pos.

The returned values indicate the point on the line at the base of the arrowhead. This could be used to draw the associated line so that it ends at this point instead of at the tip of the arrowhead, in order to leave a sharper tip when the line is thick. There are two returned values, for the x and y coordinates or the point.

While you can draw the line first and then draw arrowheads at one or both ends, you can also draw the arrowheads first, capturning the base coordinates and then draw the line with one end the base coordinates and thus ensure the tip of the arrowhead is sharp.

The arguments are:

- stream: the window or other graphical stream on which to draw the arrowhead. stream should be a `cg-stream`.
- from-pos: a position object (see make-position) indicating the "other" end of a line that was drawn, so that the arrow will be drawn at the proper angle.
- to-pos: a position object (see make-position) indicating the tip of the arrowhead.
- length: the length of the arrowhead in stream units (which are usually pixels). The default is 20.
- width: the width of the arrowhead at its base in stream units. The default is 10.
- fill: either `nil`, `t`, an RGB color object (see make-rgb), or an HLS color (see make-hls). This argument indicates how the arrow is to be filled.

  If the value is `nil` (the default), the arrow is filled in the current background-color of the stream. This creates the effect of a hollow arrow (with the background color showing through the arrowhead), though in fact the interior is still filled in order to cover over the end of the actual line that was drawn beforehand.

  If the value is `t`, then the arrow is filled with the current foreground-color of the stream, which is the color that is always used to draw the border of the arrowhead; this creates a solid arrow.

  If the value is an RGB or HLS color object, then the arrowhead is filled with that color. This option may be used to fill the arrowhead with a different color than is used for the border of the arrowhead.

### Example

Here is an example function that draws arrows at various angles.

    (defun test-arrowheads (&key (length 20)(width 10))
      (let* ((window (make-window :arrows
                       :class 'bitmap-window
                       :title "Arrowheads"
                       :interior (make-box 200 200 600 600)
                       :scrollbars nil))
             (pane (frame-child window))
             (center #.(make-position 200 200))
             coord side)
        (with-positions (pos1)
          (dotimes (j 9)
            (setq coord (+ 200 (* 40 (- j 4))))
            (dolist (fill (list nil t))
              (setq side (if fill 360 40))
              (nmake-position pos1 side coord)
              (draw-line pane center pos1)
              (draw-arrowhead pane center pos1 :fill fill
                              :length length :width width)
              (nmake-position pos1 coord side)
              (draw-line pane center pos1)
              (draw-arrowhead pane center pos1 :fill fill
                              :length length :width width))))))

See also cg-drawing.htm.

Copyright (c) 1998-2019, Franz Inc. Oakland, CA., USA. All rights reserved.
This page was not revised from the 8.2 page.
Created 2012.5.30.

|  | ToC | DocOverview | CGDoc | RelNotes | FAQ | Index | PermutedIndex
| Allegro CL version 9.0 Unrevised from 8.2 to 9.0. 8.2 version