7589a8edc7b0895f75ae0941ca20c77d9ee6d6e1
[platform/core/uifw/dali-demo.git] / examples / particles / float-rand.h
1 #ifndef PARTICLES_FLOAT_RAND_H_
2 #define PARTICLES_FLOAT_RAND_H_
3 /*
4  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19 #include <random>
20
21 struct FloatRand
22 {
23   std::random_device mDevice;
24   std::mt19937 mMersenneTwister;
25   std::uniform_real_distribution<float> mDistribution;
26
27   FloatRand()
28   : mMersenneTwister(mDevice()),
29     mDistribution(0., 1.)
30   {}
31
32   float operator()()
33   {
34     return mDistribution(mMersenneTwister);
35   }
36 };
37
38 #endif //PARTICLES_FLOAT_RAND_H_