Overtime Class
A time limit visualization library.
Constructor
Overtime
-
[options]
Parameters:
-
[options]
Object optional- The settings.
-
[time]
Number optional- The time limit.
-
[canvas]
Number optional- The canvas to use. A new one will be created if none is supplied.
-
[clearCanvas=true]
Boolean optional- Whether the canvas should be cleared before rendering.
-
[size]
Array optional- The size of the canvas.
-
[timeMeasure=Overtime.TimeMeasure.SECONDS]
Overtime.TimeMeasure optional- The time measure of the supplied time limit.
Item Index
Properties
Events
Methods
_render
()
private
Renders the time progress on the canvas.
_update
()
private
Steps the system forward. This is the main loop.
advanceBy
-
t
Goes ahead in time by a given value.
Parameters:
-
t
Number- The time value by which to rewind. Will be interpreted according to the current time measure. A negative value corresponds to rewinding.
persist
()
private
Stores the time values for the next session.
prolongBy
-
t
Adds time.
Parameters:
-
t
Number- The time value to add. Will be interpreted according to the current time measure. A negative value corresponds to shortening.
rewind
()
Sets the time back to its original length.
rewindBy
-
t
Sets the time back by the given value. The time will not go back beyond the initial length.
Parameters:
-
t
Number- The time by which to rewind. Interpreted according to the current time measure. A negative value corresponds to fast-forwarding.
shortenBy
-
t
Reduces the total duration of the countdown.
Parameters:
-
t
Number- The time value to subtract. Will be interpreted according to the current time measure. A negative value corresponds to prolonging.
start
()
Tries to start the rendering cycle if it isn't running. Otherwise it restarts it.
stop
()
Stops the rendering cycle. Does nothing else besides that.
update
()
The update function.
Properties
animId
Number
private
Animation id of the currently requested frame.
canvas
HTMLCanvasElement
The internal canvas.
clearCanvas
Boolean
Clear canvas flag.
ctx
CanvasRenderingContext2D
private
The rendering context.
fullCircle
Number
private
Radians of the full circle plus the start angle.
HALF_PI
Number
private
final
PI / 2.
now
Number
private
Used for time-based rendering.
primaryStrokeStyle
String
Colour of the progressing circle.
Default: rgba(255, 100, 0, 0.9)
secondaryStrokeStyle
String
Colour of the empty circle.
Default: rgba(0, 0, 0, 0.1)
size
Number
The size of the canvas.
Example:
[width, height]
startAngle
Number
private
the start angle.
t
Number
private
The remaining time in milliseconds.
T
Number
private
The total time.
then
Number
private
Used for time-based rendering.
threshold
Number
private
A float threshold for the chrome rendering hack.
time
Number
The time. When set, the given value will be translated to the current time measure.
TimeMeasure
Object
final
static
Enumeration of time measure constants.
timeMeasure
Overtime.TimeMeasure
The current time measure. The current time will not be affected by this in any way.
tm
Overtime.TimeMeasure
private
The currently set time measure.
TWO_PI
Number
private
final
PI * 2.
Events
update
Returns the remaining time.
Event Payload:
-
time
Number- The remaining time.