Hi all,First off, please forgive my coding style -- that is something to clean up after the functionality is working. Also, please let me know if there's a better way to attach code or screenshots.
I was writing a bit of code to generate a diagram, and bumped into an off-by-one error. Not sure whether its in my understanding of or use of the 2htdp/image library. Testing on DrRacket 5.3.1 on 64-bit linux.
----- begin test.rkt #lang racket (require 2htdp/image) (define (stack wordlist) (let ((boxes '()) (maxwidth 0)) (for ((w wordlist)) (let* ((txt (text w 24 "black")) (width (image-width txt))) (set! boxes (cons txt boxes)) (when (> width maxwidth) (set! maxwidth width)))) (let ((box (rectangle (* maxwidth 1.2) (* (image-height (text "Gg" 24 "black")) 1.2) "outline" "black")) (img empty-image)) (for ((b boxes)) (set! img (above (overlay box b) (if (equal? img empty-image) empty-image (line 0 15 "black")) img))) img))) (stack '("hello" "world" "1" "2" "3")) (save-image (stack '("hello" "world" "1" "2" "3")) "stack.png") ----- end test.rktThe code runs, but there is a one-pixel white gap between each (line 0 15 "black") and the box below it. Also, the anti-aliasing is rendering the line into the box above it. The save-image output is attached (and matches a screenshot).
Now the questions. What is the preferred image library in Racket? Am I misusing 'above, or is there an off-by-1 error in its implementation? (e.g. in above/internal or overlay/δ in collects/2htdp/private/image-more.rkt)
Thanks, Daniel
<<attachment: stack.png>>
____________________ Racket Users list: http://lists.racket-lang.org/users