test2 finished

main
Matthew Butterick 7 years ago
parent acf9f12ab9
commit ac0827d171

@ -2,4 +2,5 @@
(module+ test
(require pitfall/test/test0
pitfall/test/test1
pitfall/test/test2
pitfall/page-test))

@ -14,10 +14,6 @@ doc.moveTo(0, 20)
doc.translate(0, 200)
doc.path('M 0,20 L 100,160 Q 130,200 150,120 C 190,-40 200,200 300,150 L 400,90').stroke()
doc.translate(0, 200)
doc.polygon [100, 0], [50, 100], [150, 100]
doc.stroke()

@ -39,7 +39,7 @@ endobj
endobj
3 0 obj
<<
/Length 979
/Length 890
>>
stream
1 0 0 -1 0 792 cm
@ -50,13 +50,6 @@ stream
400 90 l
S
1 0 0 1 0 200 cm
0 20 m
100 160 l
130 200 150 120 v
190 -40 200 200 300 150 c
400 90 l
S
1 0 0 1 0 200 cm
100 0 m
50 100 l
150 100 l
@ -126,7 +119,7 @@ endobj
<<
/Producer (PDFKit)
/Creator (PDFKit)
/CreationDate (D:20170515173303Z)
/CreationDate (D:20170515185139Z)
>>
endobj
2 0 obj
@ -145,15 +138,15 @@ endobj
xref
0 10
0000000000 65535 f
0000001541 00000 n
0000001492 00000 n
0000001452 00000 n
0000001403 00000 n
0000000370 00000 n
0000000253 00000 n
0000000149 00000 n
0000000015 00000 n
0000000061 00000 n
0000000105 00000 n
0000001400 00000 n
0000001311 00000 n
trailer
<<
/Size 10
@ -161,5 +154,5 @@ trailer
/Info 9 0 R
>>
startxref
1598
1509
%%EOF

@ -16,16 +16,6 @@
(send* doc [translate 0 200])
#|
;; curved path as svg path
(send* doc
[path "M 0,20 L 100,160 Q 130,200 150,120 C 190,-40 200,200 300,150 L 400,90"]
[stroke])
|#
(send* doc
[translate 0 200])
;; triangle
(send* doc
[polygon '(100 0) '(50 100) '(150 100)]
@ -50,8 +40,6 @@
[fillAndStroke "red" "#900"]
[restore])
#|
(send* doc [translate 0 200])
;; these examples are easier to see with a large line width
@ -83,8 +71,7 @@
[lineJoin 'bevel]
[rect 250 100 50 50]
[stroke])
|#
(send doc end)))
;(check-copy-equal? this)
(check-copy-equal? this)

@ -0,0 +1,158 @@
%PDF-1.3
%ÿÿÿÿ
6 0 obj
<<
/ca 0.8
/Type /ExtGState
>>
endobj
7 0 obj
<<
/ca 1
/Type /ExtGState
>>
endobj
8 0 obj
<<
/CA 1
/Type /ExtGState
>>
endobj
5 0 obj
<<
/Parent 1 0 R
/Resources 4 0 R
/Contents 3 0 R
/MediaBox [0 0 612 792]
/Type /Page
>>
endobj
4 0 obj
<<
/ExtGState <<
/Gs2 7 0 R
/Gs1 6 0 R
/Gs3 8 0 R
>>
/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
>>
endobj
3 0 obj
<<
/Length 890
>>
stream
1 0 0 -1 0 792 cm
0 20 m
100 160 l
130 200 150 120 v
190 -40 200 200 300 150 c
400 90 l
S
1 0 0 1 0 200 cm
100 0 m
50 100 l
150 100 l
h
S
q
1 0 0 1 200 0 cm
50 50 m
50 22.385763 72.385763 0 100 0 c
127.614237 0 150 22.385763 150 50 c
150 77.614237 127.614237 100 100 100 c
72.385763 100 50 77.614237 50 50 c
h
[5 10] 0 d
S
Q
q
1 0 0 1 400 0 cm
50 50 m
50 22.385763 72.385763 0 100 0 c
127.614237 0 150 22.385763 150 50 c
150 77.614237 127.614237 100 100 100 c
72.385763 100 50 77.614237 50 50 c
h
3 w
/Gs1 gs
/DeviceRGB cs
1 0 0 scn
/Gs2 gs
/DeviceRGB CS
0.6 0 0 SCN
/Gs3 gs
B
Q
1 0 0 1 0 200 cm
25 w
0 J
50 20 m
100 20 l
S
1 J
150 20 m
200 20 l
S
2 J
250 20 m
260 30 m
260 21.715729 266.715729 15 275 15 c
283.284271 15 290 21.715729 290 30 c
290 38.284271 283.284271 45 275 45 c
266.715729 45 260 38.284271 260 30 c
h
S
0 j
50 100 50 50 re
S
1 j
150 100 50 50 re
S
2 j
250 100 50 50 re
S
endstream
endobj
9 0 obj
<<
/CreationDate (D:19700101000000Z)
/Creator (PitfallKit)
/Producer (PitfallKit)
>>
endobj
2 0 obj
<<
/Pages 1 0 R
/Type /Catalog
>>
endobj
1 0 obj
<<
/Kids [5 0 R]
/Count 1
/Type /Pages
>>
endobj
xref
0 10
0000000000 65535 f
0000001460 00000 n
0000001411 00000 n
0000000370 00000 n
0000000253 00000 n
0000000149 00000 n
0000000015 00000 n
0000000061 00000 n
0000000105 00000 n
0000001311 00000 n
trailer
<<
/Info 9 0 R
/Root 2 0 R
/Size 10
>>
startxref
1517
%%EOF

@ -39,7 +39,7 @@ endobj
endobj
3 0 obj
<<
/Length 595
/Length 890
>>
stream
1 0 0 -1 0 792 cm
@ -50,7 +50,6 @@ stream
400 90 l
S
1 0 0 1 0 200 cm
1 0 0 1 0 200 cm
100 0 m
50 100 l
150 100 l
@ -75,7 +74,7 @@ q
150 77.614237 127.614237 100 100 100 c
72.385763 100 50 77.614237 50 50 c
h
#3
3 w
/Gs1 gs
/DeviceRGB cs
1 0 0 scn
@ -85,6 +84,34 @@ h
/Gs3 gs
B
Q
1 0 0 1 0 200 cm
25 w
0 J
50 20 m
100 20 l
S
1 J
150 20 m
200 20 l
S
2 J
250 20 m
260 30 m
260 21.715729 266.715729 15 275 15 c
283.284271 15 290 21.715729 290 30 c
290 38.284271 283.284271 45 275 45 c
266.715729 45 260 38.284271 260 30 c
h
S
0 j
50 100 50 50 re
S
1 j
150 100 50 50 re
S
2 j
250 100 50 50 re
S
endstream
endobj
@ -111,15 +138,15 @@ endobj
xref
0 10
0000000000 65535 f
0000001165 00000 n
0000001116 00000 n
0000001460 00000 n
0000001411 00000 n
0000000370 00000 n
0000000253 00000 n
0000000149 00000 n
0000000015 00000 n
0000000061 00000 n
0000000105 00000 n
0000001016 00000 n
0000001311 00000 n
trailer
<<
/Info 9 0 R
@ -127,5 +154,5 @@ trailer
/Size 10
>>
startxref
1222
1517
%%EOF

@ -12,12 +12,15 @@
save
restore
closePath
lineCap
lineJoin
lineWidth
dash
moveTo
lineTo
bezierCurveTo
quadraticCurveTo
rect
ellipse
circle
polygon
@ -58,10 +61,27 @@
(->m object?)
(send this addContent "h"))
(define/contract (lineCap this [c #f])
((or/c 'butt 'round 'square #f) . ->m . object?)
(define cap-styles (hasheq 'butt 0 'round 1 'square 2))
(send this addContent
(format "~a J" (if (symbol? c)
(hash-ref cap-styles c)
""))))
(define/contract (lineJoin this [j #f])
((or/c 'miter 'round 'bevel #f) . ->m . object?)
(define cap-styles (hasheq 'miter 0 'round 1 'bevel 2))
(send this addContent
(format "~a j" (if (symbol? j)
(hash-ref cap-styles j)
""))))
(define/contract (lineWidth this w)
(number? . ->m . object?)
(send this addContent (format "#~a" (number w))))
(send this addContent (format "~a w" (number w))))
(define/contract (dash this length [options (mhash)])
@ -101,6 +121,11 @@
(send this addContent (format "~a v" (string-join (map number (list cpx cpy x y)) " "))))
(define/contract (rect this x y w h)
(number? number? number? number? . ->m . object?)
(send this addContent (format "~a re" (string-join (map number (list x y w h)) " "))))
(define/contract (ellipse this x y r1 [r2 r1])
((number? number? number?) (number?) . ->*m . object?)
;; based on http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas/2173084#2173084

Loading…
Cancel
Save