Skip to content

Commit

Permalink
fix(colors): blend method return type should be same as input (#6107)
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkeye64 authored and rstoenescu committed Jan 14, 2020
1 parent c8b1028 commit cb70fff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/src/pages/quasar-utils/color-utils.md
Expand Up @@ -60,9 +60,10 @@ Returns a value between 0 and 255. A value of < 128 would be considered a dark c


Calculates the [blend](https://www.w3.org/TR/compositing-1/#simplealphacompositing) of two colors. Calculates the [blend](https://www.w3.org/TR/compositing-1/#simplealphacompositing) of two colors.


Accepts a HEX/A String, a RGB/A String or a RGB/A Object as `fgColor`/`bgColor`. Accepts a HEX/A String or a RGB/A Object as `fgColor`/`bgColor`.
If the alpha channel of the `fgColor` is completely opaque, then the result will be the `fgColor`. If the alpha channel of the `fgColor` is completely opaque, then the result will be the `fgColor`.
If the alpha channel of the `bgColor` is completely opaque, then the resulting blended color will also be opaque. If the alpha channel of the `bgColor` is completely opaque, then the resulting blended color will also be opaque.
Returns the same type as input for fgColor.


### updateAlpha (color, offset) ### updateAlpha (color, offset)


Expand Down
5 changes: 4 additions & 1 deletion ui/src/utils/colors.js
Expand Up @@ -252,7 +252,10 @@ export function blend (fgColor, bgColor) {
g = Math.round(((g1 * a1 + g2 * a2 * (1 - a1)) / a) * 255), g = Math.round(((g1 * a1 + g2 * a2 * (1 - a1)) / a) * 255),
b = Math.round(((b1 * a1 + b2 * a2 * (1 - a1)) / a) * 255) b = Math.round(((b1 * a1 + b2 * a2 * (1 - a1)) / a) * 255)


return rgbToHex({ r, g, b, a: Math.round(a * 100) }) const ret = { r, g, b, a: Math.round(a * 100) }
return typeof fgColor === 'string'
? rgbToHex(ret)
: ret
} }


export function changeAlpha (color, offset) { export function changeAlpha (color, offset) {
Expand Down

0 comments on commit cb70fff

Please sign in to comment.