Skip to content
Permalink
Browse files

fix(colors): blend method return type should be same as input (#6107)

  • Loading branch information
hawkeye64 authored and rstoenescu committed Jan 14, 2020
1 parent c8b1028 commit cb70fffb5852a16245d20ab17065dd5062a2abe5
Showing with 6 additions and 2 deletions.
  1. +2 −1 docs/src/pages/quasar-utils/color-utils.md
  2. +4 −1 ui/src/utils/colors.js
@@ -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.

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 `bgColor` is completely opaque, then the resulting blended color will also be opaque.
Returns the same type as input for fgColor.

### updateAlpha (color, offset)

@@ -252,7 +252,10 @@ export function blend (fgColor, bgColor) {
g = Math.round(((g1 * a1 + g2 * 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) {

0 comments on commit cb70fff

Please sign in to comment.
You can’t perform that action at this time.