Hi, I need help with a college job. It consists of generating with the movement and speed of the mouse, different abstract works of art, in my case select some that contain different squares each one in a specific position. The question is that I don’t know how to move the mouse to generate the squares. As the mouse increases its speed, the squares with warmer colors should appear, and on the contrary, the colder colors and each one in its specific positions (which is the most complicated). I pass the code that I have already advanced. Hopefully someone can help me thanks!
class prototype ------------------------------------------------ -----------------------------------------------
Address_Speed mySpeedYDirection; // declare object
ArrayList walkers; // declare ArrayList object
null configurations () {
size (600,600);
// I initialize the object
mySpeedYaddress = new Speed_Address ();
walkers = new ArrayList ();
for (int i = 0; i <random (0.5); i ++)
walkers.add (new Walker ());
}
empty draw () {
miVelocidadYDireccion.calcularTodo (mouseX, mouseY);
noStroke ();
for (Walker c: walkers) {
c. draw ();
if (mySpeedYaddress.speed ()> 10)
c.mover ();
}
}
class walking ------------------------------------------------ -------------------------------------------------- -
class Walker {
// Attributes
float x1, y1;
float x2, y2;
float dir;
float vel;
float t;
//Builder
Walker () {
`` ''
x1 = random (width);
y1 = random (height);
x2 = random (width);
y2 = random (height);
vel = 15;
t = random (50,100);
dir = random (width, height);
`` ''
}
// what is going to be drawn depending on the direction and speed
void draw () {
`` ''
fill (mySpeedYaddress.speed ()); / * the slower the mouse is, squares with dark colors are drawn
The more speed the mouse has, the colored squares are drawn
more clear*/
rect (x1, y1, t, t);
`` ''
}
// action of when you move the mousse
void move () {
`` ''
x1 = x2 + random (0.600); // DISTRIBUTION AND MOVEMENT OF SQUARES
y1 = y2 + random (0.600); // DISTRIBUTION AND MOVEMENT OF SQUARES
`` ''
// toroidal space
x1 = (x1> width? x1-width: x1);
x1 = (x1 <0? x1 + width: x1);
y1 = (y1> height? y1-height: y1);
y1 = (y1 <0? + height: y1);
}
}
class Address_and_speed ------------------------------------------------ --------------------------------------
class Speed_Address {
float posX;
float posY;
float PosPrevX;
float PosPrevY;
float myDirectionX;
float myAddressY;
float myPolarAddress;
float vel;
Speed_Address () {
this.posX = 50;
this.posY = 600;
vel = 50;
myDirectionX = 600;
myDirectionY = 600;
}
void calculateAll (float my_X, float my_Y) {
PosPrevX = posX;
PosPrevY = posY;
posX = my_X;
posY = my_Y;
`` ''
myDirectionX = posX-PosPrevX;
myDirectionY = posY-PosPrevY;
myPolarAddress = degrees (atan2 (posY-PosPrevY, posX-PosPrevX));
vel = dist (posX, posY, PosPrevX, PosPrevY);
`` ''
}
// methods that return values or something
speed float () {
return vel;
}
float xaddress () {
return myXAddress;
}
float addressY () {
return myAddressY;
}
float polaraddress () {
return myPolarAddress;
}
}