public static Expression mix ( Generator generator , FunctionCall input ) { Color color1 = input . getExpectedColorParam ( 0 ) ; Color color2 = input . getExpectedColorParam ( 1 ) ; float weight = input . getParameters ( ) . size ( ) > 2 ? input . getExpectedFloatParam ( 2 ) : 0.5f ; return new Color ( ( int ) Math . round ( color1 . getR ( ) * weight + color2 . getR ( ) * ( 1.0 - weight ) ) , ( int ) Math . round ( color1 . getG ( ) * weight + color2 . getG ( ) * ( 1.0 - weight ) ) , ( int ) Math . round ( color1 . getB ( ) * weight + color2 . getB ( ) * ( 1.0 - weight ) ) , ( float ) ( color1 . getA ( ) * weight + color2 . getA ( ) * ( 1.0 - weight ) ) ) ; }
Calculates the weighted arithmetic mean of two colors .