test10 works
parent
47331124f4
commit
b0f9ee621b
File diff suppressed because one or more lines are too long
@ -0,0 +1,27 @@
|
||||
PDFDocument = require 'pdfkit'
|
||||
tiger = require './assets/tiger'
|
||||
fs = require 'fs'
|
||||
|
||||
make = (doc) ->
|
||||
doc.translate(220, 300)
|
||||
# Render each path that makes up the tiger image
|
||||
for part in tiger
|
||||
doc.path(part.path) # render an SVG path
|
||||
|
||||
if part['stroke-width']
|
||||
doc.lineWidth part['stroke-width']
|
||||
|
||||
if part.fill isnt 'none' and part.stroke isnt 'none'
|
||||
doc.fillAndStroke(part.fill, part.stroke)
|
||||
else
|
||||
unless part.fill is 'none'
|
||||
doc.fill(part.fill)
|
||||
|
||||
unless part.stroke is 'none'
|
||||
doc.stroke(part.stroke)
|
||||
|
||||
doc.end()
|
||||
|
||||
doc = new PDFDocument({compress: yes})
|
||||
doc.pipe(fs.createWriteStream('test10c.pdf'))
|
||||
make doc
|
@ -0,0 +1,25 @@
|
||||
#lang pitfall/pdftest
|
||||
|
||||
(define (proc doc)
|
||||
(send doc translate 220 300)
|
||||
(for* ([datum (in-list (read (open-input-string (string-replace (file->string "assets/tiger.json") #rx"[,:]" " "))))]
|
||||
[part (in-value (apply hash datum))])
|
||||
(send doc path (hash-ref part 'path))
|
||||
|
||||
(when (hash-has-key? part "stroke-width")
|
||||
(send doc lineWidth (string->number (hash-ref part "stroke-width"))))
|
||||
|
||||
(if (and (not (string=? (hash-ref part 'fill "none") "none"))
|
||||
(not (string=? (hash-ref part 'stroke "none") "none")))
|
||||
(send doc fillAndStroke (hash-ref part 'fill) (hash-ref part 'stroke))
|
||||
(begin
|
||||
(unless (string=? (hash-ref part 'fill "none") "none")
|
||||
(send doc fill (hash-ref part 'fill)))
|
||||
(unless (string=? (hash-ref part 'stroke "none") "none")
|
||||
(send doc fill (hash-ref part 'stroke)))))))
|
||||
|
||||
(define-runtime-path this "test10rkt.pdf")
|
||||
(make-doc this #f proc #:pdfkit #f)
|
||||
|
||||
(define-runtime-path that "test10crkt.pdf")
|
||||
(make-doc that #t proc #:pdfkit #f)
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue