 Blend - Maple Help

ColorTools

 Blend
 generate a blend of colors Calling Sequence Blend(color1..color2, value, options) Blend(colorlist, value, options) Parameters

 color1,color2 - colors in formats recognized by ColorTools colorlist - list or Array of colors in formats recognized by ColorTools value - (optional) value between 0 and 1; sample point options - (optional) equation(s) of the form option=value where option is one of space, markers, or displayable Options

 • displayable=truefalse := false
 If this keyword is given then each output color will be displayable, and when represented in the "RGB" color space all three component values of each output color will be between 0 and 1. The default value for this option is false.
 • markers=list or Array
 • The parameter thresholds corresponding to each of the specified input colors.
 • space=string
 • The color space in which to compute the intermediate colors; if unspecified, this is inferred from the colors spaces of the input when possible, defaulting to "RGB" otherwise. Description

 • The Blend command generates a blend of the specified colors.
 • The first parameter specifies the colors to blend. This may be a range color1..color2 or a list or Array of colors.
 • The second parameter value specifies a point at which to interpolate.
 • For example, Blend(red..blue,3/4) will produce a blend of 3/4 blue and 1/4 red. Examples

 > $\mathrm{with}\left(\mathrm{ColorTools}\right):$

Interpolate linearly between white and blue in the default color space.

 > $\mathrm{Blend}\left(\mathrm{white}..\mathrm{blue},\frac{2}{3}\right)$
 ${⟨}\colorbox[rgb]{0.333333333333333,0.333333333333333,1}{RGB : 0.333 0.333 1}{⟩}$ (1)

Interpolate linearly between white and blue in the HSV color space.

 > $\mathrm{Blend}\left(\mathrm{white}..\mathrm{blue},\frac{2}{3},\mathrm{space}="HSV"\right)$
 ${⟨}\colorbox[rgb]{0.333333333333333,1,0.776470588235294}{HSV : 0.444 0.667 1}{⟩}$ (2)

Interpolate linearly between three colors: red, white, and green.

 > $\mathrm{Blend}\left(\left[\mathrm{red},\mathrm{white},\mathrm{green}\right],0.25\right)$
 ${⟨}\colorbox[rgb]{1,0.501960784313725,0.501960784313725}{RGB : 1 0.5 0.5}{⟩}$ (3)

Interpolate linearly with specified thresholds, marking all values <= 0.1 as red and all values >= 0.8 as green.

 > $f≔\mathrm{Blend}\left(\left[\mathrm{red},\mathrm{yellow},\mathrm{green}\right],\mathrm{markers}=\left[0.1,0.45,0.8\right]\right):$
 > $\mathrm{seq}\left(f\left(i\right),i=0..1,0.2\right)$
 ${⟨}\colorbox[rgb]{1,0,0}{{RGB : 1 0 0}}{⟩}{,}{⟨}\colorbox[rgb]{1,0.286274509803922,0}{RGB : 1 0.286 0}{⟩}{,}{⟨}\colorbox[rgb]{1,0.858823529411765,0}{RGB : 1 0.857 0}{⟩}{,}{⟨}\colorbox[rgb]{0.572549019607843,1,0}{RGB : 0.571 1 0}{⟩}{,}{⟨}\colorbox[rgb]{0,1,0}{RGB : 0 1 0}{⟩}{,}{⟨}\colorbox[rgb]{0,1,0}{RGB : 0 1 0}{⟩}$ (4)

The color halfway in the "Lab" color space between red and green is not displayable. Note that after conversion to the "RGB" color space the blue component is negative and so not between 0 and 1. This is the default behavior of the Blend command.

 > $c≔\mathrm{Blend}\left(\mathrm{red}..\mathrm{green},\frac{1}{2},\mathrm{space}="Lab",\mathrm{displayable}=\mathrm{false}\right)$
 ${c}{≔}{⟨}\colorbox[rgb]{0.784313725490196,0.670588235294118,0}{*Lab* : 70.5 -3.05 75.2}{⟩}$ (5)
 > $\mathrm{Color}\left("RGB",c\right)$
 ${⟨}\colorbox[rgb]{0.784313725490196,0.670588235294118,0}{*RGB* : 0.786 0.671 -0.0651}{⟩}$ (6)

The displayable option forces the result above to be a color that is displayable in the "RGB" color space. Note that the blue component is now between 0 and 1.

 > $c≔\mathrm{Blend}\left(\mathrm{red}..\mathrm{green},\frac{1}{2},\mathrm{space}="Lab",\mathrm{displayable}=\mathrm{true}\right)$
 ${c}{≔}{⟨}\colorbox[rgb]{0.784313725490196,0.670588235294118,0}{Lab : 70.5 -3.01 73.2}{⟩}$ (7)
 > $\mathrm{Color}\left("RGB",c\right)$
 ${⟨}\colorbox[rgb]{0.784313725490196,0.670588235294118,0}{RGB : 0.786 0.671 0}{⟩}$ (8) Compatibility

 • The ColorTools[Blend] command was introduced in Maple 2016.