-
Notifications
You must be signed in to change notification settings - Fork 779
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(color-contrast): properly blend multiple alpha colors (#3193)
* fix(color-contrast): properly blend multiple alpha colors * revert shadow * add back shadow color flatten * fix * fix ie11 * type * typo
- Loading branch information
Showing
9 changed files
with
365 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import Color from './color'; | ||
|
||
/** | ||
* Combine the two given shadow colors according to alpha blending. | ||
* @method flattenColors | ||
* @memberof axe.commons.color.Color | ||
* @instance | ||
* @param {Color} fgColor Foreground color | ||
* @param {Color} bgColor Background color | ||
* @return {Color} Blended color | ||
*/ | ||
function flattenColors(fgColor, bgColor) { | ||
var alpha = fgColor.alpha; | ||
var r = (1 - alpha) * bgColor.red + alpha * fgColor.red; | ||
var g = (1 - alpha) * bgColor.green + alpha * fgColor.green; | ||
var b = (1 - alpha) * bgColor.blue + alpha * fgColor.blue; | ||
var a = fgColor.alpha + bgColor.alpha * (1 - fgColor.alpha); | ||
|
||
return new Color(r, g, b, a); | ||
} | ||
|
||
export default flattenColors; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.