Overview of this book

openFrameworks Essentials
Credits
Foreword
www.PacktPub.com
Preface
Free Chapter
Getting Started with openFrameworks
Adding a GUI and Handling Keyboard Events
Working with Raster Graphics – Images, Videos, and Shaders
Creating 3D Graphics
Distributed and Physical Computing with Networking and Arduino
Deploying the Project on iOS, Android, and Raspberry Pi
Further Resources
Video Synthesizer Reference
openFrameworks Quick Reference
Index

Mathematical, timer, and conversion functions

The mathematical, timer, and conversion functions were described in Chapter 6, Animating Parameters, and Chapter 7, Distributed and Physical Computing with Networking and Arduino, and are collected in this table:

Function

Description

`ofMap( x, 0, 1, 2, 3 )`

This linearly maps the float `x` from segment [0,1] to segment [2,3].

`ofMap( x, 0, 1, 2, 3, true )`

This linearly maps the float `x` from the segment [0,1] to the segment [2,3], clamping the output value to the [2,3] range (it occurs when `x` is not in segment [0,1]).

`ofClamp( x, 0, 1 )`

This clamps the float `x` to the range [0,1].

`ofInRange( x, 0, 1 )`

This returns `true` if the float `x` lies in the segment [0,1] and returns `false` in the opposite case.

`ofToString( 0.5 )`

This converts a numeric value (integer or float) to a string.

`ofGetElapsedTime()`

This is the number of seconds elapsed from the application start; the returned value is float.

`ofNoise( x )`

This is the Perlin noise value for float `x`.

`ofToFloat( "0.5" )`

This converts a string to a float number.

`ofToInt( "5" )`

This converts a string to an integer.

`vector<string> list = ofSplitString( "aa;bb;cc;dd", ";" );`

This splits a string into an array of strings. The first argument is the string, and the second argument is the delimeter. In our example, the resulting array list will consist of the four elements:

`list[0] = "aa"`

`list[1] = "bb"`

`list[2] = "cc"`

`list[3] = "dd"`