Debian Codegraph @

examples/machine/platform.ck

raw
1 // name: platform.ck
2 // desc: getting the operating system name + OS-provided time
3 // author: Andrew Zhu Aday
4 // date: summer 2025
5
6 // print the underlying operating system name as a string;
7 // possible return values of Machine.os():
8 // "mac", "linux", "windows", "web", "ios", "android", "unknown"
9 <<< "underlying operating system:", Machine.os() >>>;
10
11 // print the operating system-provided absolute time as a float
12 // in seconds since the Epoch 1970-01-01 00:00:00 +0000 (UTC);
13 // the returned time has microsecond resolution (and could be
14 // used for e.g. synchronizing events across machines without
15 // the use of networking)
16 <<< "machine time:", Machine.timeOfDay() >>>;
17
18 // identical to Machine.timeOfDay(), only the return value is a
19 // vec2 where x is time in seconds, and y is fractional time in
20 // microseconds; y is guaranteed to be between 0 and 1,000,000;
21 // x + y yields the total time. useful for situations needing less
22 // than 64-bit precision e.g., floats in OSC are 32-bit and one
23 // must send the x and y values separately -- otherwise a
24 // significant amount of timing resolution will be lost
25 <<< "machine time (added precision):", Machine.timeOfDay2() >>>;