resolve method

({Color? frameColor, Color? strokeColor, Color textColor}) resolve(
  1. Color colour
)

The glyph, frame and outline colours this style makes of colour.

Implementation

({Color textColor, Color? frameColor, Color? strokeColor}) resolve(
  Color colour,
) {
  // Rec.709 luma of the 0–1 sRGB channels as-is, not linearized.
  final lightness = 0.2126 * colour.r + 0.7152 * colour.g + 0.0722 * colour.b;
  final onColour = lightness > 0.99 ? Color(0xFF000000) : Color(0xFFFFFFFF);
  return switch (this) {
    TextEntityStyle.regular => (
      textColor: colour,
      frameColor: null,
      strokeColor: null,
    ),
    TextEntityStyle.filled => (
      textColor: onColour,
      frameColor: colour,
      strokeColor: null,
    ),
    TextEntityStyle.semi => (
      textColor: colour,
      frameColor: lightness > 0.7 ? Color(0xBF000000) : Color(0xBFFFFFFF),
      strokeColor: null,
    ),
    TextEntityStyle.stroke => (
      textColor: onColour,
      frameColor: null,
      strokeColor: colour,
    ),
  };
}