[racket] Slideshow: change baseline

10 views
Skip to first unread message

Laurent

unread,
May 22, 2013, 9:32:17 AM5/22/13
to Racket Mailing List
Hi,

Is it possible in slideshow to change the baseline of a pict?

I have the following code to draw a fraction:

;; Fraction
;; pict? pict? -> pict?
(define (frac a b)
  (vc-append
   a
   (hline (max (pict-width a) (pict-width b)) 20)
   b))

and I want to do some thing like:
(hbl-append (t "x=") (frac (t "1234") (t "5678")))

so that the hline is aligned with the =.

I tried the various procedures like `lift-above-baseline` and such but with no luck.

Thanks,
Laurent

Matthew Flatt

unread,
May 22, 2013, 9:47:18 AM5/22/13
to Laurent, Racket Mailing List
The `lift-above-baseline' function should be what you want, but with a
negative offset (so that it actually drops below the baseline).

#lang slideshow

;; Fraction
;; pict? pict? -> pict?
(define (frac a b)
(lift-above-baseline
(vc-append
a
(hline (max (pict-width a) (pict-width b)) 20)
b)
(- (pict-descent b) (pict-height b))))

(slide (hbl-append (t "x=") (frac (t "1234") (t "5678"))))

____________________
Racket Users list:
http://lists.racket-lang.org/users

Laurent

unread,
May 22, 2013, 9:50:24 AM5/22/13
to Matthew Flatt, Racket Mailing List

On Wed, May 22, 2013 at 3:47 PM, Matthew Flatt <mfl...@cs.utah.edu> wrote:
(define (frac a b)
  (lift-above-baseline
   (vc-append
    a
    (hline (max (pict-width a) (pict-width b)) 20)
    b)
   (- (pict-descent b) (pict-height b))))

(slide (hbl-append (t "x=") (frac (t "1234") (t "5678"))))


Indeed it works! I had tried with negative values but I probably had done it wrong then.
Thank you!

Laurent
Reply all
Reply to author
Forward
0 new messages