We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I am very new to processing and would appreciate the help.
PImage img, female, male;
PGraphics mask;
int xspacing = 16;
int w;
float theta = 0.0;
float amplitude = 150.0;
float period = 500.0;
float dx;
float[] yvalues;
float mx;
float my;
float easing = 0.05;
void setup() {
size (1024,640);
img=loadImage("forest.png");
male=loadImage("male.png");
female=loadImage("female.png"); //this is the image I want to display on the wave instead of the ellipses
female.resize(16, 16);
w = width+16;
dx = (TWO_PI / period) * xspacing;
yvalues = new float[w/xspacing];
}
void draw() {
background(0);
image(img,0,0);
stroke(0);
fill (0);
if (abs(mouseX - mx) > 0.1) {
mx = mx + (mouseX - mx) * easing;
}
if (abs(mouseY -my) > 0.1) {
my = my + (mouseY - my) * easing;
}
mx = constrain(mx,0,width);
my = constrain(my,0,260);
rect(0,260,1024,380);
image(male, mouseX, mouseY);
calcWave();
renderWave();
}
void calcWave() {
theta += 0.02;
float x = theta;
for (int i = 0; i < yvalues.length; i++) {
yvalues[i] = sin(x)*amplitude + 150;
x+=dx;
}
}
void renderWave() {
noStroke();
fill(255);
for (int x = 0; x < yvalues.length; x++) {
ellipse(x*xspacing, height/2+yvalues[x],16,16);
}
}
Answers
Use image() where you use ellipse().