[racket] Problem with hline in

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Sat May 26 11:47:01 EDT 2012

Oh, in that case, you could do this:

(hc-append (blank 1 0) (hline (- w 1) 1))

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've added the 2 pixel blank gap to counteract the fact that these
fonts have "internal leading" and to even out the whitespace above and
below the line.

hth,
Robby

On Sat, May 26, 2012 at 10:30 AM, Jens Axel Søgaard
<jensaxel at soegaard.net> wrote:
> Hi Robby,
>
>> So maybe the easiest thing is to drop down to use 'dc' to draw the
>> precise lines you want.
>>
>> If you spell that out here, I can probably give you some guidance on
>> how to do it?
>
> The hline is used to make a fraction.
> When I scaled the fraction, I noticed the division bar was asymmetrical.
>
> See attached file.
>
> /Jens Axel


Posted on the users mailing list.