From 37a1e5606e709dadc946e62c850161a30aad88f0 Mon Sep 17 00:00:00 2001 From: sam Date: Sat, 21 Feb 2009 14:26:58 +0000 Subject: [PATCH] wave.c: better behaviour around image edges. git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@3403 92316355-f0b4-4df1-b90c-862c8a59935f --- pipi/filter/wave.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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;