FurryChat/lib/utils/string_color.dart

22 lines
517 B
Dart
Raw Normal View History

2020-01-18 12:22:22 +00:00
import 'package:flutter/material.dart';
extension StringColor on String {
Color get color {
2020-06-25 07:15:53 +00:00
var number = 0.0;
for (var i = 0; i < length; i++) {
number += codeUnitAt(i);
}
number = (number % 10) * 25.5;
return HSLColor.fromAHSL(1, number, 1, 0.35).toColor();
}
Color get lightColor {
2020-05-13 13:58:59 +00:00
var number = 0.0;
for (var i = 0; i < length; i++) {
number += codeUnitAt(i);
2020-01-18 12:22:22 +00:00
}
number = (number % 10) * 25.5;
2020-06-24 07:42:28 +00:00
return HSLColor.fromAHSL(1, number, 1, 0.66).toColor();
2020-01-18 12:22:22 +00:00
}
}