main
Matthew Butterick 7 years ago
parent 46b5b1e94c
commit 3943e36ebe

@ -40,18 +40,18 @@
[stroke]
[restore])
#|
;; filled circle
(send* doc
[save]
[translate 400 0]
[circle 100 50 50]
[lineWidth 3]
[fillOpacity 0 [8]]
[fillOpacity 0.8]
[fillAndStroke "red" "#900"]
[restore])
#|
(send* doc [translate 0 200])
;; these examples are easier to see with a large line width

@ -12,8 +12,9 @@
save
restore
closePath
lineTo
dash
moveTo
lineTo
bezierCurveTo
quadraticCurveTo
ellipse
@ -56,6 +57,23 @@
(send this addContent "h"))
(define/contract (dash this length [options (mhash)])
(((or/c number? (listof number?) #f)) (hash?) . ->*m . object?)
(cond
[length
(cond
[(list? length)
(send this addContent
(format "[~a] ~a d"
(string-join (map number length) " ")
(hash-ref options 'phase 0)))]
[else
(define space (hash-ref options 'space length))
(define phase (hash-ref options 'phase 0))
(send this addContent (format "[~a ~a] ~a d" (number length) (number space) (number phase)))])]
[else this]))
(define/contract (moveTo this x y)
(number? number? . ->m . object?)
(send this addContent (format "~a ~a m" x y)))
@ -104,12 +122,13 @@
(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)))
(cond
[(pair? points)
(apply moveTo this (car points))
(for ([pt (in-list (cdr points))])
(apply lineTo this pt))
(closePath this)]
[else this]))
(define/contract (path this path-data)

Loading…
Cancel
Save