|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.gicentre.utils.FrameTimer
public class FrameTimer
Class for displaying frame rates in a sketch. To use, declare a FrameTimer
object at the top of a sketch, initialise it in the setup()
method, and
call one and only one of the methods for reporting frame rates (displayFrameRate()
,
getFrameRate()
, getFrameRateAsText()
) in the draw()
method. Frame rates can be reported either every n frames or every t seconds
depending on which constructor is used.
Constructor Summary | |
---|---|
FrameTimer()
Creates a timer that will report the frame rate once in every 50 frames. |
|
FrameTimer(float delay,
float reportRateInSeconds)
Creates a timer that will report the frame rate once in every reportRateInSeconds seconds. |
|
FrameTimer(int reportRateInFrames)
Creates a timer that will report the frame rate once in every reportRateInFrames frames. |
Method Summary | |
---|---|
void |
displayFrameRate()
Displays the current frame rate. |
float |
getElapsedTime()
Retrieves the time since the last call to startTimer() |
float |
getFrameRate()
Reports the current frame rate as a number. |
java.lang.String |
getFrameRateAsText()
Reports the current frame rate as formatted text. |
void |
startTimer()
Starts a timer that can be used for timing specific parts of a program. |
void |
update()
Updates the frame counter. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FrameTimer()
public FrameTimer(int reportRateInFrames)
reportRateInFrames
frames.
reportRateInFrames
- Number of frames to elapse before recalculation of the current frame rate.public FrameTimer(float delay, float reportRateInSeconds)
reportRateInSeconds
seconds.
delay
- Number of seconds delay before the first frame rate calculation. This can be useful if you
wish to ignore frame rates during the initialisation part of a sketch.reportRateInSeconds
- Number of seconds between recalculations of the current frame rate.Method Detail |
---|
public void displayFrameRate()
public java.lang.String getFrameRateAsText()
public float getFrameRate()
public void update()
public void startTimer()
getElapsedTime
to retrieve the number of seconds since a call was made to this method.
public float getElapsedTime()
startTimer()
startTimer
was last called, or 0 if it has not been called.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |