You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
typesetting/pitfall/ptest/test10.rkt

29 lines
1.0 KiB
Racket

#lang racket/base
6 years ago
(require pitfall/pdftest racket/file racket/string)
7 years ago
7 years ago
(define-runtime-path tiger "assets/tiger.json")
7 years ago
(define (proc doc)
5 years ago
(translate doc 220 300)
7 years ago
(for* ([datum (in-list (read (open-input-string (string-replace (file->string tiger) #rx"[,:]" " "))))]
7 years ago
[part (in-value (apply hash datum))])
5 years ago
(path doc (hash-ref part 'path))
7 years ago
(when (hash-has-key? part "stroke-width")
5 years ago
(line-width doc (string->number (hash-ref part "stroke-width"))))
7 years ago
(if (and (not (string=? (hash-ref part 'fill "none") "none"))
(not (string=? (hash-ref part 'stroke "none") "none")))
5 years ago
(fill-and-stroke doc (hash-ref part 'fill) (hash-ref part 'stroke))
7 years ago
(begin
(unless (string=? (hash-ref part 'fill "none") "none")
5 years ago
(fill doc (hash-ref part 'fill)))
7 years ago
(unless (string=? (hash-ref part 'stroke "none") "none")
5 years ago
(fill doc (hash-ref part 'stroke)))))))
7 years ago
(define-runtime-path this "test10rkt.pdf")
6 years ago
(make-doc this #f proc)
7 years ago
6 years ago
(define-runtime-path that "test10crkt.pdf")
(make-doc that #t proc)