[plt-scheme] MrLib/graph.ss edges as splines

From: Stephen De Gabrielle (stephen at degabrielle.name)
Date: Wed Dec 12 12:02:56 EST 2007

Hi,
Like a dill I only recently realised that MrEd had a spline draw feature.

Just a fun here is a little mod of graph.ss that gives curved arrows.

[It looks best for horizontal graphs...]

;line 593 comment out draw-line
;                           (send dc draw-line
;                                (+ dx from-x) (+ dy from-y) ; start
;                                (+ dx to-x) (+ dy to-y)); end
;include draw-spline
                           (let* (
                                  (x1 (+ dx from-x)) ; start-point
                                  (y1 (+ dy from-y))
                                  (x2 (+ dx to-x))     ; end-point
                                  (y2 (+ dy to-y))
                                  (xmid (/ (+ x1 x2) 2)) ; mid-point for
nice curve
                                  (ymid (/ (+ y1 y2) 2))

                                  (x3 (+  (/ x1 4) (/ (* 3 xmid) 4))) ;
control point
                                  (y3 (+  (/ (* 3 y1) 4) (/ ymid 4)))

                                  (x4 (+  (/ (* 3 xmid) 4) (/ x2 4))) ;
control point.
                                  (y4 (+  (/ ymid 4) (/ (* 3 y2) 4)))

                                  )
                             (send dc draw-spline  ;  first bit
                                   x1 y1
                                   x3 y3 ;  control point.
                                   xmid ymid)
                             (send dc draw-spline  ;  second bit
                                   xmid ymid
                                   x4 y4
                                   x2 y2)
                             )


Cheers,

Stephen



--
Stephen De Gabrielle
s.degabrielle at ucl.ac.uk
Telephone +44 (0)20 7679 5242 (x45242)
Mobile                  079 851 890 45
http://www.uclic.ucl.ac.uk/annb/MaSI.html
University College London Interaction Centre
Remax House - 31/32 Alfred Place
London - WC1E 7DP
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20071212/b3f08cc2/attachment.html>

Posted on the users mailing list.