yesterday once more

main
Matthew Butterick 6 years ago
parent e547c15e3e
commit 5ddcf29d70

@ -3,18 +3,22 @@
(provide (all-defined-out))
(define-generics quad
(in quad)
(out quad)
(inner quad)
(start quad) ; called before draw (?)
(end quad) ; called after draw (?)
(break quad) ; called if quad is not clipping (?)
(in quad) ; returns inbound connection point
(out quad) ; returns outbound connection point
(inner quad) ; returns inner connection point
(printable? quad [signal])
(size quad)
(offset quad)
(printable? quad [signal]) ; returns whether quad is printable (under `signal`)
(size quad) ; returns outer size of quad (two dimensional)
(offset quad) ; returns top left adjustment of drawing (may or may not clip to quad boundary)
(origin quad)
(set-origin! quad where)
(origin quad) ; returns point where quad starts
(set-origin! quad where) ; changes point where quad starts
(draw quad [surface])
(draw quad [surface]) ; draws quad (imperatively)
(elems quad)
(attrs quad))
(elems quad) ; returns list of subquads
(attrs quad)) ; returns list of attributes

@ -47,7 +47,10 @@
(let ([str (car (elems q))])
(cond
[(hash-has-key? (attrs q) 'link)
(text doc str (first (origin q)) (second (origin q)) (hasheq 'link (hash-ref (attrs q) 'link)))]
(save doc)
(fill-color doc "blue")
(text doc str (first (origin q)) (second (origin q)) (hasheq 'link (hash-ref (attrs q) 'link)))
(restore doc)]
[else
#;(println str)
(void)
@ -60,7 +63,6 @@
(define (make-break . xs) ($break (hasheq 'printable? #f 'size '(0 0)) xs))
(define (consolidate-runs pcs)
(for/fold ([runs empty]
[pcs pcs]
@ -90,6 +92,8 @@
(consolidate-runs pcs)
pcs))))))
;; 181231 it's weird that setup work for page is in the page break,
;; which is between pages, not associated with either
(define pb ($break (hasheq 'printable? #f
'size '(0 0)
'draw (λ (q doc)
@ -97,7 +101,10 @@
(font-size doc 10)
(define str (string-append "page " (number->string page-count)))
;; page number
(save doc)
(fill-color doc "blue")
(text doc str 10 10 (hasheq 'link "https://practicaltypography.com"))
(restore doc)
(set! page-count (add1 page-count)))) '(#\page)))
(define (page-wrap xs size [debug #f])
(break xs size debug

Loading…
Cancel
Save