diff --git a/Cargo.toml b/Cargo.toml index a84d271..f9bc1e6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fimg" -version = "0.4.28" +version = "0.4.29" authors = ["bend-n "] 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 Builder, C> { } } +impl Builder, 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, 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