1
mirror of https://github.com/ricoriedel/wipe.git synced 2025-04-11 01:48:26 +00:00
wipe/src/char.rs
2022-04-02 17:20:52 +02:00

16 lines
332 B
Rust

pub struct CharSampler {
chars: String
}
impl CharSampler {
pub fn new(chars: String) -> Self {
Self { chars }
}
pub fn sample(&self, level: f32) -> char {
let pos = level * self.chars.chars().count() as f32;
let index = pos as usize;
self.chars.chars().nth(index).unwrap()
}
}