racket / pict

Other
15 stars 20 forks source link

`panorma` calculates the descent incorrectly #63

Open lexi-lambda opened 4 years ago

lexi-lambda commented 4 years ago

Here is a program that draws an arrow and annotates it with lines that mark bounding box positions:

#lang racket
(require pict)

(define (metrics-frame p)
  (define metrics-line (hline (pict-width p) 0))
  (let* ([metrics (rectangle (pict-width p) (pict-height p))]
         [metrics (pin-over metrics 0 (pict-ascent p) (colorize metrics-line "red"))]
         [metrics (pin-over metrics 0 (- (pict-height p) (pict-descent p))
                            (linestyle 'long-dash (colorize metrics-line "blue")))])
    (pin-over p 0 0 (colorize (linewidth 1/4 metrics) "gray"))))

(define p (metrics-frame (panorama (pin-over (metrics-frame (linewidth 2 (hline 40 2)))
                                             36 -4 (metrics-frame (arrowhead 10 0))))))
(send (pict->bitmap (scale (inset p 2 2 2 5) 10))
      save-file "out.png" 'png)

This is the program’s output:

out

The dashed blue line at the very bottom is the descent-specified baseline of the resulting pict. Its position doesn’t make any sense: both of the original picts’ descents are 0. I took a look at the panorama implementation, but I don’t fully understand all the details, especially since pict uses two different coordinate spaces.