gliches++

This commit is contained in:
tonton th 2020-12-02 19:24:54 +01:00
parent a587a66af8
commit a450ac4291
3 changed files with 49 additions and 16 deletions

17
Fonderie/essai.sh Executable file
View File

@ -0,0 +1,17 @@
#!/bin/bash
OUTF='/tmp/out_a*.png'
rm $OUTF
make t && ./t
A_PART=$(ls -1 $OUTF)
Z_PART=$(ls -r1 $OUTF)
convert -delay 10 ${A_PART} ${Z_PART} foo.gif

View File

@ -113,11 +113,26 @@ int poke_a_random_pixel(FloatImg *picz, float fval, int kaboo)
return -1; return -1;
} }
/* -------------------------------------------------------------- */ /* -------------------------------------------------------------- */
/*
* used by vertical_singlitch()
*/
int x_delta(float dy, float phy)
{
float param, fv;
param = dy + phy;
fv = 9.999*sin(param) + 6.666*sin(param*3) + 3.333*sin(param*5);
return (int)fv;
}
/* -------------------------------------------------------------- */
/*
* please explain arguments
*/
int vertical_singlitch(FloatImg *picz, int xpos, float fval, int vertical_singlitch(FloatImg *picz, int xpos, float fval,
float omega, float phi) float omega, float phi)
{ {
int y, x, w, h; int y, x, w, h;
double dy; float dy;
float fv;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %d %f %f )\n", __func__, picz, fprintf(stderr, ">>> %s ( %p %d %f %f )\n", __func__, picz,
@ -125,21 +140,23 @@ fprintf(stderr, ">>> %s ( %p %d %f %f )\n", __func__, picz,
#endif #endif
h = picz->height; w = picz->width; h = picz->height; w = picz->width;
#define BB 10 #define BB 4
for (y=BB; y<h-BB; y++) { for (y=BB; y<h-BB; y++) {
dy = (double)y * omega; dy = (float)y * omega; /* normalize vertical position */
x = xpos + (int)(10.9*sin(dy+phi)); /* add sinus deviation */ x = xpos + x_delta(dy, phi); /* add sinus deviation */
/* compute bounding box */ /* compute bounding box */
if ( (x>BB) && (x<w-BB) ) { if ( (x>BB) && (x<w-BB) ) {
/* an make the glitch */ /* an make the glitch */
fimg_plot_rgb(picz, x, y, fval, fval, fval); fimg_plot_rgb(picz, x, y, fval, fval, fval);
fv = fval / 3.0;
if (rand() & 8) if (rand() & 8)
fimg_plot_rgb(picz, x-1, y, 0.0, 0.0, 0.0); fimg_plot_rgb(picz, x-1, y, fv, fv, fv);
if (rand() & 8) if (rand() & 8)
fimg_plot_rgb(picz, x+1, y, 0.0, 0.0, 0.0); // XXX else
fimg_plot_rgb(picz, x+1, y, fv, fv, fv);
} }
} }
return 0; return 0;

View File

@ -8,6 +8,7 @@
#include "../floatimg.h" #include "../floatimg.h"
#include "glitches.h" #include "glitches.h"
#include "sfx.h"
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
@ -15,13 +16,10 @@ int verbosity;
#define PNG "out.png" #define PNG "out.png"
#define W 512 #define W 512
#define H 512 #define H 256
#define LMAX 233.333 #define LMAX 249.9999
#define TIMER 1 #define TIMER 1
int trinarize(FloatImg *pimg, int notused); // in sfx.c
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int foo, iter, xloc, bloub; int foo, iter, xloc, bloub;
@ -40,16 +38,16 @@ if (foo) {
exit(1); exit(1);
} }
fimg_printhead(&image); // fimg_printhead(&image);
srand(getpid()); srand(getpid());
debut = fimg_timer_set(TIMER); debut = fimg_timer_set(TIMER);
for (iter=0; iter<16; iter++) { fimg_hdeg_a(&image, LMAX);
fimg_vdeg_a(&image, LMAX); for (iter=0; iter<32; iter++) {
for (bloub=0; bloub<16; bloub++) { for (bloub=0; bloub<6; bloub++) {
xloc = rand() % W; xloc = rand() % W;
omega = (float)(0.1 + drand48()*0.6) * 0.4; omega = (float)(0.1 + drand48()*0.6) * 0.4;
foo = vertical_singlitch(&image, xloc, LMAX, foo = vertical_singlitch(&image, xloc, LMAX,
@ -64,6 +62,7 @@ for (iter=0; iter<16; iter++) {
exit(1); exit(1);
} }
#if 0
foo = trinarize(&image, 0); /* XXX */ foo = trinarize(&image, 0); /* XXX */
sprintf(buff, "/tmp/out_b%03d.png", iter); sprintf(buff, "/tmp/out_b%03d.png", iter);
@ -72,7 +71,7 @@ for (iter=0; iter<16; iter++) {
fprintf(stderr, "err %d saving to '%s'\n", foo, buff); fprintf(stderr, "err %d saving to '%s'\n", foo, buff);
exit(1); exit(1);
} }
#endif
} }
fin = fimg_timer_set(TIMER); fin = fimg_timer_set(TIMER);