A TypeScript package to perform the alpha blending of two colors based on the given mathematical formulas.
The blending is calculated using the following formulas:
For a detailed explanation, please refer to this article.
- Blend two colors with their respective alpha values.
- Get the resulting color in HEX format.
- Handle both HEX and RGBA input formats.
import { alphaBlend } from "@napolab/alpha-blend";
const foregroundColor = "#ff5733";
const backgroundColor = "rgba(255, 87, 51, 0.5)";
const blendedColor = alphaBlend(foregroundColor, backgroundColor);
// Outputs: '#ff5733ff'.
blendedColor;
To install the package, use:
npm install @napolab/alpha-blend
or
yarn add @napolab/alpha-blend
This project is licensed under the MIT License.