|
6 | 6 | #include <string> |
7 | 7 |
|
8 | 8 | // ── Math (static, no instance needed) ──────────────────────────────────────── |
9 | | -inline float sin(float x) { return ::std::sin(x); } |
10 | | -inline float cos(float x) { return ::std::cos(x); } |
11 | | -inline float tan(float x) { return ::std::tan(x); } |
12 | | -inline float asin(float x) { return ::std::asin(x); } |
13 | | -inline float acos(float x) { return ::std::acos(x); } |
14 | | -inline float atan(float x) { return ::std::atan(x); } |
15 | | -inline float atan2(float y, float x) { return ::std::atan2(y,x); } |
16 | | -inline float abs(float x) { return ::std::abs(x); } |
17 | | -inline float floor(float x) { return ::std::floor(x); } |
18 | | -inline float ceil(float x) { return ::std::ceil(x); } |
19 | | -inline float round(float x) { return ::std::round(x); } |
20 | | -inline float sqrt(float x) { return ::std::sqrt(x); } |
21 | | -inline float pow(float a, float b) { return ::std::pow(a,b); } |
22 | | -inline float exp(float x) { return ::std::exp(x); } |
23 | | -inline float log(float x) { return ::std::log(x); } |
24 | 9 | inline float radians(float d) { return PApplet::radians(d); } |
25 | 10 | inline float degrees(float r) { return PApplet::degrees(r); } |
26 | 11 | inline float sq(float x) { return PApplet::sq(x); } |
27 | 12 | inline float lerp(float a,float b,float t) { return PApplet::lerp(a,b,t); } |
28 | 13 | inline bool* getKeysDown() { return PApplet::g_papplet ? PApplet::g_papplet->keysDown : nullptr; } |
29 | | -// print/println for hoisted classes |
30 | | -template<typename T> inline void print(const T& v) { ::std::cout << v; ::std::cout.flush(); } |
31 | | -template<typename T> inline void println(const T& v) { ::std::cout << v << "\n"; ::std::cout.flush(); } |
32 | | -inline void println() { ::std::cout << "\n"; ::std::cout.flush(); } |
33 | | -template<typename T> inline void printArray(const ::std::vector<T>& a) { |
34 | | - for(int i=0;i<(int)a.size();i++) ::std::cout<<"["<<i<<"] "<<a[i]<<"\n"; |
35 | | - ::std::cout.flush(); |
36 | | -} |
37 | | - |
38 | | -// File/IO functions for hoisted classes |
39 | | -inline ::std::string sketchPath(const ::std::string& w="") { return ::Processing::sketchPath(w); } |
40 | | -inline ::std::string dataPath(const ::std::string& w="") { return ::Processing::dataPath(w); } |
41 | | -inline ::std::string sketchFile(const ::std::string& w) { return ::Processing::sketchPath(w); } |
42 | | -inline ::std::string dataFile(const ::std::string& w) { return ::Processing::dataPath(w); } |
43 | 14 | inline ::std::vector<::std::string> loadStrings(const ::std::string& p) { |
44 | 15 | return ::Processing::PApplet::g_papplet ? ::Processing::PApplet::g_papplet->loadStrings(p) : ::std::vector<::std::string>{}; |
45 | 16 | } |
46 | 17 | inline ::std::vector<unsigned char> loadBytes(const ::std::string& p) { |
47 | 18 | return ::Processing::PApplet::g_papplet ? ::Processing::PApplet::g_papplet->loadBytes(p) : ::std::vector<unsigned char>{}; |
48 | 19 | } |
49 | 20 |
|
50 | | -// Time functions |
51 | | -inline unsigned long millis() { return ::Processing::PApplet::g_papplet ? ::Processing::PApplet::g_papplet->millis() : 0; } |
52 | | -inline int second() { ::std::time_t t=::std::time(nullptr); return ::std::localtime(&t)->tm_sec; } |
53 | | -inline int minute() { ::std::time_t t=::std::time(nullptr); return ::std::localtime(&t)->tm_min; } |
54 | | -inline int hour() { ::std::time_t t=::std::time(nullptr); return ::std::localtime(&t)->tm_hour; } |
55 | | -inline int day() { ::std::time_t t=::std::time(nullptr); return ::std::localtime(&t)->tm_mday; } |
56 | | -inline int month() { ::std::time_t t=::std::time(nullptr); return ::std::localtime(&t)->tm_mon+1; } |
57 | | -inline int year() { ::std::time_t t=::std::time(nullptr); return ::std::localtime(&t)->tm_year+1900; } |
58 | 21 | inline bool isKeyDown(int keyCode) { |
59 | 22 | if(!PApplet::g_papplet) return false; |
60 | 23 | if(keyCode<0||keyCode>=256) return false; |
|
0 commit comments