mirror of
https://github.com/ricoriedel/wipe.git
synced 2025-04-11 01:48:26 +00:00
16 lines
332 B
Rust
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()
|
|
}
|
|
} |