Skip to content

Commit f29feb2

Browse files
committed
Add sketchPath/dataPath/loadStrings/loadBytes to Processing_api.h
1 parent a548e1b commit f29feb2

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/Processing_api.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ inline float degrees(float r) { return PApplet::degrees(r); }
1111
inline float sq(float x) { return PApplet::sq(x); }
1212
inline float lerp(float a,float b,float t) { return PApplet::lerp(a,b,t); }
1313
inline bool* getKeysDown() { return PApplet::g_papplet ? PApplet::g_papplet->keysDown : nullptr; }
14+
// File/IO functions for hoisted classes
15+
inline ::std::string sketchPath(const ::std::string& w="") { return ::Processing::sketchPath(w); }
16+
inline ::std::string dataPath(const ::std::string& w="") { return ::Processing::dataPath(w); }
17+
inline ::std::string sketchFile(const ::std::string& w) { return ::Processing::sketchPath(w); }
18+
inline ::std::string dataFile(const ::std::string& w) { return ::Processing::dataPath(w); }
19+
inline ::std::vector<::std::string> loadStrings(const ::std::string& p) {
20+
return ::Processing::PApplet::g_papplet ? ::Processing::PApplet::g_papplet->loadStrings(p) : ::std::vector<::std::string>{};
21+
}
22+
inline ::std::vector<unsigned char> loadBytes(const ::std::string& p) {
23+
return ::Processing::PApplet::g_papplet ? ::Processing::PApplet::g_papplet->loadBytes(p) : ::std::vector<unsigned char>{};
24+
}
25+
1426
// Time functions
1527
inline unsigned long millis() { return ::Processing::PApplet::g_papplet ? ::Processing::PApplet::g_papplet->millis() : 0; }
1628
inline int second() { ::std::time_t t=::std::time(nullptr); return ::std::localtime(&t)->tm_sec; }

0 commit comments

Comments
 (0)