Overview
Mixes two colors together according to a specified amount value between 0.0 and 1.0. This method performs RGB interpolation to blend the colors smoothly.Signature
Parameters
The first color as a hex string (e.g.,
'#FFFFFF'). This is the base color.The second color as a hex string (e.g.,
'#000000'). This color will be mixed into the base color.The mix amount from
0.0 to 1.0:0.0returnscolor1unchanged1.0returnscolor2unchanged0.5returns a 50/50 mix of both colors
color2 in the final mix.Returns
A hex color string representing the mixed color (e.g.,
'#808080').Example
Use Cases
Creating Custom Tints
Opacity Simulation
The mixing is performed in RGB color space using linear interpolation. Each RGB component is calculated independently:
R = R1 + (R2 - R1) × amountG = G1 + (G2 - G1) × amountB = B1 + (B2 - B1) × amount
Implementation Details
Implementation location:www/plugin.js:49-53
The method internally:
- Converts hex colors to RGB using
hexToRgb(lines 6-15) - Performs RGB interpolation with
_mixColor(lines 39-47) - Converts the result back to hex using
rgbToHex(lines 24-28)
Related Methods
mixColorElevation- Mix colors using Material Design elevation levelstintColors- Apply elevation tints to multiple colorstintSurfaceColors- Apply elevation tints to surface colors