demos/Collage/fabric.js
function(otherColor) {
      if (!(otherColor instanceof Color)) {
        otherColor = new Color(otherColor);
      }

      var result = [],
          alpha = this.getAlpha(),
          otherAlpha = 0.5,
          source = this.getSource(),
          otherSource = otherColor.getSource();

      for (var i = 0; i < 3; i++) {
        result.push(Math.round((source[i] * (1 - otherAlpha)) + (otherSource[i] * otherAlpha)));
      }

      result[3] = alpha;
      this.setSource(result);
      return this;
    }
function(otherColor) {
      if (!(otherColor instanceof Color)) {
        otherColor = new Color(otherColor);
      }

      var result = [],
          alpha = this.getAlpha(),
          otherAlpha = 0.5,
          source = this.getSource(),
          otherSource = otherColor.getSource();

      for (var i = 0; i < 3; i++) {
        result.push(Math.round((source[i] * (1 - otherAlpha)) + (otherSource[i] * otherAlpha)));
      }

      result[3] = alpha;
      this.setSource(result);
      return this;
    }
function ( otherColor ) { if ( ! ( otherColor instanceof Color ) ) { otherColor = new Color ( otherColor ) ; } var result = [ ] , alpha = this . getAlpha ( ) , otherAlpha = 0.5 , source = this . getSource ( ) , otherSource = otherColor . getSource ( ) ; for ( var i = 0 ; i < 3 ; i ++ ) { result . push ( Math . round ( ( source [ i ] * ( 1 - otherAlpha ) ) + ( otherSource [ i ] * otherAlpha ) ) ) ; } result [ 3 ] = alpha ; this . setSource ( result ) ; return this ; }
Overlays color with another color
@method overlayWith
@param {String|fabric.Color} otherColor
@return {fabric.Color} thisArg
Overlays color with another color