no init color

main
Matthew Butterick 6 years ago
parent 2cfc6965c7
commit 0cb5b04856

@ -41,35 +41,30 @@
(define (color-mixin [% mixin-tester%]) (define (color-mixin [% mixin-tester%])
(class % (class %
(super-new) (super-new)
(field [_opacityRegistry #f] (field [_opacityRegistry (mhash)]
[_opacityCount #f] [_opacityCount 0]
[_gradCount #f] [_gradCount 0]
[_fillColor #f]) [_fillColor #f])
(define/public (initColor) (define/public (_setColor color-in stroke)
(set! _opacityRegistry (mhash)) (define color (_normalizeColor color-in))
(set! _opacityCount 0) (define op (if stroke "SCN" "scn"))
(set! _gradCount 0)) (cond
[(not color)]
(define/public (_setColor color stroke) #;[(is-a? color PDFGradient)
(let ([color (_normalizeColor color)] (_setColorSpace "Pattern" stroke)
[op (if stroke "SCN" "scn")]) (send color apply op)
(cond #t] ; todo
[(not color)] [else
#;[(is-a? color PDFGradient) (define color-space (case (length color)
(_setColorSpace "Pattern" stroke) [(4) "DeviceCMYK"]
(send color apply op) [(3) "DeviceRGB"]
#t] ; todo [else (raise-argument-error '_setColor "color of length 3 or 4" color)]))
[else (_setColorSpace color-space stroke)
(define color-space (case (length color)
[(4) "DeviceCMYK"]
[(3) "DeviceRGB"]
[else (raise-argument-error '_setColor "color of length 3 or 4" color)]))
(_setColorSpace color-space stroke)
;; 181126 don't round, to be consistent with pdfkit behavior ;; 181126 don't round, to be consistent with pdfkit behavior
(send this addContent (format "~a ~a" (string-join (map (λ (num) (number num #:round #false)) color) " ") op)) (send this addContent (format "~a ~a" (string-join (map (λ (num) (number num #:round #false)) color) " ") op))
#t]))) #t]))
(define/public (_setColorSpace space stroke) (define/public (_setColorSpace space stroke)
(define op (if stroke "CS" "cs")) (define op (if stroke "CS" "cs"))

@ -37,7 +37,6 @@
'CreationDate (seconds->date (if (test-mode) 0 (current-seconds)) #f))]) 'CreationDate (seconds->date (if (test-mode) 0 (current-seconds)) #f))])
;; initialize mixins ;; initialize mixins
(send this initColor)
(send this initVector) (send this initVector)
(inherit-field _ctm) (inherit-field _ctm)
(send this initFonts) (send this initFonts)

Loading…
Cancel
Save