mirror of
https://github.com/bend-n/fimg.git
synced 2024-12-22 02:28:19 -06:00
add Image::fill
This commit is contained in:
parent
5839881e25
commit
b7c91274c1
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "fimg"
|
||||
version = "0.4.28"
|
||||
version = "0.4.29"
|
||||
authors = ["bend-n <bend.n@outlook.com>"]
|
||||
license = "MIT"
|
||||
edition = "2021"
|
||||
|
|
|
@ -61,6 +61,20 @@ impl<const C: usize> Builder<Vec<u8>, C> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: Copy, const C: usize> Builder<Box<[T]>, C> {
|
||||
/// Fill this image with a certain pixel.
|
||||
/// ```
|
||||
/// # use fimg::Image;
|
||||
///
|
||||
/// // fill black
|
||||
/// Image::build(50, 50).fill([0, 0, 0, 255]);
|
||||
/// ```
|
||||
pub fn fill(self, with: [T; C]) -> Image<Box<[T]>, C> {
|
||||
Image::build(self.width, self.height)
|
||||
.buf((0..self.width * self.height).flat_map(|_| with).collect())
|
||||
}
|
||||
}
|
||||
|
||||
/// seals the [`Buffer`] trait
|
||||
mod buf {
|
||||
/// A valid buffer for use in the builder
|
||||
|
|
Loading…
Reference in a new issue