float f, t;
float W, H;
PImage shark;
int ang = 0;
int cang = 0.01;
float shark,
particles = [];
float pixelStep = 10;
var x=0
var y=0
void setup () {
size(1000, 1000);
W=width;
H=height;
stroke(#A08447);
f=2;
strokeWeight(f);
shark = loadImage("shark_smal.png");
for(int ang = 0; x < shark.width; x += pixelStep){
for(int cang = 0; y < shark.height; y += pixelStep){
particles.push(new Particle(x+(width-shark.width)/2,y+(height-shark.height)/4,shark.get(x,y)));
}
}
}
void draw () {
clear();
background(#766132);
//SAND BACKGROUND FUNCTION NOTHING CHANGED
t=map(sin((f+=0.01)), -1, 1, 60, 200);
float TAU=TWO_PI;
for (int y=0; y<H; y+=3) {
for (int x=0; x<W; x+=3) {
float r=noise(x/W, y/H - f) *t;
point(cos(r)*TAU+x, sin(r)*TAU+y);
}
}
//PLACEMENT OF THE IMAGE IN THE FRAME
image(shark, 270, 200
// HERE THE EFFECT SHOULD BE ADDED TO THE IMAGE
degrees();
for (int i=0; i<9999; i++){
x+=5
if (x>width) {
y+=5;x=0
}
if (y>height) {
y=0;x=0
}
}
for(let particle of particles){
particle.draw();
particle.pos.add(particle.vel);
particle.vel.div(1.1);
particle.vel.add(PVector.sub(particle.target,particle.pos).div(20));
const d = dist(particle.pos.x,particle.pos.y,x,y);
particle.vel.x += (particle.pos.x - x) / d;
particle.vel.y += (particle.pos.y - y) / d;
}
}
class Particle {
constructor(x,y,color){
this.col = color;
this.pos = new PVector(x,y);
this.vel = new PVector();
this.target = this.pos.copy();
}
draw(){
fill(this.col);
ellipse(this.pos.x,this.pos.y,pixelStep,pixelStep);
}
}
}
Yes, that’s right. I have not shown how I try. Maybe because I’m a bit embarrassed. So at the moment I’m trying it like this. However, I only get error messages and it doesn’t really work. I would also be happy with a simpler solution that lets the image of the shark do something. I just haven’t come across anything yet that could help me.