@@ -26,13 +26,15 @@
#include "pipi.h"
#include "pipi.h"
#include "pipi_internals.h"
#include "pipi_internals.h"
pipi_image_t *pipi_wave(pipi_image_t *src, double freq, double phase,
double theta, double xamp, double yamp)
#define BORDER 64
pipi_image_t *pipi_wave(pipi_image_t *src, double dw, double dh,
double d, double a)
{
{
pipi_image_t *dst;
pipi_image_t *dst;
pipi_pixels_t *srcp, *dstp;
pipi_pixels_t *srcp, *dstp;
float *srcdata, *dstdata;
float *srcdata, *dstdata;
double sint, cost ;
double sina, cosa ;
int x, y, w, h, i, gray;
int x, y, w, h, i, gray;
w = src->w;
w = src->w;
@@ -49,26 +51,29 @@ pipi_image_t *pipi_wave(pipi_image_t *src, double freq, double phase,
: pipi_get_pixels(dst, PIPI_PIXELS_RGBA_F32);
: pipi_get_pixels(dst, PIPI_PIXELS_RGBA_F32);
dstdata = (float *)dstp->pixels;
dstdata = (float *)dstp->pixels;
sint = sin(thet a);
cost = cos(thet a);
sina = sin( a);
cosa = cos( a);
for(y = 0; y < h; y++)
for(y = 0; y < h; y++)
{
{
for(x = 0; x < w; x++)
for(x = 0; x < w; x++)
{
{
double t = cost * (x - w / 2) + sint * (y - h / 2);
double step = sin(t * freq + phase );
double dx = xamp ;
double dy = yamp ;
double angle = 2 * M_PI / dw * ((x - w / 2) * cosa
+ (y - h / 2) * sina - d );
double displacement = dh * sin(angle) ;
double dx, dy ;
int x2, y2;
int x2, y2;
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;
dx = -sina * displacement;
dy = cosa * displacement;
if(x < BORDER) dx = dx * x / BORDER;
if(x > w - 1 - BORDER) dx = dx * (w - 1 - x) / BORDER;
if(y < BORDER) dy = dy * y / BORDER;
if(y > h - 1 - BORDER) dy = dy * (h - 1 - y) / BORDER;
x2 = x + dx * step;
y2 = y + dy * step;
x2 = x + dx;
y2 = y + dy;
/* Just in case... */
/* Just in case... */
if(x2 < 0) x2 = 0;
if(x2 < 0) x2 = 0;