import lord_of_galaxy.timing_utils.*;
Stopwatch s;//Declare
void setup(){
size(640, 360);
//Creating a stopwatch to keep time
s = new Stopwatch(this);
//Start the stopwatch
s.start();
}
void draw(){
background(0);
fill(255);
textSize(50);
//Use s.time() to get current time in milliseconds
text(str(s.time()), 50, 100);
}
To get the time in seconds for the last line:
text("Time in secs: "+str(s.time()/1000.0), 50, 100);
To format the number, look at round(), floor(), nf() in the reference.
If all you need is just to set a wait time for some event and know when it's finished, you can use the Countdown class from the link below instead: O:-)
And of course, you can have more than 1 Countdown instance at the same time; so you can track down more than 1 event w/ diff. wait times if your sketch demands it. *-:)
Answers
You can install the TimingUtilities using the Library manager in Processing. A link to the lib in github: https://github.com/Lord-of-the-Galaxy/Timing-Utilities
Kf
Thanks! Do you know how to make a timer in seconds?? :-/
From the github example:
To get the time in seconds for the last line:
text("Time in secs: "+str(s.time()/1000.0), 50, 100);
To format the number, look at round(), floor(), nf() in the reference.
Kf
Thank you so much!!
If all you need is just to set a wait time for some event and know when it's finished, you can use the Countdown class from the link below instead: O:-)
https://Forum.Processing.org/two/discussion/23846/time-delay-in-python-mode#Item_11
An online example btW: :bz
http://Bl.ocks.org/GoSubRoutine/1a0d21828319cf18fecf44101764bd60
true
. That's it! :-bdBtW, you can always start over a Countdown instance by reinvoking its start() method; even when it's not done yet. :ar!
It simply cancel() its old TimerTask and schedule() a
new
1, using its field delay's current value. :>And of course, you can have more than 1 Countdown instance at the same time; so you can track down more than 1 event w/ diff. wait times if your sketch demands it. *-:)