diff options
Diffstat (limited to 'include/core/SkRandom.h')
-rw-r--r-- | include/core/SkRandom.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/core/SkRandom.h b/include/core/SkRandom.h index 4731bbed4b..c8d71996e5 100644 --- a/include/core/SkRandom.h +++ b/include/core/SkRandom.h @@ -40,6 +40,21 @@ public: */ S16CPU nextS16() { return this->nextS() >> 16; } + /** + * Returns value [0...1) as a float + */ + float nextF() { + // const is 1 / (2^32 - 1) + return (float)(this->nextU() * 2.32830644e-10); + } + + /** + * Returns value [min...max) as a float + */ + float nextRangeF(float min, float max) { + return min + this->nextF() * (max - min); + } + /** Return the next pseudo random number, as an unsigned value of at most bitCount bits. @param bitCount The maximum number of bits to be returned |