function mixTwoRgba (colors, range = 50) { let arr = [], i = 0 for (let i = 0; i < 4; i++) { let round = (i == 3) ? (x) => x : Math.round arr[i] = round( (colors[0][i] + ( (colors[1][i] - colors[0][i]) * range / 100 )) ) } return `rgba(${arr})` } console.log( mixTwoRgba([[234, 126, 53, 0.5], [115, 172, 77, 0.2]], 75) )