main
Matthew Butterick 7 years ago
parent 967b33aef5
commit 46b5b1e94c

@ -0,0 +1,34 @@
#lang pitfall/racket
(provide parse-svg-path)
(define (parse-svg-path doc path)
(define commands (parse path))
(apply-commands commands doc))
(define (parse path)
empty)
(define (apply-commands command doc)
(void))
(define parameters
(hash "A" 7
"a" 7
"C" 6
"c" 6
"H" 1
"h" 1
"L" 2
"l" 2
"M" 2
"m" 2
"Q" 4
"q" 4
"S" 4
"s" 4
"T" 2
"t" 2
"V" 1
"v" 1
"Z" 0
"z" 0))

@ -16,20 +16,19 @@
(send* doc [translate 0 200])
#|
;; curved path as svg path
(send* doc
[path "M 020 L 100160 Q 130200 150120 C 190-40 200200 300150 L 40090"]
[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]]
[polygon '(100 0) '(50 100) '(150 100)]
[stroke])
;; dashed circle
@ -41,6 +40,8 @@
[stroke]
[restore])
#|
;; filled circle
(send* doc
[save]

@ -1,72 +0,0 @@
%PDF-1.3
%ÿÿÿÿ
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
<<
/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
>>
endobj
3 0 obj
<<
/Length 126
>>
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
S
1 0 0 1 0 200 cm
endstream
endobj
6 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 7
0000000000 65535 f
0000000512 00000 n
0000000463 00000 n
0000000186 00000 n
0000000119 00000 n
0000000015 00000 n
0000000363 00000 n
trailer
<<
/Info 6 0 R
/Root 2 0 R
/Size 7
>>
startxref
569
%%EOF

@ -1,4 +1,5 @@
#lang pitfall/racket
(require "path.rkt")
(provide vector-mixin default-ctm-value)
(define (vector-mixin [% mixin-tester%])
@ -17,6 +18,7 @@
quadraticCurveTo
ellipse
circle
polygon
path
_windingRule
fill
@ -100,9 +102,19 @@
(ellipse this x y radius))
(define/contract (polygon this . points)
(() () #:rest (listof (list/c number? number?)) . ->*m . object?)
(when (pair? points)
(match-define (cons first-pt other-pts) points)
(apply moveTo this first-pt)
(for ([pt (in-list other-pts)])
(apply lineTo this pt))
(closePath this)))
(define/contract (path this path-data)
(string? . ->m . object?)
;(parse-svg-path this path-data)
(parse-svg-path this path-data)
this)

Loading…
Cancel
Save