30 Drawing Conveniences

▼ |  | The Racket Drawing Toolkit

1 | Overview
2 | bitmap%
3 | bitmap-dc%
4 | brush%
5 | brush-list%
6 | color%
7 | color-database<%>
8 | dc<%>
9 | dc-path%
10 | font%
11 | font-list%
12 | font-name-directory<%>
13 | gl-config%
14 | gl-context<%>
15 | linear-gradient%
16 | pdf-dc%
17 | pen%
18 | pen-list%
19 | point%
20 | post-script-dc%
21 | ps-setup%
22 | radial-gradient%
23 | record-dc%
24 | region%
25 | svg-dc%
26 | Drawing Functions
27 | Drawing Contracts
28 | Signature and Unit
29 | Unsafe Libraries
30 | Drawing Conveniences
31 | Platform Dependencies
| Bibliography
| Index

► | 30 | Drawing Conveniences

30.1 | Arrows

On this page:

30.1 Arrows
draw-arrow

9.2
Racket
top contents ← prev up next →

## 30 Drawing Conveniences🔗ℹ

This section presents higher-level APIs that provide additional conveniences over the racket/draw API.

### 30.1 Arrows🔗ℹ

(require racket/draw/arrow) | package: draw-lib

> > procedure
> > (draw-arrow |  | dc |  |  |  |
> > |  | start-x |  |  |  |
> > |  | start-y |  |  |  |
> > |  | end-x |  |  |  |
> > |  | end-y |  |  |  |
> > |  | dx |  |  |  |
> > |  | dy |  |  |  |
> > | [ | #:pen-width pen-width |  |  |  |
> > |  | #:arrow-head-size arrow-head-size |  |  |  |
> > |  | #:arrow-root-radius arrow-root-radius |  |  |  |
> > |  | #:%age %age] |  |  |  |
> > |  | #:bb bb) |  | → |  | void?
> dc : (is-a?/c dc<%>)
> start-x : real?
> start-y : real?
> end-x : real?
> end-y : real?
> dx : real?
> dy : real?
> pen-width : (or/c real? #f) = #f
> arrow-head-size : real? = 8
> arrow-root-radius : real? = 2.5
> %age : #f = (or/c #f "leftup" (real-in -1 1))
> | bb |  | : |  |
> (or/c (list/c (or/c #f real?)
> (or/c #f real?)
> (or/c #f real?)
> (or/c #f real?))
> #f)

Draws an arrow on dc from (start-x, start-y) to (end-x, end-y). (dx, dy) is the top-left location for drawing. If pen-width is #f, the current pen width is used.

If %age is not #f, then the arrows are drawn with a curve. When %age is "leftup", then the arrows will curve leftwards and upwards from the end point to the start point. When %age is a number, the number controls the angle coming out of the starting point. If the number is negative, the arrows comes out to the left and if it is positive, it comes out to the right. The precise angle depends on the absolute value of the number. If the absolute value is close to 1, the angle is close to straight out to the sides. If the absolute value is close to 0, the angle is close to straight down or straight down.

When the arrow curves (because %age is not #f) and bb is not #f, it specifies a bounding box that can cause the arrow not to curve. Specifically, if the curve would go outside the bounding box, then the attempt to curve is abandoned, and a straight line is drawn.

Added in version 1.9 of package draw-lib.
Changed in version 1.23: Added the %age and bb arguments.

top contents ← prev up next →