mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-03-12 07:41:02 +03:00
feat: show my cursor (#12745)
Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
@@ -2040,6 +2040,22 @@ pub async fn get_ipv6_socket() -> Option<(Arc<UdpSocket>, bytes::Bytes)> {
|
||||
None
|
||||
}
|
||||
|
||||
// The color is the same to `str2color()` in flutter.
|
||||
pub fn str2color(s: &str, alpha: u8) -> u32 {
|
||||
let bytes = s.as_bytes();
|
||||
// dart code `160 << 16 + 114 << 8 + 91` results `0`.
|
||||
let mut hash: u32 = 0;
|
||||
for &byte in bytes {
|
||||
let code = byte as u32;
|
||||
hash = code.wrapping_add((hash << 5).wrapping_sub(hash));
|
||||
}
|
||||
|
||||
hash = hash % 16777216;
|
||||
let rgb = hash & 0xFF7FFF;
|
||||
|
||||
(alpha as u32) << 24 | rgb
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user