disable brush gradient when the target is monochrome

This commit is contained in:
Matthew Flatt 2011-01-04 17:31:34 -07:00
parent 6c3feabb52
commit 577755630a
4 changed files with 77 additions and 72 deletions

View File

@ -787,7 +787,8 @@
(let ([st (send brush get-stipple)]
[col (send brush get-color)]
[gradient (send brush get-gradient)])
(if gradient
(if (and gradient
(not (collapse-bitmap-b&w?)))
(make-gradient-pattern cr gradient)
(if st
(install-stipple st col s

View File

@ -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.

View File

@ -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.

View File

@ -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.