diff --git a/src/random.ts b/src/random.ts index 9620a78..6e0b0c4 100644 --- a/src/random.ts +++ b/src/random.ts @@ -1,9 +1,11 @@ import { Colord } from "./colord"; -export const random = (): Colord => { +export const random = (old?: Colord): Colord => { + const { r, g, b , a } = old?.toRgb() ?? { r: 255, g: 255, b: 255 , a: 1 }; return new Colord({ - r: Math.random() * 255, - g: Math.random() * 255, - b: Math.random() * 255, + r: r * 255, + g: g * 255, + b: b * 255, + a, }); };