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