From 4b790a619272b523047b5fdbb977f5cfe676cec7 Mon Sep 17 00:00:00 2001 From: Robson Date: Thu, 23 Jul 2020 22:26:02 +0100 Subject: [PATCH] New initial image type: random monochrome squares --- GlitchGenerator/InitialImages.cs | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/GlitchGenerator/InitialImages.cs b/GlitchGenerator/InitialImages.cs index 767e65f..04f1e94 100644 --- a/GlitchGenerator/InitialImages.cs +++ b/GlitchGenerator/InitialImages.cs @@ -16,6 +16,7 @@ internal List GetInitialImageTypes() new InitialImageNoiseBinary(), new InitialImageNoiseColour(), new InitialImageNoiseMonochrome(), + new InitialImageNoiseMonochromeSquares(), new InitialImageShapes(), }; } @@ -119,7 +120,7 @@ internal class InitialImageNoiseColour : IInitialImage { public string GetName() { - return "Noise, Colour"; + return "Noise, Pixels, Colour"; } public bool IsPossible() @@ -137,7 +138,7 @@ internal class InitialImageNoiseMonochrome : IInitialImage { public string GetName() { - return "Noise, Monochrome"; + return "Noise, Pixels, Monochrome"; } public bool IsPossible() @@ -151,6 +152,32 @@ public Bitmap GenerateImage(int width, int height, bool isPreview) } } + internal class InitialImageNoiseMonochromeSquares : IInitialImage + { + public string GetName() + { + return "Noise, Squares, Monochrome"; + } + + public bool IsPossible() + { + return true; + } + + public Bitmap GenerateImage(int width, int height, bool isPreview) + { + var bitmap = new Bitmap(width, height); + for (int y = 0; y < height;) + { + var h = 16 * (isPreview ? RNG.Random.Next(2, 4) : RNG.Random.Next(2, 6)); + Glitches.GenerateMonochromeSquareNoiseAtLocation(bitmap, new Rectangle(0, y, width, h)); + y += h; + } + + return bitmap; + } + } + internal class InitialImageShapes : IInitialImage { public string GetName()