SlideShare a Scribd company logo
1 of 55
openFrameworks
      utils
Utils

    date        screenshots       noise

list helpers   remote loading   logging

  string         threading      ļ¬le utils
manipulation    system tools    constants
date

       int ofGetSeconds()          Get seconds of current time
       int ofGetMinutes()           Get minutes of current time
        int ofGetHours()             Get hours of current time
        int ofGetYear()                  Get current year
       int ofGetMonth()                 Get current month
         int ofGetDay()                  Get current day
       int ofGetWeekDay                Get current weekday
 unsigned int ofGetUnixTime()         Timestamp since 1970
unsigned long ofGetSystemTime()        System time in millis
string ofGetSystemTimeMicros()        System time in micros
 string ofGetTimestampString()    Timestamp since 1970 as string
list helpers
Remove items from a vector.
       void ofRemove(vector<T>&, BoolFunction shouldErase)




                   Step 1. Create a custom remove functor

                   class MyOwnRemover{
                   public:
                   
 bool operator()(const string& str) {
                   
 
     return str == "roxlu";
                   
 }
                   };
list helpers

void ofRemove(vector<T>&, BoolFunction shouldErase)


    Step 2. use ofRemove with remove functor
    void testApp::setup(){

    
   // create list with strings.
    
   vector<string> mystrings;
    
   mystrings.push_back("diederick");
    
   mystrings.push_back("openframeworks");
    
   mystrings.push_back("supercool");
    
   mystrings.push_back("roxlu");
    
   mystrings.push_back("do not remove");
    
   mystrings.push_back("roxlu");
    
    
   // show before removing items.
    
   for(int i = 0; i < mystrings.size(); ++i) {
    
   
     cout << "before: " << mystrings[i] << endl;
    
   }
    
   cout << "=======" << endl;
    
    
   // remove items using my own remover!
    
   ofRemove(mystrings, MyOwnRemover());
    
   for(int i = 0; i < mystrings.size(); ++i) {
    
   
     cout << "after: " << mystrings[i] << endl;
    
   }
    }
Summary ofRemove                                                      list helpers

                   void ofRemove(vector<T>&, BoolFunction shouldErase)


class MyOwnRemover{                         void testApp::setup(){
public:

 bool operator()(const string& str) {      
   // create list with strings.

 
     return str == "roxlu";              
   vector<string> mystrings;

 }                                         
   mystrings.push_back("diederick");
};                                          
   mystrings.push_back("openframeworks");
                                            
   mystrings.push_back("supercool");
                                            
   mystrings.push_back("roxlu");
                                            
   mystrings.push_back("do not remove");
                                            
   mystrings.push_back("roxlu");
                                            
                                            
   // show before removing items.
                                            
   for(int i = 0; i < mystrings.size(); ++i) {
 Result                                     
                                            
                                                
                                                }
                                                      cout << "before: " << mystrings[i] << endl;

 before: diederick                          
   cout << "=======" << endl;
 before: openframeworks
 before: supercool                          
 before: roxlu
 before: do not remove
                                            
   // remove items using my own remover!
 before: roxlu                              
   ofRemove(mystrings, MyOwnRemover());
 =======
 after: diederick                           
   for(int i = 0; i < mystrings.size(); ++i) {
 after: openframeworks                      
   
     cout << "after: " << mystrings[i] << endl;
 after: supercool
 after: do not remove                       
   }
                                            }
Randomize a vector                                           list helpers

                              void ofRandomize(vector<T>&)


void testApp::setup(){


   // create list with strings.

   vector<string> mystrings;

   mystrings.push_back("diederick");

   mystrings.push_back("openframeworks");                   Result

   mystrings.push_back("supercool");
                                                             random:   roxlu

   mystrings.push_back("roxlu");
                                                             random:   roxlu

   mystrings.push_back("do not remove");
                                                             random:   supercool

   mystrings.push_back("roxlu");
                                                             random:   openframeworks
                                                             random:   do not remove

   ofRandomize(mystrings);
                                                             random:   diederick

   // show before removing items.

   for(int i = 0; i < mystrings.size(); ++i) {

   
     cout << "random: " << mystrings[i] << endl;

   }
}
Sort a vector                                                list helpers

                                   void ofSort(vector<T>&)


void testApp::setup(){


   // create list with strings.

   vector<string> mystrings;

   mystrings.push_back("diederick");

   mystrings.push_back("openframeworks");                   Result

   mystrings.push_back("supercool");
                                                             sorted:   diederick

   mystrings.push_back("roxlu");
                                                             sorted:   do not remove

   mystrings.push_back("do not remove");
                                                             sorted:   openframeworks

   mystrings.push_back("roxlu");
                                                             sorted:   roxlu
                                                             sorted:   roxlu

   ofSort(mystrings);
                                                             sorted:   supercool

   // show before removing items.

   for(int i = 0; i < mystrings.size(); ++i) {

   
     cout << "sorted: " << mystrings[i] << endl;

   }
}
Find entry in vector                                          list helpers

                  unsigned int ofFind(vector<T>&, const T& target)




void testApp::setup(){

 vector<string> mystrings;

 mystrings.push_back("diederick");

 mystrings.push_back("openframeworks");                      Result

 mystrings.push_back("supercool");

 mystrings.push_back("roxlu");                               do not remove <--

 mystrings.push_back("do not remove");

 mystrings.push_back("roxlu");


 string fstr = "do not remove";

 unsigned int num_found = ofFind(mystrings, fstr);

 if(num_found) {

 
      cout << mystrings[num_found] << " <-- ā€œ << endl;

 }
}
Check if entry exists                                          list helpers

                     bool ofContains(vector<T>&, const T& target)





   // create list with strings.

   vector<string> mystrings;

   mystrings.push_back("diederick");

   mystrings.push_back("openframeworks");                    Result

   mystrings.push_back("supercool");

   mystrings.push_back("roxlu");
                                                              do not remove in mystrings

   mystrings.push_back("do not remove");

   mystrings.push_back("roxlu");


   string fstr = "do not remove";

   bool contains = ofContains(mystrings, fstr);

   if(contains) {

   
     cout << fstr << " in mystrings" << endl;

   }
string
                                                                 manipulation
    Split a string
    vector<string> ofSplitString(
        const string& source
       ,const string& delimiters
       ,bool ignoreEmpty = false
       ,bool trim = false
    );


                                                                  Result

   string items = "one|two|three|four|five |||test|";             part:   'one'

   vector<string> parts = ofSplitString(items,"|",true,true);     part:   'two'

   for(int i = 0; i < parts.size(); ++i) {                        part:   'three'

   
     cout << "part: '" << parts[i] << "'" << endl;            part:   'four'

   }                                                              part:   'ļ¬ve'

                                                                  part:   'test'
string
                                                               manipulation
    Split a string
    vector<string> ofJoinString(vector<string>, const string delim)




   vector<string> loose_parts;                                Result

   loose_parts.push_back("I");

   loose_parts.push_back("need");                             I-need-some-OF-examples!

   loose_parts.push_back("some");

   loose_parts.push_back("OF");

   loose_parts.push_back("examples!");


   string joined_string = ofJoinString(loose_parts, "-");

   cout << joined_string << endl;
string
                                                                            manipulation
Is a string in a string?
bool ofIsStringInString(string haystack, string needle)





    string haystack_str = "I'm searching for a needle in this haystack";

    if(ofIsStringInString(haystack_str, "searching")) {

    
     cout << "yes, 'searching' is in the string" << endl;

    }




    Result
    yes, 'searching' is in the string
string
                                                                  manipulation
Case conversion
string ofToUpper(const string& src)
string ofToLower(const string& src)




                  
   string str = "Just some string";
                  
   cout << ofToLower(str) << " = ofToLower" << endl;
                  
   cout << ofToUpper(str) << " = ofToUpper" << endl;




 Result
 just some string = ofToLower
 JUST SOME STRING = ofToUpper
string
                                                  manipulation
Type / hex conversion


                                          Convert int,ļ¬‚oat,uint,char,??
        string ofToString(const T&)
                                                    to string


        string ofToHex(string|char)


       int ofHexToInt(const string&)


    string ofHexToChar(const string&)


     ļ¬‚oat ofHexToFloat(const string&)


    string ofHexToString(const string&)
string
                                                 manipulation
String conversions


                                         Convert int,ļ¬‚oat,uint,char,??
       string ofToString(const T&)
                                                   to string



       int ofToInt(const string& str)        Convert string to int


     char ofToChar(const string& str)       Convert string to char


     ļ¬‚oat ofToFloat(const string& str)      Convert string to ļ¬‚oat


     bool ofToBool(const string& str)       Convert string to bool
string
                                                 manipulation
Binary utils




    string ofToBinary(const string& str)       String to binary

     int ofBinaryToInt(const string& str)    From binary to int

   char ofBinaryToChar(const string& str)    From binary to char

   ļ¬‚oat ofBinaryToFloat(const string& str)   From binary to ļ¬‚oat
screenshots
Screenshots


                                          Save whatā€™s drawn to a ļ¬le
                                         named by the current frame.
           void ofSaveFrame()
                                         The ļ¬le is saved into the data
                                                   directory.



                                         Save the current screen to a
    void ofSaveScreen(string ļ¬lename)
                                          ļ¬le in the data directory.



   void ofSaveViewport(string ļ¬lename)   Save current viewport to ļ¬le
screenshots
 Screenshots



void testApp::draw(){

 // create filename (each call we increment the counter)

 static int screen_num = 0;

 ++screen_num;

 char buf[512];

 sprintf(buf,"screen_%04d.jpg",screen_num);


 // draw a simple circle at the center of screen and save it to image file.

 ofCircle(ofGetWidth() *0.5,ofGetHeight()*0.5,40);

 ofSaveScreen(buf);
}
screenshots
 Screenshots



void testApp::draw(){

 // create filename (each call we increment the counter)

 static int screen_num = 0;

 ++screen_num;

 char buf[512];

 sprintf(buf,"screen_%04d.jpg",screen_num);


 // draw a simple circle at the center of screen and save it to image file.

 ofCircle(ofGetWidth() *0.5,ofGetHeight()*0.5,40);

 ofSaveScreen(buf);
}
remote loading
Load from url (synchronous)


                         ofHttpResponse ofLoadURL(string url)



          ofHttpResponse resp = ofLoadURL("http://roxlu.com/ofloadurl.txt");
          cout << resp.data << endl;
          




Result
This is just a test!
remote loading
Load from url (async)


              int ofLoadURLAsync(string url, string name)




ā€¢ Loads asynchronous
ā€¢ Returns ID of process
ā€¢ You need to listen for URL notiļ¬cations in
  testApp::urlResponse(ofHttpResponse&)
remote loading
Asynchronous loading


 Step 1. declare urlResponse in class header which wants to get notiļ¬cations


 class testApp : public ofBaseApp{
 
 public:
 
 
      void urlResponse(ofHttpResponse & response);
 }




Step 2. deļ¬ne urlResponse in class which wants to get notiļ¬cations


void testApp::urlResponse(ofHttpResponse & response){

 if(response.status==200 && response.request.name == "async_req"){

 
      img.loadImage(response.data);

 
      loading=false;

 }

 else{

 
      cout << response.status << " " << response.error << endl;

 
      if(response.status!=-1) loading=false;

 }
}
Asynchronous loading                             remote loading



Step 3. enable URL notiļ¬cations

void testApp::setup(){

 ofRegisterURLNotification(this);
}




Recap URL loading functions
ofHttpResponse ofLoadURL(string url)
int ofLoadURLAsync(string url, string name=ā€ā€)
void ofRemoveURLRequest(int id)
void ofRemoveAllURLRequests()
threading




Threading in OF
ā€¢ Very easy to create threads using ofThread
ā€¢ Locking using lock/unlock() functions
ā€¢ Easy start/stop/joining
ā€¢ Just implement threadedFunction()
ā€¢ I.e. used to perform background processes
threading
Creating a thread


Step 1. Create your thread class which extends ofThread

class MyCustomThread : public ofThread {
protected:

 virtual void threadedFunction() {

 
     while(true) {

 
     
   cout << "My own custom thread!" << endl;

 
     
   ofSleepMillis(3000);

 
     }

 }
};



Step 2. Create member in testApp.h

class testApp : public ofBaseApp{

 public:

 
      MyCustomThread my_thread;

 
      ...
}
threading
Creating a thread




Step 3. Start the thread by calling startThread()

void testApp::setup(){

 // creates a non-blocking thread. (not verbose)

 my_thread.startThread(false, false);
}
system tools
System tools


       void ofSystemAlertDialog(string)         Show system Alert window



 ofFileDialogResult ofSystemLoadDialog(string    Show system File Load
       windowtitle, bool folderselection)              window


 ofFileDialogResult ofSystemSaveDialog(string     Show system File Save
       defaultname, string messagename)                 window
system tools
System tools




               void testApp::setup(){
               
 ofSystemAlertDialog("Whoot! Look out!");
               }
system tools
System tools




  ofFileDialogResult dialog_result = ofSystemLoadDialog("Load image",false);
  if(dialog_result.bSuccess) {
  
 cout << "name: " << dialog_result.getName() << endl;
  
 cout << "file path: " << dialog_result.getPath() << endl;
  }
noise
Simplex noise

                                             1D, 2D, 3D and 4D
ļ¬‚oat   ofNoise(ļ¬‚oat)
                                             simplex noise.
ļ¬‚oat   ofNoise(ļ¬‚oat, ļ¬‚oat)
                                             Returns values in
ļ¬‚oat   ofNoise(ļ¬‚oat, ļ¬‚oat, ļ¬‚oat)
                                             range
ļ¬‚oat   ofNoise(ļ¬‚oat, ļ¬‚oat,ļ¬‚oat,ļ¬‚oat)
                                             0.0 - 1.0
                                             1D, 2D, 3D and 4D
ļ¬‚oat   ofSignedNoise(ļ¬‚oat)
                                             simplex noise.
ļ¬‚oat   ofSignedNoise(ļ¬‚oat, ļ¬‚oat)
                                             Returns values in
ļ¬‚oat   ofSignedNoise(ļ¬‚oat, ļ¬‚oat, ļ¬‚oat)
                                             range
ļ¬‚oat   ofSignedNoise(ļ¬‚oat, ļ¬‚oat,ļ¬‚oat,ļ¬‚oat)
                                             -1.0 - 1.0
noise
Simplex noise

                                                            float scale = 0.001;



                                                            float scale = 0.01;




                                                            float scale = 0.1;



                                                            float scale = 0.7;



            void testApp::draw(){
            
 float scale = 0.001;
            
 glBegin(GL_LINE_STRIP);
            
 for(float i = 0; i < ofGetWidth(); ++i) {
            
 
      glVertex2f(i,ofNoise(i*scale) * 50);
            
 }
            
 glEnd();
            }
logging
 Logging




ā€¢ Simple logging to console or ļ¬le
ā€¢ Support for basic log levels
ā€¢ Log level ļ¬ltering
ā€¢ More advanced stuff, see ofxLogger
  (ļ¬le rotation)
logging
Logging

                                       Set level to log. Only this
    void ofSetLogLevel(ofLogLevel)   level will show up in console
                                                  or ļ¬le

      ofLogLevel ofGetLogLevel()         Get current log level



     void ofLogToFile(string path)           Log to path



          void ofLogToConsole()        Log to console (default)
logging
Logging


                ofSetLogLevel(OF_LOG_VERBOSE);
                ofLog(OF_LOG_VERBOSE,"log something");
                ofLog(OF_LOG_VERBOSE,"Something to log");
                ofLog(OF_LOG_VERBOSE,"Something else to log");
                




Result
OF: OF_VERBOSE: log something
OF: OF_VERBOSE: Something to log
OF: OF_VERBOSE: Something else to log
logging
Logging

                                       Set level to log. Only this
    void ofSetLogLevel(ofLogLevel)   level will show up in console
                                                  or ļ¬le

      ofLogLevel ofGetLogLevel()         Get current log level



     void ofLogToFile(string path)           Log to path



          void ofLogToConsole()        Log to console (default)
ļ¬le utils
File utils


   ofBuffer    Raw byte buffer class


  ofFilePath   A ļ¬le system path


    ofFile     File class; handy functions


 ofDirectory   Directory class; i.e. dirlists
ļ¬le utils

                                                                  ofBuffer
 ofBuffer




ā€¢ Allows you to store raw data
ā€¢ This is useful when working on networked
    applications or hardware (arduino) when you want to
    use a custom protocol.


Two handy global functions:
ofBuffer ofBufferFromFile(const string& p, bool binary = false)
bool ofBufferToFile(const string& p, ofBuffer& buf, bool bin=false);
ļ¬le utils

                                                                             ofBuffer
    ofBuffer



    string data = "This isnjust a bunchnof rawndata withn somenline breaks.";

    ofBuffer buffer;

    buffer.set(data.c_str(), data.size());

    while(!buffer.isLastLine()) {

    
    cout << "Buffer line: " << buffer.getNextLine() << endl;

    }




    Result
    Buffer   line:   This is
    Buffer   line:   just a bunch
    Buffer   line:   of raw
    Buffer   line:   data with
    Buffer   line:    some
    Buffer   line:   line breaks.
ļ¬le utils

                                                ofBuffer
read ļ¬le into buffer

  // read from file into buffer

  ofBuffer buf = ofBufferFromFile("of.log");
  cout
 << "********"
 << endl

 
     
    << buf 

    << endl

 
     
    << "********"
 << endl;



Other functions...
void set(const char*, int size)
bool set(istream&)
bool writeTo(ostream &stream)
void clear()
void allocate(long)
char* getBinaryBuffer()
const char* getBinaryBuffer()
string getText()
string getNextLine()
string getFirstLine()
bool isLastLine()
ļ¬le utils

                                         ofFilePath
 File paths




ā€¢ Just easy class to play with paths
ā€¢ Use this for cleaning up paths, retrieving absolute
  paths, retrieving basenames, ļ¬lenames, enclosing
  directories, current working dir.

ā€¢ All member functions are static
ļ¬le utils

                                                                      ofFilePath
File paths
static string getFileExt(string ļ¬lename)

static string removeExt(string ļ¬lename)

static string addLeadingSlash(string path)

static string addTrailingSlash(string path)

static string removeTrailingSlash(string path)

static string getPathForDirectory(string path)

static string getAbsolutePath(string path, bool rel_data = true)

static bool isAbsolute(string path)

static string getFileName(string f,bool rel_data = true)

static string getBaseName(string ļ¬le)
static string getEnclosingDirectory(string p, bool rel_data = true)

static string getCurrentWorkingDirectory()
ļ¬le utils

                                                          ofFilePath
File paths

cout << ofFilePath::getPathForDirectory("~/Documents");
/Users/roxlu/Documents/


cout << ofFilePath::getPathForDirectory("data");
data/


string path = "/just/some/path/photo.jpg";
cout << ofFilePath::getFileExt(path);
jpg

string path = "/just/some/path/photo.jpg";
cout << ofFilePath::removeExt(path);
/just/some/path/photo


string path = "/just/some/path/photo.jpg";
cout << ofFilePath::getFilename(path) << endl;
photo.jpg
ļ¬le utils

                                                             ofFilePath
File paths
string path = "/just/some/path/photo.jpg";
cout << ofFilePath::getBaseName(path) << endl;
photo


string path = "/just/some/path/photo.jpg";
cout << ofFilePath::getEnclosingDirectory(path) << endl;

/just/some/path/


cout << ofFilePath::getCurrentWorkingDirectory() << endl;
/Users/roxlu/Documents/programming/c++/of/git/apps/examples/emptyExample/bin/
emptyExampleDebug.app/Contents/MacOS/
ļ¬le utils

                                                                           ofFile
ofFile
bool open(string path, Mode m=ReadOnly, bool binary=false)

bool changeMode(Mode m, bool binary=false)


void close()                                      bool canExecute()
bool exists()                                     bool isFile()
string path()                                     bool isLink()
string getExtension()                             bool isDirectory()
string getFileName()                              bool isDevice(
string getBaseName()                              bool isHidden
string getEnclosingDirectory()                    void setWriteble(bool writable)
string getAbsolutePath()                          void setReadOnly(bool readable)
bool canRead()                                    void setExecutable(bool exec)
bool canWrite()                                   uint64_t getSize()
ļ¬le utils

                                                                               ofFile

ofFile
bool copyTo(string path, bool rel_to_data = true, bool overwrite = false)
bool moveTo(string path, bool rel_to_data = true, bool overwrite = false)
bool renameTo(string path, bool rel_to_data = true, bool overwrite = false)




ofFile <> ofBuffer
ofBuffer readToBuffer()
bool writeFromBuffer(ofBuffer& buffer)
bool renameTo(string path, bool rel_to_data = true, bool overwrite = false)
ļ¬le utils

                                                                                                    ofFile
ofFile - static functions


static bool copyFromTo(string src, string dest, bool rel_to_data = true, bool overwrite = false)
static bool moveFromTo(string src, string dest, bool rel_to_data = true, bool overwrite = false)
static bool doesFileExist(string path,bool rel_to_data = true)
static bool removeFile(string path,bool rel_to_data = true)
ļ¬le utils

                                                           ofDirectory
ofDirectory

ā€¢ Similar to ofFile
ā€¢ Lots of handy function for moving, renaming,
     copying, deleting, ļ¬le listing, etc...
void open(string path)               void setWriteble(bool writable)
void close()
                                     void setReadOnly(bool readable)
bool create(bool recursive = true)
bool exists()                        void setExecutable(bool exec)
string path()
                                     For more functions ofFileUtils.h
bool canRead()
bool canWrite()
bool canExecute()
bool isDirectory()
bool isHidden()
bool remove(bool recursive)
ļ¬le utils

                                                                                  ofDirectory


Retrieve all jpegs from a directory
ofDirectory dir;
dir.allowExt("jpg");
int num_jpegs_in_datapath = dir.listDir(ofToDataPath(".",true));
cout << "Num files in data path : " << num_jpegs_in_datapath << endl;
for(int i = 0; i < num_jpegs_in_datapath; ++i) {

 cout << dir.getPath(i) << endl;
}




Result
/Users/roxlu/Documents/programming/c++/of/git/apps/examples/emptyExample/bin/data/screen_0001.jpg
/Users/roxlu/Documents/programming/c++/of/git/apps/examples/emptyExample/bin/data/screen_0002.jpg
/Users/roxlu/Documents/programming/c++/of/git/apps/examples/emptyExample/bin/data/screen_0003.jpg
/Users/roxlu/Documents/programming/c++/of/git/apps/examples/emptyExample/bin/data/screen_0004.jpg
/Users/roxlu/Documents/programming/c++/of/git/apps/examples/emptyExample/bin/data/screen_0005.jpg
/Users/roxlu/Documents/programming/c++/of/git/apps/examples/emptyExample/bin/data/screen_0006.jpg
ļ¬le utils

                                                                                            ofDirectory
Some static functions



static bool createDirectory(string path, bool rel_to_data = true, bool recursive = false)

static bool isDirectoryEmtpy(string path, bool rel_to_data = true)

static bool doesDirectoryExist(string path, bool rel_to_data = true)

static bool removeDirectory(string path, bool deleteIfNotEmpty, bool bRelativeToData = true)
constants



Development        Math/Trig
OF_VERSION         HALF_PI      CLAMP(val,min,max)

OF_VERSION_MINOR   PI           ABS(x)

TARGET_WIN32       TWO_PI
                                OF_OUTLINE
TARGET_OF_IPHONE   FOUR_PI
                                OF_FILLED
TARGET_ANDROID     DEG_TO_RAD

TARGET_LINUS       RAD_TO_DEG   Window
TARGET_OPENGLES    MIN(x,y)     OF_WINDOW
                                OF_FULLSCREEN
OF_USING_POCO      MAX(x,y)
                                OF_GAME_MODE
constants


Rectangle modes        Pixel formats      Blend modes
OF_RECTMODE_CORNER
                       OF_PIXELS_MONO     OF_BLENDMODE_DISABLED

OF_RECTMODE_CENTER
                       OF_PIXELS_RGB      OF_BLENDMODE_ALPHA

                       OF_PIXELS_RGBA     OF_BLENDMODE_ADD
Image types
                       OF_PIXELS_BGRA     OF_BLENDMODE_SUBTRACT
OF_IMAGE_GRAYSCALE
                       OF_PIXELS_RGB565   OF_BLENDMODE_MULTIPLY
OF_IMAGE_COLOR

                                          OF_BLENDMODE_SCREEN
OF_IMAGE_COLOR_ALPHA

OF_IMAGE_UNDEFINED
constants


Orientations                      ofLoopType

OF_ORIENTATION_UNKNOWN            OF_LOOP_NONE

OF_ORIENTATION_DEFAULT            OF_LOOP_PALINDROME

OF_ORIENTATION_90_LEFT            OF_LOOP_NORMAL


OF_ORIENTATION_180

OF_ORIENTATION_90_RIGHT




For more deļ¬nes see ofConstants
constants

Function keys                           Cursor keys

OF_KEY_F1                               OF_KEY_LEFT

OF_KEY_F2                               OF_KEY_RIGHT

...                                     OF_KEY_DOWN

OF_KEY_F12                              OF_KEY_UP



Special keys

OF_KEY_PAGE_UP          OF_KEY_INSERT      OF_KEY_ALT

OF_KEY_PAGE_DOWN        OF_KEY_RETURN      OF_KEY_SHIFT

OF_KEY_HOME             OF_KEY_ESC         OF_KEY_BACKSPACE

OF_KEY_END              OF_KEY_CTRL        OF_KEY_DEL

For more deļ¬nes see ofConstants
roxlu
www.roxlu.com

More Related Content

What's hot

Rainer Grimm, ā€œFunctional Programming in C++11ā€
Rainer Grimm, ā€œFunctional Programming in C++11ā€Rainer Grimm, ā€œFunctional Programming in C++11ā€
Rainer Grimm, ā€œFunctional Programming in C++11ā€Platonov Sergey
Ā 
The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)jeffz
Ā 
响åŗ”式ē¼–ēØ‹åŠę”†ęž¶
响åŗ”式ē¼–ēØ‹åŠę”†ęž¶å“åŗ”式ē¼–ēØ‹åŠę”†ęž¶
响åŗ”式ē¼–ēØ‹åŠę”†ęž¶jeffz
Ā 
Better Software: introduction to good code
Better Software: introduction to good codeBetter Software: introduction to good code
Better Software: introduction to good codeGiordano Scalzo
Ā 
Stamps - a better way to object composition
Stamps - a better way to object compositionStamps - a better way to object composition
Stamps - a better way to object compositionVasyl Boroviak
Ā 
ę·±å…„ęµ…å‡ŗJscex
ę·±å…„ęµ…å‡ŗJscexę·±å…„ęµ…å‡ŗJscex
ę·±å…„ęµ…å‡ŗJscexjeffz
Ā 
Jscex: Write Sexy JavaScript (äø­ę–‡)
Jscex: Write Sexy JavaScript (äø­ę–‡)Jscex: Write Sexy JavaScript (äø­ę–‡)
Jscex: Write Sexy JavaScript (äø­ę–‡)jeffz
Ā 
6.1.1äø€ę­„äø€ę­„å­¦repast代ē č§£é‡Š
6.1.1äø€ę­„äø€ę­„å­¦repast代ē č§£é‡Š6.1.1äø€ę­„äø€ę­„å­¦repast代ē č§£é‡Š
6.1.1äø€ę­„äø€ę­„å­¦repast代ē č§£é‡Šzhang shuren
Ā 
Jscex: Write Sexy JavaScript
Jscex: Write Sexy JavaScriptJscex: Write Sexy JavaScript
Jscex: Write Sexy JavaScriptjeffz
Ā 
Bartosz Milewski, ā€œRe-discovering Monads in C++ā€
Bartosz Milewski, ā€œRe-discovering Monads in C++ā€Bartosz Milewski, ā€œRe-discovering Monads in C++ā€
Bartosz Milewski, ā€œRe-discovering Monads in C++ā€Platonov Sergey
Ā 
Groovy vs Boilerplate and Ceremony Code
Groovy vs Boilerplate and Ceremony CodeGroovy vs Boilerplate and Ceremony Code
Groovy vs Boilerplate and Ceremony Codestasimus
Ā 
The Macronomicon
The MacronomiconThe Macronomicon
The MacronomiconMike Fogus
Ā 
The Ring programming language version 1.5.4 book - Part 59 of 185
The Ring programming language version 1.5.4 book - Part 59 of 185The Ring programming language version 1.5.4 book - Part 59 of 185
The Ring programming language version 1.5.4 book - Part 59 of 185Mahmoud Samir Fayed
Ā 
Š”тŠ°Ń‚ŠøчŠ½Ń‹Š¹ SQL Š² Š”++14. Š•Š²Š³ŠµŠ½ŠøŠ¹ Š—Š°Ń…Š°Ń€Š¾Š² āž  CoreHard Autumn 2019
Š”тŠ°Ń‚ŠøчŠ½Ń‹Š¹ SQL Š² Š”++14. Š•Š²Š³ŠµŠ½ŠøŠ¹ Š—Š°Ń…Š°Ń€Š¾Š² āž   CoreHard Autumn 2019Š”тŠ°Ń‚ŠøчŠ½Ń‹Š¹ SQL Š² Š”++14. Š•Š²Š³ŠµŠ½ŠøŠ¹ Š—Š°Ń…Š°Ń€Š¾Š² āž   CoreHard Autumn 2019
Š”тŠ°Ń‚ŠøчŠ½Ń‹Š¹ SQL Š² Š”++14. Š•Š²Š³ŠµŠ½ŠøŠ¹ Š—Š°Ń…Š°Ń€Š¾Š² āž  CoreHard Autumn 2019corehard_by
Ā 
Academy PRO: ES2015
Academy PRO: ES2015Academy PRO: ES2015
Academy PRO: ES2015Binary Studio
Ā 
Š”Š°Š¼Ń‹Šµ Š²ŠŗусŠ½Ń‹Šµ Š±Š°Š³Šø ŠøŠ· ŠøŠ³Ń€Š¾Š²Š¾Š³Š¾ ŠŗŠ¾Š“Š°: ŠŗŠ°Šŗ Š¾ŃˆŠøŠ±Š°ŃŽŃ‚ся Š½Š°ŃˆŠø ŠŗŠ¾Š»Š»ŠµŠ³Šø-ŠæрŠ¾Š³Ń€Š°Š¼Š¼Šøсты ...
Š”Š°Š¼Ń‹Šµ Š²ŠŗусŠ½Ń‹Šµ Š±Š°Š³Šø ŠøŠ· ŠøŠ³Ń€Š¾Š²Š¾Š³Š¾ ŠŗŠ¾Š“Š°: ŠŗŠ°Šŗ Š¾ŃˆŠøŠ±Š°ŃŽŃ‚ся Š½Š°ŃˆŠø ŠŗŠ¾Š»Š»ŠµŠ³Šø-ŠæрŠ¾Š³Ń€Š°Š¼Š¼Šøсты ...Š”Š°Š¼Ń‹Šµ Š²ŠŗусŠ½Ń‹Šµ Š±Š°Š³Šø ŠøŠ· ŠøŠ³Ń€Š¾Š²Š¾Š³Š¾ ŠŗŠ¾Š“Š°: ŠŗŠ°Šŗ Š¾ŃˆŠøŠ±Š°ŃŽŃ‚ся Š½Š°ŃˆŠø ŠŗŠ¾Š»Š»ŠµŠ³Šø-ŠæрŠ¾Š³Ń€Š°Š¼Š¼Šøсты ...
Š”Š°Š¼Ń‹Šµ Š²ŠŗусŠ½Ń‹Šµ Š±Š°Š³Šø ŠøŠ· ŠøŠ³Ń€Š¾Š²Š¾Š³Š¾ ŠŗŠ¾Š“Š°: ŠŗŠ°Šŗ Š¾ŃˆŠøŠ±Š°ŃŽŃ‚ся Š½Š°ŃˆŠø ŠŗŠ¾Š»Š»ŠµŠ³Šø-ŠæрŠ¾Š³Ń€Š°Š¼Š¼Šøсты ...DevGAMM Conference
Ā 
Javascript Uncommon Programming
Javascript Uncommon ProgrammingJavascript Uncommon Programming
Javascript Uncommon Programmingjeffz
Ā 
Functional microscope - Lenses in C++
Functional microscope - Lenses in C++Functional microscope - Lenses in C++
Functional microscope - Lenses in C++Alexander Granin
Ā 

What's hot (20)

Rainer Grimm, ā€œFunctional Programming in C++11ā€
Rainer Grimm, ā€œFunctional Programming in C++11ā€Rainer Grimm, ā€œFunctional Programming in C++11ā€
Rainer Grimm, ā€œFunctional Programming in C++11ā€
Ā 
The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)
Ā 
响åŗ”式ē¼–ēØ‹åŠę”†ęž¶
响åŗ”式ē¼–ēØ‹åŠę”†ęž¶å“åŗ”式ē¼–ēØ‹åŠę”†ęž¶
响åŗ”式ē¼–ēØ‹åŠę”†ęž¶
Ā 
Better Software: introduction to good code
Better Software: introduction to good codeBetter Software: introduction to good code
Better Software: introduction to good code
Ā 
Stamps - a better way to object composition
Stamps - a better way to object compositionStamps - a better way to object composition
Stamps - a better way to object composition
Ā 
ę·±å…„ęµ…å‡ŗJscex
ę·±å…„ęµ…å‡ŗJscexę·±å…„ęµ…å‡ŗJscex
ę·±å…„ęµ…å‡ŗJscex
Ā 
Jscex: Write Sexy JavaScript (äø­ę–‡)
Jscex: Write Sexy JavaScript (äø­ę–‡)Jscex: Write Sexy JavaScript (äø­ę–‡)
Jscex: Write Sexy JavaScript (äø­ę–‡)
Ā 
6.1.1äø€ę­„äø€ę­„å­¦repast代ē č§£é‡Š
6.1.1äø€ę­„äø€ę­„å­¦repast代ē č§£é‡Š6.1.1äø€ę­„äø€ę­„å­¦repast代ē č§£é‡Š
6.1.1äø€ę­„äø€ę­„å­¦repast代ē č§£é‡Š
Ā 
Jscex: Write Sexy JavaScript
Jscex: Write Sexy JavaScriptJscex: Write Sexy JavaScript
Jscex: Write Sexy JavaScript
Ā 
Bartosz Milewski, ā€œRe-discovering Monads in C++ā€
Bartosz Milewski, ā€œRe-discovering Monads in C++ā€Bartosz Milewski, ā€œRe-discovering Monads in C++ā€
Bartosz Milewski, ā€œRe-discovering Monads in C++ā€
Ā 
Ds 2 cycle
Ds 2 cycleDs 2 cycle
Ds 2 cycle
Ā 
Groovy vs Boilerplate and Ceremony Code
Groovy vs Boilerplate and Ceremony CodeGroovy vs Boilerplate and Ceremony Code
Groovy vs Boilerplate and Ceremony Code
Ā 
The Macronomicon
The MacronomiconThe Macronomicon
The Macronomicon
Ā 
The Ring programming language version 1.5.4 book - Part 59 of 185
The Ring programming language version 1.5.4 book - Part 59 of 185The Ring programming language version 1.5.4 book - Part 59 of 185
The Ring programming language version 1.5.4 book - Part 59 of 185
Ā 
Š”тŠ°Ń‚ŠøчŠ½Ń‹Š¹ SQL Š² Š”++14. Š•Š²Š³ŠµŠ½ŠøŠ¹ Š—Š°Ń…Š°Ń€Š¾Š² āž  CoreHard Autumn 2019
Š”тŠ°Ń‚ŠøчŠ½Ń‹Š¹ SQL Š² Š”++14. Š•Š²Š³ŠµŠ½ŠøŠ¹ Š—Š°Ń…Š°Ń€Š¾Š² āž   CoreHard Autumn 2019Š”тŠ°Ń‚ŠøчŠ½Ń‹Š¹ SQL Š² Š”++14. Š•Š²Š³ŠµŠ½ŠøŠ¹ Š—Š°Ń…Š°Ń€Š¾Š² āž   CoreHard Autumn 2019
Š”тŠ°Ń‚ŠøчŠ½Ń‹Š¹ SQL Š² Š”++14. Š•Š²Š³ŠµŠ½ŠøŠ¹ Š—Š°Ń…Š°Ń€Š¾Š² āž  CoreHard Autumn 2019
Ā 
Academy PRO: ES2015
Academy PRO: ES2015Academy PRO: ES2015
Academy PRO: ES2015
Ā 
YUI Tidbits
YUI TidbitsYUI Tidbits
YUI Tidbits
Ā 
Š”Š°Š¼Ń‹Šµ Š²ŠŗусŠ½Ń‹Šµ Š±Š°Š³Šø ŠøŠ· ŠøŠ³Ń€Š¾Š²Š¾Š³Š¾ ŠŗŠ¾Š“Š°: ŠŗŠ°Šŗ Š¾ŃˆŠøŠ±Š°ŃŽŃ‚ся Š½Š°ŃˆŠø ŠŗŠ¾Š»Š»ŠµŠ³Šø-ŠæрŠ¾Š³Ń€Š°Š¼Š¼Šøсты ...
Š”Š°Š¼Ń‹Šµ Š²ŠŗусŠ½Ń‹Šµ Š±Š°Š³Šø ŠøŠ· ŠøŠ³Ń€Š¾Š²Š¾Š³Š¾ ŠŗŠ¾Š“Š°: ŠŗŠ°Šŗ Š¾ŃˆŠøŠ±Š°ŃŽŃ‚ся Š½Š°ŃˆŠø ŠŗŠ¾Š»Š»ŠµŠ³Šø-ŠæрŠ¾Š³Ń€Š°Š¼Š¼Šøсты ...Š”Š°Š¼Ń‹Šµ Š²ŠŗусŠ½Ń‹Šµ Š±Š°Š³Šø ŠøŠ· ŠøŠ³Ń€Š¾Š²Š¾Š³Š¾ ŠŗŠ¾Š“Š°: ŠŗŠ°Šŗ Š¾ŃˆŠøŠ±Š°ŃŽŃ‚ся Š½Š°ŃˆŠø ŠŗŠ¾Š»Š»ŠµŠ³Šø-ŠæрŠ¾Š³Ń€Š°Š¼Š¼Šøсты ...
Š”Š°Š¼Ń‹Šµ Š²ŠŗусŠ½Ń‹Šµ Š±Š°Š³Šø ŠøŠ· ŠøŠ³Ń€Š¾Š²Š¾Š³Š¾ ŠŗŠ¾Š“Š°: ŠŗŠ°Šŗ Š¾ŃˆŠøŠ±Š°ŃŽŃ‚ся Š½Š°ŃˆŠø ŠŗŠ¾Š»Š»ŠµŠ³Šø-ŠæрŠ¾Š³Ń€Š°Š¼Š¼Šøсты ...
Ā 
Javascript Uncommon Programming
Javascript Uncommon ProgrammingJavascript Uncommon Programming
Javascript Uncommon Programming
Ā 
Functional microscope - Lenses in C++
Functional microscope - Lenses in C++Functional microscope - Lenses in C++
Functional microscope - Lenses in C++
Ā 

Similar to openFrameworks 007 - utils

#includeiostream#includestack#includestring #include .pdf
#includeiostream#includestack#includestring #include .pdf#includeiostream#includestack#includestring #include .pdf
#includeiostream#includestack#includestring #include .pdfsrinivas9922
Ā 
Java binary subtraction
Java binary subtractionJava binary subtraction
Java binary subtractionCharm Sasi
Ā 
Java programs - bubble sort, iterator, linked list, hash set, reverse string,...
Java programs - bubble sort, iterator, linked list, hash set, reverse string,...Java programs - bubble sort, iterator, linked list, hash set, reverse string,...
Java programs - bubble sort, iterator, linked list, hash set, reverse string,...Sunil Kumar Gunasekaran
Ā 
JJUG CCC 2011 Spring
JJUG CCC 2011 SpringJJUG CCC 2011 Spring
JJUG CCC 2011 SpringKiyotaka Oku
Ā 
Creating custom views
Creating custom viewsCreating custom views
Creating custom viewsMu Chun Wang
Ā 
Collection v3
Collection v3Collection v3
Collection v3Sunil OS
Ā 
public class TrequeT extends AbstractListT { .pdf
  public class TrequeT extends AbstractListT {  .pdf  public class TrequeT extends AbstractListT {  .pdf
public class TrequeT extends AbstractListT { .pdfinfo30292
Ā 
Computer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfComputer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfHIMANSUKUMAR12
Ā 
The Groovy Puzzlers ā€“ The Complete 01 and 02 Seasons
The Groovy Puzzlers ā€“ The Complete 01 and 02 SeasonsThe Groovy Puzzlers ā€“ The Complete 01 and 02 Seasons
The Groovy Puzzlers ā€“ The Complete 01 and 02 SeasonsBaruch Sadogursky
Ā 
The Ring programming language version 1.9 book - Part 53 of 210
The Ring programming language version 1.9 book - Part 53 of 210The Ring programming language version 1.9 book - Part 53 of 210
The Ring programming language version 1.9 book - Part 53 of 210Mahmoud Samir Fayed
Ā 
Import java
Import javaImport java
Import javaheni2121
Ā 
The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196Mahmoud Samir Fayed
Ā 
Cppt 101102014428-phpapp01
Cppt 101102014428-phpapp01Cppt 101102014428-phpapp01
Cppt 101102014428-phpapp01Getachew Ganfur
Ā 
The Ring programming language version 1.3 book - Part 34 of 88
The Ring programming language version 1.3 book - Part 34 of 88The Ring programming language version 1.3 book - Part 34 of 88
The Ring programming language version 1.3 book - Part 34 of 88Mahmoud Samir Fayed
Ā 
Reactive programming with RxJS - ByteConf 2018
Reactive programming with RxJS - ByteConf 2018Reactive programming with RxJS - ByteConf 2018
Reactive programming with RxJS - ByteConf 2018Tracy Lee
Ā 
Google App Engine Developer - Day3
Google App Engine Developer - Day3Google App Engine Developer - Day3
Google App Engine Developer - Day3Simon Su
Ā 
Groovy puzzlers ŠæŠ¾ руссŠŗŠø с Joker 2014
Groovy puzzlers ŠæŠ¾ руссŠŗŠø с Joker 2014Groovy puzzlers ŠæŠ¾ руссŠŗŠø с Joker 2014
Groovy puzzlers ŠæŠ¾ руссŠŗŠø с Joker 2014Baruch Sadogursky
Ā 

Similar to openFrameworks 007 - utils (20)

#includeiostream#includestack#includestring #include .pdf
#includeiostream#includestack#includestring #include .pdf#includeiostream#includestack#includestring #include .pdf
#includeiostream#includestack#includestring #include .pdf
Ā 
Google Guava
Google GuavaGoogle Guava
Google Guava
Ā 
Java binary subtraction
Java binary subtractionJava binary subtraction
Java binary subtraction
Ā 
Java programs - bubble sort, iterator, linked list, hash set, reverse string,...
Java programs - bubble sort, iterator, linked list, hash set, reverse string,...Java programs - bubble sort, iterator, linked list, hash set, reverse string,...
Java programs - bubble sort, iterator, linked list, hash set, reverse string,...
Ā 
JJUG CCC 2011 Spring
JJUG CCC 2011 SpringJJUG CCC 2011 Spring
JJUG CCC 2011 Spring
Ā 
Creating custom views
Creating custom viewsCreating custom views
Creating custom views
Ā 
Collection v3
Collection v3Collection v3
Collection v3
Ā 
Java programs
Java programsJava programs
Java programs
Ā 
public class TrequeT extends AbstractListT { .pdf
  public class TrequeT extends AbstractListT {  .pdf  public class TrequeT extends AbstractListT {  .pdf
public class TrequeT extends AbstractListT { .pdf
Ā 
ES6 Overview
ES6 OverviewES6 Overview
ES6 Overview
Ā 
Computer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfComputer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdf
Ā 
The Groovy Puzzlers ā€“ The Complete 01 and 02 Seasons
The Groovy Puzzlers ā€“ The Complete 01 and 02 SeasonsThe Groovy Puzzlers ā€“ The Complete 01 and 02 Seasons
The Groovy Puzzlers ā€“ The Complete 01 and 02 Seasons
Ā 
The Ring programming language version 1.9 book - Part 53 of 210
The Ring programming language version 1.9 book - Part 53 of 210The Ring programming language version 1.9 book - Part 53 of 210
The Ring programming language version 1.9 book - Part 53 of 210
Ā 
Import java
Import javaImport java
Import java
Ā 
The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196
Ā 
Cppt 101102014428-phpapp01
Cppt 101102014428-phpapp01Cppt 101102014428-phpapp01
Cppt 101102014428-phpapp01
Ā 
The Ring programming language version 1.3 book - Part 34 of 88
The Ring programming language version 1.3 book - Part 34 of 88The Ring programming language version 1.3 book - Part 34 of 88
The Ring programming language version 1.3 book - Part 34 of 88
Ā 
Reactive programming with RxJS - ByteConf 2018
Reactive programming with RxJS - ByteConf 2018Reactive programming with RxJS - ByteConf 2018
Reactive programming with RxJS - ByteConf 2018
Ā 
Google App Engine Developer - Day3
Google App Engine Developer - Day3Google App Engine Developer - Day3
Google App Engine Developer - Day3
Ā 
Groovy puzzlers ŠæŠ¾ руссŠŗŠø с Joker 2014
Groovy puzzlers ŠæŠ¾ руссŠŗŠø с Joker 2014Groovy puzzlers ŠæŠ¾ руссŠŗŠø с Joker 2014
Groovy puzzlers ŠæŠ¾ руссŠŗŠø с Joker 2014
Ā 

Recently uploaded

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
Ā 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
Ā 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
Ā 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
Ā 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
Ā 
Finology Group ā€“ Insurtech Innovation Award 2024
Finology Group ā€“ Insurtech Innovation Award 2024Finology Group ā€“ Insurtech Innovation Award 2024
Finology Group ā€“ Insurtech Innovation Award 2024The Digital Insurer
Ā 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
Ā 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
Ā 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
Ā 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
Ā 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
Ā 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
Ā 
šŸ¬ The future of MySQL is Postgres šŸ˜
šŸ¬  The future of MySQL is Postgres   šŸ˜šŸ¬  The future of MySQL is Postgres   šŸ˜
šŸ¬ The future of MySQL is Postgres šŸ˜RTylerCroy
Ā 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
Ā 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
Ā 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
Ā 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
Ā 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
Ā 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
Ā 

Recently uploaded (20)

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
Ā 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
Ā 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
Ā 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Ā 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Ā 
Finology Group ā€“ Insurtech Innovation Award 2024
Finology Group ā€“ Insurtech Innovation Award 2024Finology Group ā€“ Insurtech Innovation Award 2024
Finology Group ā€“ Insurtech Innovation Award 2024
Ā 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Ā 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
Ā 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Ā 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
Ā 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
Ā 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Ā 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Ā 
šŸ¬ The future of MySQL is Postgres šŸ˜
šŸ¬  The future of MySQL is Postgres   šŸ˜šŸ¬  The future of MySQL is Postgres   šŸ˜
šŸ¬ The future of MySQL is Postgres šŸ˜
Ā 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
Ā 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
Ā 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
Ā 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
Ā 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
Ā 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
Ā 

openFrameworks 007 - utils

  • 2. Utils date screenshots noise list helpers remote loading logging string threading ļ¬le utils manipulation system tools constants
  • 3. date int ofGetSeconds() Get seconds of current time int ofGetMinutes() Get minutes of current time int ofGetHours() Get hours of current time int ofGetYear() Get current year int ofGetMonth() Get current month int ofGetDay() Get current day int ofGetWeekDay Get current weekday unsigned int ofGetUnixTime() Timestamp since 1970 unsigned long ofGetSystemTime() System time in millis string ofGetSystemTimeMicros() System time in micros string ofGetTimestampString() Timestamp since 1970 as string
  • 4. list helpers Remove items from a vector. void ofRemove(vector<T>&, BoolFunction shouldErase) Step 1. Create a custom remove functor class MyOwnRemover{ public: bool operator()(const string& str) { return str == "roxlu"; } };
  • 5. list helpers void ofRemove(vector<T>&, BoolFunction shouldErase) Step 2. use ofRemove with remove functor void testApp::setup(){ // create list with strings. vector<string> mystrings; mystrings.push_back("diederick"); mystrings.push_back("openframeworks"); mystrings.push_back("supercool"); mystrings.push_back("roxlu"); mystrings.push_back("do not remove"); mystrings.push_back("roxlu"); // show before removing items. for(int i = 0; i < mystrings.size(); ++i) { cout << "before: " << mystrings[i] << endl; } cout << "=======" << endl; // remove items using my own remover! ofRemove(mystrings, MyOwnRemover()); for(int i = 0; i < mystrings.size(); ++i) { cout << "after: " << mystrings[i] << endl; } }
  • 6. Summary ofRemove list helpers void ofRemove(vector<T>&, BoolFunction shouldErase) class MyOwnRemover{ void testApp::setup(){ public: bool operator()(const string& str) { // create list with strings. return str == "roxlu"; vector<string> mystrings; } mystrings.push_back("diederick"); }; mystrings.push_back("openframeworks"); mystrings.push_back("supercool"); mystrings.push_back("roxlu"); mystrings.push_back("do not remove"); mystrings.push_back("roxlu"); // show before removing items. for(int i = 0; i < mystrings.size(); ++i) { Result } cout << "before: " << mystrings[i] << endl; before: diederick cout << "=======" << endl; before: openframeworks before: supercool before: roxlu before: do not remove // remove items using my own remover! before: roxlu ofRemove(mystrings, MyOwnRemover()); ======= after: diederick for(int i = 0; i < mystrings.size(); ++i) { after: openframeworks cout << "after: " << mystrings[i] << endl; after: supercool after: do not remove } }
  • 7. Randomize a vector list helpers void ofRandomize(vector<T>&) void testApp::setup(){ // create list with strings. vector<string> mystrings; mystrings.push_back("diederick"); mystrings.push_back("openframeworks"); Result mystrings.push_back("supercool"); random: roxlu mystrings.push_back("roxlu"); random: roxlu mystrings.push_back("do not remove"); random: supercool mystrings.push_back("roxlu"); random: openframeworks random: do not remove ofRandomize(mystrings); random: diederick // show before removing items. for(int i = 0; i < mystrings.size(); ++i) { cout << "random: " << mystrings[i] << endl; } }
  • 8. Sort a vector list helpers void ofSort(vector<T>&) void testApp::setup(){ // create list with strings. vector<string> mystrings; mystrings.push_back("diederick"); mystrings.push_back("openframeworks"); Result mystrings.push_back("supercool"); sorted: diederick mystrings.push_back("roxlu"); sorted: do not remove mystrings.push_back("do not remove"); sorted: openframeworks mystrings.push_back("roxlu"); sorted: roxlu sorted: roxlu ofSort(mystrings); sorted: supercool // show before removing items. for(int i = 0; i < mystrings.size(); ++i) { cout << "sorted: " << mystrings[i] << endl; } }
  • 9. Find entry in vector list helpers unsigned int ofFind(vector<T>&, const T& target) void testApp::setup(){ vector<string> mystrings; mystrings.push_back("diederick"); mystrings.push_back("openframeworks"); Result mystrings.push_back("supercool"); mystrings.push_back("roxlu"); do not remove <-- mystrings.push_back("do not remove"); mystrings.push_back("roxlu"); string fstr = "do not remove"; unsigned int num_found = ofFind(mystrings, fstr); if(num_found) { cout << mystrings[num_found] << " <-- ā€œ << endl; } }
  • 10. Check if entry exists list helpers bool ofContains(vector<T>&, const T& target) // create list with strings. vector<string> mystrings; mystrings.push_back("diederick"); mystrings.push_back("openframeworks"); Result mystrings.push_back("supercool"); mystrings.push_back("roxlu"); do not remove in mystrings mystrings.push_back("do not remove"); mystrings.push_back("roxlu"); string fstr = "do not remove"; bool contains = ofContains(mystrings, fstr); if(contains) { cout << fstr << " in mystrings" << endl; }
  • 11. string manipulation Split a string vector<string> ofSplitString( const string& source ,const string& delimiters ,bool ignoreEmpty = false ,bool trim = false ); Result string items = "one|two|three|four|five |||test|"; part: 'one' vector<string> parts = ofSplitString(items,"|",true,true); part: 'two' for(int i = 0; i < parts.size(); ++i) { part: 'three' cout << "part: '" << parts[i] << "'" << endl; part: 'four' } part: 'ļ¬ve' part: 'test'
  • 12. string manipulation Split a string vector<string> ofJoinString(vector<string>, const string delim) vector<string> loose_parts; Result loose_parts.push_back("I"); loose_parts.push_back("need"); I-need-some-OF-examples! loose_parts.push_back("some"); loose_parts.push_back("OF"); loose_parts.push_back("examples!"); string joined_string = ofJoinString(loose_parts, "-"); cout << joined_string << endl;
  • 13. string manipulation Is a string in a string? bool ofIsStringInString(string haystack, string needle) string haystack_str = "I'm searching for a needle in this haystack"; if(ofIsStringInString(haystack_str, "searching")) { cout << "yes, 'searching' is in the string" << endl; } Result yes, 'searching' is in the string
  • 14. string manipulation Case conversion string ofToUpper(const string& src) string ofToLower(const string& src) string str = "Just some string"; cout << ofToLower(str) << " = ofToLower" << endl; cout << ofToUpper(str) << " = ofToUpper" << endl; Result just some string = ofToLower JUST SOME STRING = ofToUpper
  • 15. string manipulation Type / hex conversion Convert int,ļ¬‚oat,uint,char,?? string ofToString(const T&) to string string ofToHex(string|char) int ofHexToInt(const string&) string ofHexToChar(const string&) ļ¬‚oat ofHexToFloat(const string&) string ofHexToString(const string&)
  • 16. string manipulation String conversions Convert int,ļ¬‚oat,uint,char,?? string ofToString(const T&) to string int ofToInt(const string& str) Convert string to int char ofToChar(const string& str) Convert string to char ļ¬‚oat ofToFloat(const string& str) Convert string to ļ¬‚oat bool ofToBool(const string& str) Convert string to bool
  • 17. string manipulation Binary utils string ofToBinary(const string& str) String to binary int ofBinaryToInt(const string& str) From binary to int char ofBinaryToChar(const string& str) From binary to char ļ¬‚oat ofBinaryToFloat(const string& str) From binary to ļ¬‚oat
  • 18. screenshots Screenshots Save whatā€™s drawn to a ļ¬le named by the current frame. void ofSaveFrame() The ļ¬le is saved into the data directory. Save the current screen to a void ofSaveScreen(string ļ¬lename) ļ¬le in the data directory. void ofSaveViewport(string ļ¬lename) Save current viewport to ļ¬le
  • 19. screenshots Screenshots void testApp::draw(){ // create filename (each call we increment the counter) static int screen_num = 0; ++screen_num; char buf[512]; sprintf(buf,"screen_%04d.jpg",screen_num); // draw a simple circle at the center of screen and save it to image file. ofCircle(ofGetWidth() *0.5,ofGetHeight()*0.5,40); ofSaveScreen(buf); }
  • 20. screenshots Screenshots void testApp::draw(){ // create filename (each call we increment the counter) static int screen_num = 0; ++screen_num; char buf[512]; sprintf(buf,"screen_%04d.jpg",screen_num); // draw a simple circle at the center of screen and save it to image file. ofCircle(ofGetWidth() *0.5,ofGetHeight()*0.5,40); ofSaveScreen(buf); }
  • 21. remote loading Load from url (synchronous) ofHttpResponse ofLoadURL(string url) ofHttpResponse resp = ofLoadURL("http://roxlu.com/ofloadurl.txt"); cout << resp.data << endl; Result This is just a test!
  • 22. remote loading Load from url (async) int ofLoadURLAsync(string url, string name) ā€¢ Loads asynchronous ā€¢ Returns ID of process ā€¢ You need to listen for URL notiļ¬cations in testApp::urlResponse(ofHttpResponse&)
  • 23. remote loading Asynchronous loading Step 1. declare urlResponse in class header which wants to get notiļ¬cations class testApp : public ofBaseApp{ public: void urlResponse(ofHttpResponse & response); } Step 2. deļ¬ne urlResponse in class which wants to get notiļ¬cations void testApp::urlResponse(ofHttpResponse & response){ if(response.status==200 && response.request.name == "async_req"){ img.loadImage(response.data); loading=false; } else{ cout << response.status << " " << response.error << endl; if(response.status!=-1) loading=false; } }
  • 24. Asynchronous loading remote loading Step 3. enable URL notiļ¬cations void testApp::setup(){ ofRegisterURLNotification(this); } Recap URL loading functions ofHttpResponse ofLoadURL(string url) int ofLoadURLAsync(string url, string name=ā€ā€) void ofRemoveURLRequest(int id) void ofRemoveAllURLRequests()
  • 25. threading Threading in OF ā€¢ Very easy to create threads using ofThread ā€¢ Locking using lock/unlock() functions ā€¢ Easy start/stop/joining ā€¢ Just implement threadedFunction() ā€¢ I.e. used to perform background processes
  • 26. threading Creating a thread Step 1. Create your thread class which extends ofThread class MyCustomThread : public ofThread { protected: virtual void threadedFunction() { while(true) { cout << "My own custom thread!" << endl; ofSleepMillis(3000); } } }; Step 2. Create member in testApp.h class testApp : public ofBaseApp{ public: MyCustomThread my_thread; ... }
  • 27. threading Creating a thread Step 3. Start the thread by calling startThread() void testApp::setup(){ // creates a non-blocking thread. (not verbose) my_thread.startThread(false, false); }
  • 28. system tools System tools void ofSystemAlertDialog(string) Show system Alert window ofFileDialogResult ofSystemLoadDialog(string Show system File Load windowtitle, bool folderselection) window ofFileDialogResult ofSystemSaveDialog(string Show system File Save defaultname, string messagename) window
  • 29. system tools System tools void testApp::setup(){ ofSystemAlertDialog("Whoot! Look out!"); }
  • 30. system tools System tools ofFileDialogResult dialog_result = ofSystemLoadDialog("Load image",false); if(dialog_result.bSuccess) { cout << "name: " << dialog_result.getName() << endl; cout << "file path: " << dialog_result.getPath() << endl; }
  • 31. noise Simplex noise 1D, 2D, 3D and 4D ļ¬‚oat ofNoise(ļ¬‚oat) simplex noise. ļ¬‚oat ofNoise(ļ¬‚oat, ļ¬‚oat) Returns values in ļ¬‚oat ofNoise(ļ¬‚oat, ļ¬‚oat, ļ¬‚oat) range ļ¬‚oat ofNoise(ļ¬‚oat, ļ¬‚oat,ļ¬‚oat,ļ¬‚oat) 0.0 - 1.0 1D, 2D, 3D and 4D ļ¬‚oat ofSignedNoise(ļ¬‚oat) simplex noise. ļ¬‚oat ofSignedNoise(ļ¬‚oat, ļ¬‚oat) Returns values in ļ¬‚oat ofSignedNoise(ļ¬‚oat, ļ¬‚oat, ļ¬‚oat) range ļ¬‚oat ofSignedNoise(ļ¬‚oat, ļ¬‚oat,ļ¬‚oat,ļ¬‚oat) -1.0 - 1.0
  • 32. noise Simplex noise float scale = 0.001; float scale = 0.01; float scale = 0.1; float scale = 0.7; void testApp::draw(){ float scale = 0.001; glBegin(GL_LINE_STRIP); for(float i = 0; i < ofGetWidth(); ++i) { glVertex2f(i,ofNoise(i*scale) * 50); } glEnd(); }
  • 33. logging Logging ā€¢ Simple logging to console or ļ¬le ā€¢ Support for basic log levels ā€¢ Log level ļ¬ltering ā€¢ More advanced stuff, see ofxLogger (ļ¬le rotation)
  • 34. logging Logging Set level to log. Only this void ofSetLogLevel(ofLogLevel) level will show up in console or ļ¬le ofLogLevel ofGetLogLevel() Get current log level void ofLogToFile(string path) Log to path void ofLogToConsole() Log to console (default)
  • 35. logging Logging ofSetLogLevel(OF_LOG_VERBOSE); ofLog(OF_LOG_VERBOSE,"log something"); ofLog(OF_LOG_VERBOSE,"Something to log"); ofLog(OF_LOG_VERBOSE,"Something else to log"); Result OF: OF_VERBOSE: log something OF: OF_VERBOSE: Something to log OF: OF_VERBOSE: Something else to log
  • 36. logging Logging Set level to log. Only this void ofSetLogLevel(ofLogLevel) level will show up in console or ļ¬le ofLogLevel ofGetLogLevel() Get current log level void ofLogToFile(string path) Log to path void ofLogToConsole() Log to console (default)
  • 37. ļ¬le utils File utils ofBuffer Raw byte buffer class ofFilePath A ļ¬le system path ofFile File class; handy functions ofDirectory Directory class; i.e. dirlists
  • 38. ļ¬le utils ofBuffer ofBuffer ā€¢ Allows you to store raw data ā€¢ This is useful when working on networked applications or hardware (arduino) when you want to use a custom protocol. Two handy global functions: ofBuffer ofBufferFromFile(const string& p, bool binary = false) bool ofBufferToFile(const string& p, ofBuffer& buf, bool bin=false);
  • 39. ļ¬le utils ofBuffer ofBuffer string data = "This isnjust a bunchnof rawndata withn somenline breaks."; ofBuffer buffer; buffer.set(data.c_str(), data.size()); while(!buffer.isLastLine()) { cout << "Buffer line: " << buffer.getNextLine() << endl; } Result Buffer line: This is Buffer line: just a bunch Buffer line: of raw Buffer line: data with Buffer line: some Buffer line: line breaks.
  • 40. ļ¬le utils ofBuffer read ļ¬le into buffer // read from file into buffer ofBuffer buf = ofBufferFromFile("of.log"); cout << "********" << endl << buf << endl << "********" << endl; Other functions... void set(const char*, int size) bool set(istream&) bool writeTo(ostream &stream) void clear() void allocate(long) char* getBinaryBuffer() const char* getBinaryBuffer() string getText() string getNextLine() string getFirstLine() bool isLastLine()
  • 41. ļ¬le utils ofFilePath File paths ā€¢ Just easy class to play with paths ā€¢ Use this for cleaning up paths, retrieving absolute paths, retrieving basenames, ļ¬lenames, enclosing directories, current working dir. ā€¢ All member functions are static
  • 42. ļ¬le utils ofFilePath File paths static string getFileExt(string ļ¬lename) static string removeExt(string ļ¬lename) static string addLeadingSlash(string path) static string addTrailingSlash(string path) static string removeTrailingSlash(string path) static string getPathForDirectory(string path) static string getAbsolutePath(string path, bool rel_data = true) static bool isAbsolute(string path) static string getFileName(string f,bool rel_data = true) static string getBaseName(string ļ¬le) static string getEnclosingDirectory(string p, bool rel_data = true) static string getCurrentWorkingDirectory()
  • 43. ļ¬le utils ofFilePath File paths cout << ofFilePath::getPathForDirectory("~/Documents"); /Users/roxlu/Documents/ cout << ofFilePath::getPathForDirectory("data"); data/ string path = "/just/some/path/photo.jpg"; cout << ofFilePath::getFileExt(path); jpg string path = "/just/some/path/photo.jpg"; cout << ofFilePath::removeExt(path); /just/some/path/photo string path = "/just/some/path/photo.jpg"; cout << ofFilePath::getFilename(path) << endl; photo.jpg
  • 44. ļ¬le utils ofFilePath File paths string path = "/just/some/path/photo.jpg"; cout << ofFilePath::getBaseName(path) << endl; photo string path = "/just/some/path/photo.jpg"; cout << ofFilePath::getEnclosingDirectory(path) << endl; /just/some/path/ cout << ofFilePath::getCurrentWorkingDirectory() << endl; /Users/roxlu/Documents/programming/c++/of/git/apps/examples/emptyExample/bin/ emptyExampleDebug.app/Contents/MacOS/
  • 45. ļ¬le utils ofFile ofFile bool open(string path, Mode m=ReadOnly, bool binary=false) bool changeMode(Mode m, bool binary=false) void close() bool canExecute() bool exists() bool isFile() string path() bool isLink() string getExtension() bool isDirectory() string getFileName() bool isDevice( string getBaseName() bool isHidden string getEnclosingDirectory() void setWriteble(bool writable) string getAbsolutePath() void setReadOnly(bool readable) bool canRead() void setExecutable(bool exec) bool canWrite() uint64_t getSize()
  • 46. ļ¬le utils ofFile ofFile bool copyTo(string path, bool rel_to_data = true, bool overwrite = false) bool moveTo(string path, bool rel_to_data = true, bool overwrite = false) bool renameTo(string path, bool rel_to_data = true, bool overwrite = false) ofFile <> ofBuffer ofBuffer readToBuffer() bool writeFromBuffer(ofBuffer& buffer) bool renameTo(string path, bool rel_to_data = true, bool overwrite = false)
  • 47. ļ¬le utils ofFile ofFile - static functions static bool copyFromTo(string src, string dest, bool rel_to_data = true, bool overwrite = false) static bool moveFromTo(string src, string dest, bool rel_to_data = true, bool overwrite = false) static bool doesFileExist(string path,bool rel_to_data = true) static bool removeFile(string path,bool rel_to_data = true)
  • 48. ļ¬le utils ofDirectory ofDirectory ā€¢ Similar to ofFile ā€¢ Lots of handy function for moving, renaming, copying, deleting, ļ¬le listing, etc... void open(string path) void setWriteble(bool writable) void close() void setReadOnly(bool readable) bool create(bool recursive = true) bool exists() void setExecutable(bool exec) string path() For more functions ofFileUtils.h bool canRead() bool canWrite() bool canExecute() bool isDirectory() bool isHidden() bool remove(bool recursive)
  • 49. ļ¬le utils ofDirectory Retrieve all jpegs from a directory ofDirectory dir; dir.allowExt("jpg"); int num_jpegs_in_datapath = dir.listDir(ofToDataPath(".",true)); cout << "Num files in data path : " << num_jpegs_in_datapath << endl; for(int i = 0; i < num_jpegs_in_datapath; ++i) { cout << dir.getPath(i) << endl; } Result /Users/roxlu/Documents/programming/c++/of/git/apps/examples/emptyExample/bin/data/screen_0001.jpg /Users/roxlu/Documents/programming/c++/of/git/apps/examples/emptyExample/bin/data/screen_0002.jpg /Users/roxlu/Documents/programming/c++/of/git/apps/examples/emptyExample/bin/data/screen_0003.jpg /Users/roxlu/Documents/programming/c++/of/git/apps/examples/emptyExample/bin/data/screen_0004.jpg /Users/roxlu/Documents/programming/c++/of/git/apps/examples/emptyExample/bin/data/screen_0005.jpg /Users/roxlu/Documents/programming/c++/of/git/apps/examples/emptyExample/bin/data/screen_0006.jpg
  • 50. ļ¬le utils ofDirectory Some static functions static bool createDirectory(string path, bool rel_to_data = true, bool recursive = false) static bool isDirectoryEmtpy(string path, bool rel_to_data = true) static bool doesDirectoryExist(string path, bool rel_to_data = true) static bool removeDirectory(string path, bool deleteIfNotEmpty, bool bRelativeToData = true)
  • 51. constants Development Math/Trig OF_VERSION HALF_PI CLAMP(val,min,max) OF_VERSION_MINOR PI ABS(x) TARGET_WIN32 TWO_PI OF_OUTLINE TARGET_OF_IPHONE FOUR_PI OF_FILLED TARGET_ANDROID DEG_TO_RAD TARGET_LINUS RAD_TO_DEG Window TARGET_OPENGLES MIN(x,y) OF_WINDOW OF_FULLSCREEN OF_USING_POCO MAX(x,y) OF_GAME_MODE
  • 52. constants Rectangle modes Pixel formats Blend modes OF_RECTMODE_CORNER OF_PIXELS_MONO OF_BLENDMODE_DISABLED OF_RECTMODE_CENTER OF_PIXELS_RGB OF_BLENDMODE_ALPHA OF_PIXELS_RGBA OF_BLENDMODE_ADD Image types OF_PIXELS_BGRA OF_BLENDMODE_SUBTRACT OF_IMAGE_GRAYSCALE OF_PIXELS_RGB565 OF_BLENDMODE_MULTIPLY OF_IMAGE_COLOR OF_BLENDMODE_SCREEN OF_IMAGE_COLOR_ALPHA OF_IMAGE_UNDEFINED
  • 53. constants Orientations ofLoopType OF_ORIENTATION_UNKNOWN OF_LOOP_NONE OF_ORIENTATION_DEFAULT OF_LOOP_PALINDROME OF_ORIENTATION_90_LEFT OF_LOOP_NORMAL OF_ORIENTATION_180 OF_ORIENTATION_90_RIGHT For more deļ¬nes see ofConstants
  • 54. constants Function keys Cursor keys OF_KEY_F1 OF_KEY_LEFT OF_KEY_F2 OF_KEY_RIGHT ... OF_KEY_DOWN OF_KEY_F12 OF_KEY_UP Special keys OF_KEY_PAGE_UP OF_KEY_INSERT OF_KEY_ALT OF_KEY_PAGE_DOWN OF_KEY_RETURN OF_KEY_SHIFT OF_KEY_HOME OF_KEY_ESC OF_KEY_BACKSPACE OF_KEY_END OF_KEY_CTRL OF_KEY_DEL For more deļ¬nes see ofConstants

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n