-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented random placement in bitmap
- Loading branch information
1 parent
a38a202
commit e47ebbb
Showing
5 changed files
with
64 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ image = "*" | |
palette = "*" | ||
serenity = "*" | ||
anyhow = "*" | ||
itertools = "*" | ||
itertools = "*" | ||
rand = "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ mod indexed_chars; | |
mod text; | ||
mod image; | ||
mod rasterisable; | ||
mod ring_reader; | ||
pub use wordcloud::{wordcloud, Token}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#[derive(Clone)] | ||
pub struct RingReader<E: Clone + Copy> { | ||
data: Vec<E>, | ||
start: usize, | ||
end: usize, | ||
} | ||
|
||
impl<E: Clone + Copy> RingReader<E> { | ||
pub fn new(data: Vec<E>) -> Self { | ||
Self { | ||
end: data.len(), | ||
data: data, | ||
start: 0 | ||
} | ||
} | ||
|
||
pub fn next(&mut self) -> Option<E> { | ||
if self.start == self.end { | ||
return None | ||
} | ||
if self.start >= self.data.len() { | ||
self.start = 0; | ||
} | ||
let res = self.data[self.start]; | ||
self.start += 1; | ||
Some(res) | ||
} | ||
|
||
pub fn reset(&mut self) { | ||
self.end = if self.start == 0 { | ||
self.data.len() | ||
} else { | ||
self.start-1 | ||
}; | ||
} | ||
} |