How do I make a circle that starts as a dot and then keeps getting bigger until it disappears?
Also then, how would I have more circles continuously appearing from that same point one after the other so I get what looks like a wave expanding in all directions viewed from above?
Hello and welcome here!
Please read this and build your animation from here:
https://www.processing.org/tutorials/overview/
Look at ellipse to get started:
https://www.processing.org/reference/ellipse_.html
you need to store width and height of the ellipse. Use a variable d for both
increase d: d=d+1;
then show your animation sketch so far
Chrisir
Thanks!
Here is my progress so far:
float d = 1;
void setup() {
size(640, 360);
stroke(255, 204, 0);
noFill();
}
void draw() {
background(0);
d = (d+1);
ellipse(200, 200, d, d);
}
nicely done!
Remember to hit ctrl-t in processing to get auto-format (indents)
Next step
Now, you want to have different circles with same center
This calls for arrays!
an Array is a list of values.
so before setup()
:
int[] ds = new int[1000]; // wrong! d, not ds ;-)
int timer;
int max=0;
in draw()
:
for(int i = 0; i<max; i++) {
ellipse ( 200,200, d[i], d[i] );
d[i]=d[i]+1;
}
if(millis()-timer>1400) {
max=max+1;
timer = millis();
}
Chrisir
please hit ctrl-t in processing
please post your entire code as text
Do you have this:
int[] d = new int[1000];
(I had ds
there falsely)
ah, I removed the s and now it’s working. Cool!! Thank you so much!
Here is the code so far:
int[] d = new int[1000];
int timer;
int max=0;
void setup() {
size(1500, 700);
}
void draw() {
background(220);
stroke(0);
fill(0);
rect(100, 100, 300, 400);
noFill();
stroke(255, 100, 0);
//ellipse(200, 200, d, d);
//d=d+5;
for (int i = 0; i<max; i++) {
ellipse ( 200, 200, d[i], d[i] );
d[i]=d[i]+1;
}
if (millis()-timer>1400) {
max=max+1;
timer = millis();
}
}
well done!
please read the code and understand
- arrays,
- timer and
- why we get slowly more circles.
The sketch will crash after a few minutes. How many? Why?
What does max
do?
Auto-Format in processing
hit ctrl-t in processing (or menue Edit | Auto-format)
Formatting in the Forum
Anyway, in the forum after pasting, please mark your code with the mouse and click </>
in the command bar
- to show your code formatted as code when posting in the forum
Chrisir
Will do!
Thanks!!