mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-12-12 02:57:22 +00:00
@@ -1074,6 +1074,30 @@ Color str2color(String str, [alpha = 0xFF]) {
|
||||
return Color((hash & 0xFF7FFF) | (alpha << 24));
|
||||
}
|
||||
|
||||
Color str2color2(String str, [alpha = 0xFF]) {
|
||||
List<Color> colorList = [
|
||||
Colors.red,
|
||||
Colors.green,
|
||||
Colors.blue,
|
||||
Colors.orange,
|
||||
Colors.yellow,
|
||||
Colors.purple,
|
||||
Colors.grey,
|
||||
Colors.cyan,
|
||||
Colors.lime,
|
||||
Colors.teal,
|
||||
Colors.pink,
|
||||
Colors.indigo,
|
||||
Colors.brown,
|
||||
];
|
||||
var hash = 0;
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
hash += str.codeUnitAt(i);
|
||||
}
|
||||
hash = hash % colorList.length;
|
||||
return colorList[hash].withAlpha(alpha);
|
||||
}
|
||||
|
||||
const K = 1024;
|
||||
const M = K * K;
|
||||
const G = M * K;
|
||||
|
||||
Reference in New Issue
Block a user