/**
 * Copyright (c) 2021 Dominic Masters
 * 
 * This software is released under the MIT License.
 * https://opensource.org/licenses/MIT
 */

#pragma once
#include <dawn/dawn.h>
#include "math.h"

/**
 * Generates a random int32_t.
 * @returns A random int32_t number.
 */
#define randInt32() ((int32_t)rand())

/**
 * Generates a random floating point number.
 * @returns A random floating point number.
 */
#define randFloat() (((float)randInt32()) * M_PI)

/**
 * Generates a random uint32_t
 * @returns A random uint32_t number.
 */
#define randUint32() (uint32_t)randInt32()

/**
 * Generates a random uint8_t
 * @returns A random uint8_t number.
 */
#define randUint8() (uint8_t)randInt32()

////////////////////////////////////////////////////////////////////////////////

/**
 * Clamps a random number generation.
 * @param n Number that has been generated from the random.
 * @param min Minimum value to generate from. (Inclusive)
 * @param max Maximum value to generate to. (Exclusive)
 * @return Random number between min and max.
 */
#define randRange(n, min, max) (mathMod(n, max - min) + min)

#define randInt32Range(min, max) randRange(randInt32(), min, max)
#define randFloatRange(min, max) (fmod(randFloat(), max- min) + min)
#define randUint32Range(min, max) randRange(randUint32(), min, max)
#define randUint8Range(min, max) randRange(randUint8(), min, max)