gliches++

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

View File

@@ -113,11 +113,26 @@ int poke_a_random_pixel(FloatImg *picz, float fval, int kaboo)
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,
float omega, float phi)
{
int y, x, w, h;
double dy;
float dy;
float fv;
#if DEBUG_LEVEL
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
h = picz->height; w = picz->width;
#define BB 10
#define BB 4
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 */
if ( (x>BB) && (x<w-BB) ) {
/* an make the glitch */
fimg_plot_rgb(picz, x, y, fval, fval, fval);
fv = fval / 3.0;
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)
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;