From 5ddcf29d70ae21fd79bc191611375e6616748a15 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Mon, 31 Dec 2018 16:58:47 -0800 Subject: [PATCH] yesterday once more --- quad/quad/generic.rkt | 26 +++++++++++++++----------- quad/quad/typewriter.rkt | 11 +++++++++-- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/quad/quad/generic.rkt b/quad/quad/generic.rkt index 61532d7f..7f6f43fd 100644 --- a/quad/quad/generic.rkt +++ b/quad/quad/generic.rkt @@ -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)) \ No newline at end of file + (elems quad) ; returns list of subquads + (attrs quad)) ; returns list of attributes \ No newline at end of file diff --git a/quad/quad/typewriter.rkt b/quad/quad/typewriter.rkt index beac190b..36370f53 100644 --- a/quad/quad/typewriter.rkt +++ b/quad/quad/typewriter.rkt @@ -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