From 1a185d05c5d9ece5c0793e160fca525cb0abc8a7 Mon Sep 17 00:00:00 2001 From: tonton th Date: Wed, 23 Dec 2020 16:40:45 +0100 Subject: [PATCH] better random_blocks --- Fonderie/crapulator.c | 2 +- Fonderie/glitches.c | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Fonderie/crapulator.c b/Fonderie/crapulator.c index 146d3cc8..b4e036f5 100644 --- a/Fonderie/crapulator.c +++ b/Fonderie/crapulator.c @@ -206,7 +206,7 @@ switch (idFx) { break; case 26: - retval = random_blocks(image, 80); + retval = random_blocks(image, 70); break; default : diff --git a/Fonderie/glitches.c b/Fonderie/glitches.c index ab4778a7..393c453c 100644 --- a/Fonderie/glitches.c +++ b/Fonderie/glitches.c @@ -100,13 +100,19 @@ int random_blocks(FloatImg *picture, int percent) { int x, y; -for (y=0; yheight; y+=8) { - for (x=0; xwidth; x+=8) { +if ( (picture->width%16) || (picture->height%8) ) + { + fprintf(stderr, "%s: %d%d bad dims\n", __func__, + picture->width, picture->height); + } +for (y=0; yheight; y+=16) { + for (x=0; xwidth; x+=16) { if (percent < (rand()%100) ) { - - un_petit_flou_8x8(picture,x, y); - + un_petit_flou_8x8(picture, x, y); + un_petit_flou_8x8(picture, x+8, y); + un_petit_flou_8x8(picture, x, y+8); + un_petit_flou_8x8(picture, x+8, y+8); } }