hey guys. this is my first sorce code goes here. In this, i was create a funky particles where thats particles controlling theta and radius by mouse position, click for generate it. i hope you copy/paste this code here
//-start here
shaker[] sr;
int nmb=500;
void setup(){
size(500,500);
background(0);
sr=new shaker[nmb];
for(int a=0;a<nmb;a++){
sr[a]=new shaker(250,250,random(-PI,PI),183,211,232,a);
}
}
void draw(){
fill(0,10);
rect(0,0,width,height);
for(int a=0;a<nmb;a++){
sr[a].trail();
}
}
void mousePressed(){
for(int a=0;a<nmb;a++){
sr[a]=new shaker(250,250,random(PI),183,211,232,a);
}
}
class shaker{
int id; //index
float x,y; //position
float tdir; //theta direction
int rd,gr,bl; //colors
float themo; //controlled by mouse position
float spd,spd2; //speed and delay
shaker(float x0,float y0,float tdir0,int rd0,int gr0,int bl0,int id0){
//construct this
x=x0;
y=y0;
tdir=tdir0;
rd=rd0;
gr=gr0;
bl=bl0;
id=id0;
//speed init
spd=random(0.5,2.5);
spd2=random(0.995,1.005);
}
void trail(){
//control theta by mouse position
themo=atan2(250-mouseX,250-mouseY);
//circular moves
x+=cos(themo+tdir)*spd+(id%3);
y+=sin(themo+tdir)*spd+(id%3);
//make it wrap around
while(x<0){
x+=width;
}
while(x>=width){
x-=width;
}
while(y<0){
y+=height;
}
while(y>=height){
y-=height;
}
//trail it
stroke(rd,gr,bl,32);
point(x,y);
spd*=spd2;
}
}
//-end
happy coding and tell me if you works thats code