fast image operations
| -rw-r--r-- | Cargo.toml | 2 | ||||
| -rw-r--r-- | src/builder.rs | 14 |
2 files changed, 15 insertions, 1 deletions
@@ -1,6 +1,6 @@ [package] name = "fimg" -version = "0.4.28" +version = "0.4.29" authors = ["bend-n <[email protected]>"] license = "MIT" edition = "2021" diff --git a/src/builder.rs b/src/builder.rs index bff5e7c..6ae970e 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -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 |