Commit 57d4e59f authored by Arnaud Blanchard's avatar Arnaud Blanchard
Browse files

Add function to clip float on [0,1]

parent 0c0a91b9
......@@ -53,6 +53,9 @@ Created on: Apr 28, 2011
/// Clip the value on the number between 0 and 255. Usefull to convert any number to a uchar.
#define CLIP_UCHAR(x) (uchar)((x) < 0 ? 0 : ((x) >= 256 ? 255 : (x)))
/// Clip the value on the number between 0 and 255. Usefull to convert any number to a uchar.
#define BLC_CLIP_FLOAT(x) ((x) < 0 ? 0.f : ((x) >= 1.0f ? 1.0f : (x)))
/**Shorcut to do a loop from 0 to max-1 element. If it is not broken, the last iterator after the loop is max.
You should not modify the iterator yourself, in this case use a standard for(;;) */
#define FOR(iterator, max) for (iterator = 0; iterator != max; ++iterator)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment