mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-16 09:39:10 +08:00
5dd072d3a0
* chore: use fast * chore: tmp of it * test: update snapshot * fix: demo * chore: fix warning * fix: test * chore: fix ts * chore: fix lint * test: update snapshot * chore: use proxy * test: coverage
21 lines
653 B
TypeScript
21 lines
653 B
TypeScript
import type { ColorGenInput } from '@rc-component/color-picker';
|
|
|
|
import { AggregationColor } from './color';
|
|
|
|
export const generateColor = (color: ColorGenInput<AggregationColor>): AggregationColor => {
|
|
if (color instanceof AggregationColor) {
|
|
return color;
|
|
}
|
|
return new AggregationColor(color);
|
|
};
|
|
|
|
export const getRoundNumber = (value: number) => Math.round(Number(value || 0));
|
|
|
|
export const getAlphaColor = (color: AggregationColor) => getRoundNumber(color.toHsb().a * 100);
|
|
|
|
export const genAlphaColor = (color: AggregationColor, alpha?: number) => {
|
|
const hsba = color.toHsb();
|
|
hsba.a = alpha || 1;
|
|
return generateColor(hsba);
|
|
};
|