I am novice and and I have to modify this code on pvector: I would like creating several circles which change differents colors when they touch borders, I tried with lists but any result, i'm doing wrong i guess -_-
thank you for your help and advice:)
this is my code :
in the main sketch :
Objet objet;
void setup() {
size(300, 300);
PVector pos = new PVector(width/2, height/2);
PVector vel = new PVector(0, 0);
PVector acc =new PVector(0, 0);
objet = new Objet(pos, vel, acc, 1.5);
}
I was drawing some ellipses and a rectangle to create an island and i would like to pick up colors that i choose in rgb to fill the island, the sea and the ombrel with the appropriate colors but when my mouse is on the button, all the elements become a same color, why ? Can you help me please ?
and i was wondering how can i make my ellipse (the island) remain yellow when my mouse is pressed, i tried "if mousepressed" , of course, it didn t work but i think i lack something ...
Thanks for your precious help : )
This is my code :
color sable,mer,ombrelle;
void setup (){
size (500,250);
smooth();
background(7,207,240);
colorMode(RGB);
sable = color (224,203,168);// rgb
mer = color (8,150,190);
ombrelle = color (255,0,0);
}
void draw(){
color souris = get(mouseX,mouseY); // remplit forme entiere
noStroke();
fill(sable);
rect(0,0,20,20);
fill(mer);
rect(0,20,20,20);
fill (ombrelle);
rect(0,40,20,20);
//ombrelle
noStroke();
fill (souris);
ellipse (150,100,200,90);
//dessus baton
stroke (100,50,30);
fill (0,50,50);
rect (150,70,10,22);
//baton
stroke (100,50,30);
fill (0,50,50);
rect (150,145,10,70);
I created a code about a crazy clock ^^ , when the mouse is down, it change color and make appears a spiral but i wonder 2 questions :
1- why my arrows are less fast when my mouse is down/change blackground ?, it's cool but i don' t understand because this arrows are doing this, it was not my intention at first, so i would like to understand ^^
2- I tried to create a Mousepressed code to animate slowly the spirale when i click with my mouse but unfortunately i didn't succeed, could you me help please ?
This is my code to illustrate my questions :
float secondes;
float heures;
float minutes;
I wanted to thank you for the help that you have me already brought in my precedent post, today I still need your advices to end the writing of my code:
I don t know if it s possible but I would like that we can see a track ( a line) between my circles when I move my mouse..
As if my circles could draw a line as one goes along in an reinterpretated style of Jackson Pollock and my circles would remain evanescent like it already are here..
I hope you understand me ^^'
I also noticed that my Void mousepressed did not work well because I wanted by clicking on A, it would appear a black circle which wouldn t remain on the background or it doesn't stay on the background.
Here is my code...
//declare arrays for mouse position in x and y, length
float x[] = new float[lenght];
float y[] = new float[lenght];
void draw() {
background(255);
//reads entire array
for (int i=1; i<100; i++) {
//the first value is deleted, all values are moved one position down
x[i-1] = x[i];
y[i-1] = y[i];
}
//mouse x and y are the new last item of the arrays
x[100-1] = mouseX;
y[100-1] = mouseY;
//read again the array, with new values
for (int i=0;i< x.length; i++) {
//dessin du cercle
noStroke();
fill(0, 0, 0, 100);
ellipse(x[i], y[i], i-30, i);
strokeWeight(4);
stroke(random(255, 255), 255);
}
}
void keyPressed() {
if(key=='a'){
fill(255);
x [click]=mouseX;
y [click]=mouseY;
click++;
}
}
Thank you for taking time to answer me and to explain my errors:)
I'm a very beginner, so i begin to understand the loops..
I tried to use a "method" to draw every ellipses i made with my four loops but it didn't work ...
I give a name : for example " void ..... (){" to each one and write names of method like "...(); in the "void draw" and nothing happened
I tried also with ' void mousePressed' to change the color ; to turn the red dark points into red and the red into dark point but i think i miss something and i would like to have the possibilty of making grow the circles if the mouse is Pressed...
The man who did it knows how to use the variable LoadImage and i don't have his image.png and i'm a really beginner so i's possible to create a similar effect with the variable of loop "for" ? Can you explain me how ?
This is my first topic and i'm just learning how to code with processing. I want to make a simple grid with 16 box, when i move my mouse on a box, the color change, and when i click on it, color change again...
Here is my first work on it (you can download it to check it out) :