Clock

class Clock

A simple class for timing of animations and things. Literally a delta function.

PolyUI internally uses nanoseconds as the time unit. There are a few reasons for this:

  • animations will be smoother as frames are usually shorter than 1ms, around 0.007ms. This means that the delta will be a decimal, which is not possible with longs, so some accuracy is lost with milliseconds.

  • Clock,getTime (the function we use to measure time) ignores changes to the system clock, so if the user changes their clock PolyUI won't crash or go very crazy because of a negative time.

  • 9,223,372,036,854,775,808 is max for a long, so the program can run for 2,562,047.78802 hours, or 106,751.991167 days, or 292.471 years. So we can use these.

See also

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
class Bomb(val timerNanos: Long, val func: () -> Unit) : Clock.Executor

An executor that will execute a function after a certain amount of time.

Link copied to clipboard
object Companion
Link copied to clipboard
fun interface Executor
Link copied to clipboard
open class FixedTimeExecutor @JvmOverloads constructor(val executeEveryNanos: Long, val repeats: Int = 0, func: () -> Unit) : Clock.Executor

Create a new FixedTimeExecutor.

Properties

Link copied to clipboard
val delta: Long

Functions

Link copied to clipboard
@ApiStatus.Internal
fun peek(): Long

this function is rather wasteful and usage should be avoided.