Hi everyone, so I was wondering how do I get the ellipse that I have drawn to appear one at a time, rather than having 10 all appear at once as a group?
var data;
var instagram, snapchat, messenger, facebook, email, instagramCol, snapchatCol, messengerCol, facebookCol, emailCol;
var whichHour=0; //for iterating through data
var sizeMultiplier = 20;
var time, size;
function preload (){
data =loadJSON("Sunday.json");
}
function setup() {
createCanvas (windowWidth, windowHeight);
background (255);
noStroke ();
textSize (20);
instagramCol = color (142, 68, 173, 30);
messengerCol = color (133, 193, 233, 30);
snapchatCol = color (247, 220, 111, 30);
facebookCol = color (118, 215, 196, 30);
emailCol = color (178, 186, 187, 30);
frameRate(2);
}
function draw () {
for (whichHour=0; whichHour<data.hours.length; whichHour++){
fill (instagramCol);
size = data.hours[whichHour].instagram*sizeMultiplier;
ellipse (random(20+(whichHour*50)), height/4, size, size);
}
}
Just a hint… you can use draw() as your “for loop”.
This is one way to do it.
In your example with frameRate(2):
function draw()
{
//for (whichHour=0; whichHour<data.hours.length; whichHour++)
{
fill (instagramCol);
size = data.hours[whichHour].instagram*sizeMultiplier;
ellipse (random(20+(whichHour*50)), height/4, size, size);
}
whichHour++;
//And so on... you will have to complete this part.
}
Hello, I would not lower the frameRate() since it is slowing down your whole sketch.
One interesting way imho is to use millis();
you can do things like saying: “do something every 10 seconds”
modulo is also helpful: if (millis%1000 =0) { do something }
= if the current time (in milliseconds) divided by 1000 is zero -> that happens every second…
then you could increase the radius of the ellipse you draw…
… and use background(0); so you do not draw the ellipse(s) on top of each other
hm ok. ill believe you there, I use it for years like this and it always worked though
frameCount sure is a good option, but it doesn’t give you measure of how much time has passed
probably a more complicated construction using both can root out all possible errors