1

How to draw an arrow in a frame in racket (DrRacket)? For example between two objects: a circle and a rectangle obtained by:

(send dc draw-ellipse 50 50 30 30) and (send dc draw-rectangle 200 200 30 6)
soegaard
  • 30,661
  • 4
  • 57
  • 106
chsms
  • 107
  • 2
  • Depending on the goal of the program, it might be easier to draw a `pict` and then send the pict to the frame as a bitmap because it would avoid all the message passing semantics. `pict` is also easier to use in general. – ben rudgers Jan 28 '15 at 19:48

2 Answers2

2

You can use picts to do such things.

First, you define your picts.

(define pict-a (rectangle 40 40))

(define pict-b (circle 40))

Then you combine them to be able to use rc-find or lc-find, which are the procedures that will help you connect those picts.

(define combined (hc-append 200 pict-a pict-b))

Finally

> (pin-arrows-line 30 combined
                   pict-a rc-find
                   pict-b lc-find
                   #:start-angle (/ pi 11)
                   #:end-angle (- (/ pi 11))
                   #:solid? #f)

Will produce this: Two picts connected

You can find more information in the docs! Tell us if that solved your problem!

David Merinos
  • 1,195
  • 1
  • 14
  • 36
1

What kind of arrows?

  • For simple arrows use draw-line directly.
  • For bended arrows use draw-spline. Use a filled triangle as a simple arrow head.

If you need a prettier arrow head shape, one option is to adapt the arrow shape from MetaPict.

You can find other examples of arrows in MetaPict's documentation.

An example with a non-straight arrow which shows how to draw a state machine with MetaPict.

ben rudgers
  • 3,647
  • 2
  • 20
  • 32
soegaard
  • 30,661
  • 4
  • 57
  • 106
  • An arrow as in oriented graphs or Petri nets to connect two nodes. A bit like too pin-line-arrow but in frame. – chsms Jan 28 '15 at 10:09