INNER CODE UNIT · Dart

basicColorsFromHex

Ephenodrom/Dart-Basic-Utils · lib/src/ColorUtils.dart:139

  static Map<String, int> basicColorsFromHex(String hex) {
    hex = fillUpHex(hex);

    if (!hex.startsWith('#')) {
      hex = '#' + hex;
    }

    var R = int.parse(hex.substring(1, 3), radix: 16);
    var G = int.parse(hex.substring(3, 5), radix: 16);
    var B = int.parse(hex.substring(5, 7), radix: 16);
    return {BASIC_COLOR_RED: R, BASIC_COLOR_GREEN: G, BASIC_COLOR_BLUE: B};
  }

  ///
  /// Calculates the relative luminance for the given [red], [green], [blue] values.
  ///
  /// The returned value is between 0 and 1 with the given [decimals].
  ///

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…