[racket] Problem with hline in

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Sat May 26 12:06:13 EDT 2012

Oh, now that I re-read that code I see a bug: it needs to set the pen
back. So the last line of the procedure passed to dc should be:

  (send dc set-pen pen)

Robby

On Sat, May 26, 2012 at 11:03 AM, Jens Axel Søgaard
<jensaxel at soegaard.net> wrote:
> 2012/5/26 Robby Findler <robby at eecs.northwestern.edu>:
>> Oh, in that case, you could do this:
>>
>> (hc-append (blank 1 0) (hline (- w 1) 1))
>
> Thanks!
>
>> If you don't want the rounded edges, you'd have to do something like this:
>>
>> (define (fraction p q)
>>  (define w (max (pict-width p) (pict-width q)))
>>  (vc-append p (vc-append (blank 0 2) (butt-hline w)) q))
>>
>> (require racket/gui/base)
>> (define (butt-hline w)
>>  (dc
>>   (λ (dc dx dy)
>>     (define pen (send dc get-pen))
>>     (send dc set-pen (send the-pen-list find-or-create-pen
>>                            (send pen get-color)
>>                            (send pen get-width)
>>                            'solid
>>                            'butt))
>>     (send dc draw-line dx dy (+ dx w) dy))
>>   w 1))
>
> I think I can use this technique to make roots.
> And to make a proper "vector arrow".
>
> Thanks,
> Jens Axel


Posted on the users mailing list.