diff --git a/collects/racket/draw/private/dc.rkt b/collects/racket/draw/private/dc.rkt index bdb94dc78a..028d329cd2 100644 --- a/collects/racket/draw/private/dc.rkt +++ b/collects/racket/draw/private/dc.rkt @@ -787,67 +787,68 @@ (let ([st (send brush get-stipple)] [col (send brush get-color)] [gradient (send brush get-gradient)]) - (if gradient - (make-gradient-pattern cr gradient) - (if st - (install-stipple st col s - (lambda () brush-stipple-s) - (lambda (v) (set! brush-stipple-s v) v)) - (let ([horiz (lambda (cr2) - (cairo_move_to cr2 0 3.5) - (cairo_line_to cr2 12 3.5) - (cairo_move_to cr2 0 7.5) - (cairo_line_to cr2 12 7.5) - (cairo_move_to cr2 0 11.5) - (cairo_line_to cr2 12 11.5))] - [vert (lambda (cr2) - (cairo_move_to cr2 3.5 0) - (cairo_line_to cr2 3.5 12) - (cairo_move_to cr2 7.5 0) - (cairo_line_to cr2 7.5 12) - (cairo_move_to cr2 11.5 0) - (cairo_line_to cr2 11.5 12))] - [bdiag (lambda (cr2) - (for ([i (in-range -2 3)]) - (let ([y (* i 6)]) - (cairo_move_to cr2 -1 (+ -1 y)) - (cairo_line_to cr2 13 (+ 13 y)))))] - [fdiag (lambda (cr2) - (for ([i (in-range -2 3)]) - (let ([y (* i 6)]) - (cairo_move_to cr2 13 (+ -1 y)) - (cairo_line_to cr2 -1 (+ 13 y)))))]) - - (case s - [(horizontal-hatch) - (make-pattern-surface - cr col - horiz)] - [(vertical-hatch) - (make-pattern-surface - cr col - vert)] - [(cross-hatch) - (make-pattern-surface - cr col - (lambda (cr) (horiz cr) (vert cr)))] - [(bdiagonal-hatch) - (make-pattern-surface - cr col - bdiag)] - [(fdiagonal-hatch) - (make-pattern-surface - cr col - fdiag)] - [(crossdiag-hatch) - (make-pattern-surface - cr col - (lambda (cr) (bdiag cr) (fdiag cr)))] - [else - (install-color cr - (if (eq? s 'hilite) hilite-color col) - alpha - #f)]))))) + (if (and gradient + (not (collapse-bitmap-b&w?))) + (make-gradient-pattern cr gradient) + (if st + (install-stipple st col s + (lambda () brush-stipple-s) + (lambda (v) (set! brush-stipple-s v) v)) + (let ([horiz (lambda (cr2) + (cairo_move_to cr2 0 3.5) + (cairo_line_to cr2 12 3.5) + (cairo_move_to cr2 0 7.5) + (cairo_line_to cr2 12 7.5) + (cairo_move_to cr2 0 11.5) + (cairo_line_to cr2 12 11.5))] + [vert (lambda (cr2) + (cairo_move_to cr2 3.5 0) + (cairo_line_to cr2 3.5 12) + (cairo_move_to cr2 7.5 0) + (cairo_line_to cr2 7.5 12) + (cairo_move_to cr2 11.5 0) + (cairo_line_to cr2 11.5 12))] + [bdiag (lambda (cr2) + (for ([i (in-range -2 3)]) + (let ([y (* i 6)]) + (cairo_move_to cr2 -1 (+ -1 y)) + (cairo_line_to cr2 13 (+ 13 y)))))] + [fdiag (lambda (cr2) + (for ([i (in-range -2 3)]) + (let ([y (* i 6)]) + (cairo_move_to cr2 13 (+ -1 y)) + (cairo_line_to cr2 -1 (+ 13 y)))))]) + + (case s + [(horizontal-hatch) + (make-pattern-surface + cr col + horiz)] + [(vertical-hatch) + (make-pattern-surface + cr col + vert)] + [(cross-hatch) + (make-pattern-surface + cr col + (lambda (cr) (horiz cr) (vert cr)))] + [(bdiagonal-hatch) + (make-pattern-surface + cr col + bdiag)] + [(fdiagonal-hatch) + (make-pattern-surface + cr col + fdiag)] + [(crossdiag-hatch) + (make-pattern-surface + cr col + (lambda (cr) (bdiag cr) (fdiag cr)))] + [else + (install-color cr + (if (eq? s 'hilite) hilite-color col) + alpha + #f)]))))) (cairo_fill_preserve cr)))) (when pen? (let ([s (send pen get-style)]) diff --git a/collects/scribblings/draw/brush-class.scrbl b/collects/scribblings/draw/brush-class.scrbl index 9bebc6120f..4bdaffb911 100644 --- a/collects/scribblings/draw/brush-class.scrbl +++ b/collects/scribblings/draw/brush-class.scrbl @@ -17,14 +17,16 @@ In addition to its color and style, a brush can have a stipple bitmap. As an alternative to a color, style, and stipple, a brush can have a gradient that is a @racket[linear-gradient%] or - @racket[radial-gradient%]. For each point in a drawing destination, a - gradient associates a color to the point based on starting and ending - colors and starting and ending lines (for a linear gradient) or - circles (for a radial gradient). A gradient-assigned color is applied - for each point is that touched when drawing with the brush. + @racket[radial-gradient%]. When a brush has a gradient and the target + for drawing is not monochrome, then other brush settings are + ignored. With a gradient, for each point in a drawing destination, + the gradient associates a color to the point based on starting and + ending colors and starting and ending lines (for a linear gradient) + or circles (for a radial gradient); a gradient-assigned color is + applied for each point that is touched when drawing with the brush. A brush's style is one of the following (but is ignored if the brush - has a gradient): + has a gradient and the target is not monochrome): @itemize[ @@ -115,7 +117,9 @@ Gets the stipple bitmap, or @scheme[#f] if the brush has no stipple. } @defmethod[(get-gradient) - (or/c (is-a?/c gradient<%>) #f)]{ + (or/c (is-a?/c linear-gradient%) + (is-a?/c radial-gradient%) + #f)]{ Gets the gradient, or @scheme[#f] if the brush has no gradient. diff --git a/collects/scribblings/draw/linear-gradient-class.scrbl b/collects/scribblings/draw/linear-gradient-class.scrbl index 3e24050949..622a831e9f 100644 --- a/collects/scribblings/draw/linear-gradient-class.scrbl +++ b/collects/scribblings/draw/linear-gradient-class.scrbl @@ -24,7 +24,7 @@ Colors transitions are based on a line, where colors are assigned to [y0 real?] [x1 real?] [y1 real?] - [stops (listof/c (list/c (real-in 0 1) (is-a?/c color%)))])]{ + [stops (listof (list/c (real-in 0 1) (is-a?/c color%)))])]{ Creates a linear gradient with a line from (@racket[x0], @racket[y0]) to end point (@racket[x1], @racket[y1]). The @racket[stops] list @@ -70,7 +70,7 @@ Returns the gradient's control line as @racket[_x0], @racket[_y0], } @defmethod[(get-stops) - (listof/c (list/c (real-in/c 0 1) (is-a?/c color%)))]{ + (listof (list/c (real-in/c 0 1) (is-a?/c color%)))]{ Returns the gradient's list of color stops. diff --git a/collects/scribblings/draw/radial-gradient-class.scrbl b/collects/scribblings/draw/radial-gradient-class.scrbl index 19d34c6b89..68027b4a31 100644 --- a/collects/scribblings/draw/radial-gradient-class.scrbl +++ b/collects/scribblings/draw/radial-gradient-class.scrbl @@ -24,7 +24,7 @@ Colors transitions are based on two circles and the sequence of circles that [x1 real?] [y1 real?] [r1 real?] - [stops (listof/c (list/c (real-in 0 1) (is-a?/c color%)))])]{ + [stops (listof (list/c (real-in 0 1) (is-a?/c color%)))])]{ Creates a radial gradient with the starting circle as the one with radius @racket[r0] centered at (@racket[x0], @racket[y0]) and the @@ -68,7 +68,7 @@ Returns the gradient's boundary circles as @racket[_x0], @racket[_y0], } @defmethod[(get-stops) - (listof/c (list/c (real-in 0 1) (is-a?/c color%)))]{ + (listof (list/c (real-in 0 1) (is-a?/c color%)))]{ Returns the gradient's list of color stops.