diff --git a/pipi/filter/wave.c b/pipi/filter/wave.c index 68d069b..cb82876 100644 --- a/pipi/filter/wave.c +++ b/pipi/filter/wave.c @@ -58,12 +58,19 @@ pipi_image_t *pipi_wave(pipi_image_t *src, double freq, double phase, { double t = cost * (x - w / 2) + sint * (y - h / 2); double step = sin(t * freq + phase); - double dx = xamp * step; - double dy = yamp * step; + double dx = xamp; + double dy = yamp; + int x2, y2; - int x2 = x + dx; - int y2 = y + dy; + if(x < 32) dx = dx * x / 32; + if(x > w - 1 - 32) dx = dx * (w - 1 - x) / 32; + if(y < 32) dy = dy * y / 32; + if(y > h - 1 - 32) dy = dy * (h - 1 - y) / 32; + x2 = x + dx * step; + y2 = y + dy * step; + + /* Just in case... */ if(x2 < 0) x2 = 0; else if(x2 >= w) x2 = w - 1;