export function isColor(color: Color | GlobalColorsString): color is Color {
  return typeof color === 'object' && 'hex' in color;
}

export function getColorString(color: Color | GlobalColorsString | string): string {
  if (typeof color !== 'string' && isColor(color)) {
    return color.hex;
  }

  return color;
}

export function calculateFontColor(rgbaColor: RGBAColor): string {
  const brightness = (0.299 * rgbaColor.r + 0.587 * rgbaColor.g + 0.114 * rgbaColor.b) / 255;
  return brightness < 0.5 ? '#ffffff' : '#000000';
}
