WOLFRAM

Blend[{col1,col2},x]

gives a color obtained by blending a fraction of color col1 and of color col2.

Blend[{col1,col2,col3,},x]

linearly interpolates between colors coli as x varies from 0 to 1.

Blend[{{x1,col1},{x2,col2},},x]

interpolates to give coli when x=xi.

Blend[{col1,col2,},{u1,u2,}]

blends all the coli, using fraction ui of color coli.

Blend[{image1,image2,},]

blends pixel values of 2D or 3D images imagei.

Details

  • Blend implements additive color mixing as appropriate for colored light sources or lightgenerating displays.
  • In Blend[{col1,,coln},{u1,,un}], the ui are normalized to have total 1. »
  • Blend[{col1,col2,}] blends equal fractions of all the coli.
  • In Blend[{image1,image2},x], if image1 and image2 are of different dimensions, linear interpolation of the dimensions is used.
  • Blend[{image,col},x] blends every pixel of image with the color col.
  • In Blend[{image1,col1,,coln,image2},x], coli is interpreted as an image whose dimensions are taken from a linear interpolation between dimensions of image1 and image2.

Examples

open allclose all

Basic Examples  (4)Summary of the most common use cases

Blend two colors by fractions:

Out[1]=1

Generate an array of blended colors ranging from red to blue:

Out[1]=1

Represent the height as a blend from yellow to purple:

Out[1]=1

Blend pixels of an image with a color:

Out[1]=1

Scope  (12)Survey of the scope of standard use cases

Colors  (6)

Average two colors equally:

Out[1]=1

Color a graphic:

Out[1]=1

Linear interpolation between two colors:

Out[1]=1

Linear interpolation between colors with opacity:

Out[1]=1
Out[2]=2

Linear interpolation between multiple colors uniformly:

Out[1]=1

Linear interpolation between colors at specific values:

Out[1]=1

Blending colors with equal weights:

Out[1]=1

Blending colors with specified weights:

Out[2]=2
Out[3]=3

Images  (6)

Linear interpolation between pixels of an image and a color:

Out[1]=1

Linear interpolation of an image and a color at a specific value:

Out[1]=1

Linear interpolation of two images:

Out[1]=1

Linear interpolation of two images of different dimensions:

Out[1]=1

Blend images and their alpha channels:

Out[1]=1

Blend of 3D images:

Out[1]=1

Applications  (2)Sample problems that can be solved with this function

Use Blend to construct a ColorFunction from base colors:

Out[1]=1
Out[4]=4
Out[5]=5

Combine multiple images with different exposures into one image:

Out[1]=1

Properties & Relations  (7)Properties of the function, and connections to other functions

The weights are always normalized, so that the sum becomes 1:

Out[1]=1

The position values are always sorted:

Out[1]=1

When colors are specified using the same color space, that space is used for interpolation:

Out[1]=1

When colors are specified using different color spaces, interpolation happens in the RGB space:

Out[2]=2

Lighter is a special case of Blend:

Out[1]=1

Darker is a special case of Blend:

Out[1]=1

ColorData contains a large number of predefined Blend colors called "Gradients":

Out[2]=2
Out[3]=3

Gradients can be called by their names only:

Out[4]=4

Polygon supports equal-weight blending of VertexColors:

Out[1]=1
Out[2]=2

Possible Issues  (2)Common pitfalls and unexpected behavior

Values outside of the 0, 1 range will be clipped:

Out[1]=1

In plot functions, use ColorFunctionScaling to control global scaling of variables:

Out[2]=2

Different colors can be given at a single position to generate discontinuities:

Out[1]=1

Interactive Examples  (4)Examples with interactive outputs

Continuous blend between two images:

Out[1]=1

Linear interpolation of two images with different dimensions:

Out[1]=1

Blend of multiple images while going through a white background between each two images:

Out[1]=1

Interactive representation of the linear interpolation of multiple colors:

Out[1]=1

Neat Examples  (2)Surprising or curious use cases

Use Blend with plots to generate synthesized textures:

Out[1]=1
Out[2]=2

Simulated colors of stars:

Out[1]=1
Wolfram Research (2007), Blend, Wolfram Language function, https://reference.wolfram.com/language/ref/Blend.html (updated 2014).
Wolfram Research (2007), Blend, Wolfram Language function, https://reference.wolfram.com/language/ref/Blend.html (updated 2014).

Text

Wolfram Research (2007), Blend, Wolfram Language function, https://reference.wolfram.com/language/ref/Blend.html (updated 2014).

Wolfram Research (2007), Blend, Wolfram Language function, https://reference.wolfram.com/language/ref/Blend.html (updated 2014).

CMS

Wolfram Language. 2007. "Blend." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/Blend.html.

Wolfram Language. 2007. "Blend." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/Blend.html.

APA

Wolfram Language. (2007). Blend. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Blend.html

Wolfram Language. (2007). Blend. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Blend.html

BibTeX

@misc{reference.wolfram_2025_blend, author="Wolfram Research", title="{Blend}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/Blend.html}", note=[Accessed: 27-March-2025 ]}

@misc{reference.wolfram_2025_blend, author="Wolfram Research", title="{Blend}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/Blend.html}", note=[Accessed: 27-March-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_blend, organization={Wolfram Research}, title={Blend}, year={2014}, url={https://reference.wolfram.com/language/ref/Blend.html}, note=[Accessed: 27-March-2025 ]}

@online{reference.wolfram_2025_blend, organization={Wolfram Research}, title={Blend}, year={2014}, url={https://reference.wolfram.com/language/ref/Blend.html}, note=[Accessed: 27-March-2025 ]}