doodle
0.2
Intended to support teaching C++, doodle is a simple library that helps make a window and makes it easy to do some drawing.
|
Functions | |
std::string | doodle::to_string (MouseButtons button) noexcept |
Convert MouseButtons enum to std::string. More... | |
std::string | doodle::to_string (KeyboardButtons button) noexcept |
Convert KeboardButtons enum to std::string. More... | |
std::wstring | doodle::to_wstring (MouseButtons button) noexcept |
Convert MouseButtons enum to std::wstring. More... | |
std::wstring | doodle::to_wstring (KeyboardButtons button) noexcept |
Convert KeboardButtons enum to std::wstring. More... | |
double | doodle::noise (double x, double y=0.0, double z=0.0) noexcept |
Returns the Perlin noise value at specified coordinates. More... | |
void | doodle::seed_noise (unsigned long long new_seed) noexcept |
Sets the seed value for noise(). More... | |
void | doodle::set_noise_detail (int perlin_octaves, double amplitude_falloff) noexcept |
Adjusts the character and level of detail produced by the Perlin noise function. More... | |
void | doodle::seed_random (unsigned int seed) noexcept |
Sets the seed value for random(). More... | |
double | doodle::random (double min_inclusive, double max_exclusive) noexcept |
Return a random floating-point number within the range [min,max) More... | |
double | doodle::random (double max_exclusive) noexcept |
Return a random floating-point number within the range [0,max) More... | |
double | doodle::random () noexcept |
Return a random floating-point number within the range [0,1) More... | |
int | doodle::random (int min_inclusive, int max_exclusive) noexcept |
Return a random integer number within the range [min,max) More... | |
int | doodle::random (int max_exclusive) noexcept |
Return a random integer number within the range [0,max) More... | |
Helper functions to convert the input enums to strings.
Helper functions to get noise values.
Helper functions to get random numbers.
|
noexcept |
Returns the Perlin noise value at specified coordinates.
Perlin noise is a random sequence generator producing a more natural ordered, harmonic succession of numbers compared to the standard random() function. It was invented by Ken Perlin in the 1980s and been used since in graphical applications to produce procedural images, natural motion, shapes, terrains etc.
The main difference to the random() function is that Perlin noise is defined in an infinite n-dimensional space where each pair of coordinates corresponds to a fixed semi-random value (fixed only for the lifespan of the program; see the seed_noise() function). doodle can compute 1D, 2D and 3D noise, depending on the number of coordinates given. The resulting value will always be between 0.0 and 1.0. The noise value can be animated by moving through the noise space as demonstrated in the example above. The 2nd and 3rd dimension can also be interpreted as time.
A way to adjust the character of the resulting sequence is the scale of the input coordinates. As the function works within an infinite space the value of the coordinates doesn't matter as such, only the distance between successive coordinates does (eg. when using noise() within a loop). As a general rule the smaller the difference between coordinates, the smoother the resulting noise sequence will be. Steps of 0.005-0.03 work best for most applications, but this will differ depending on use.
x | x-coordinate in noise space |
y | y-coordinate in noise space |
z | z-coordinate in noise space |
|
noexcept |
Return a random floating-point number within the range [0,1)
It is the same as calling
|
noexcept |
Return a random floating-point number within the range [0,max)
It is the same as calling
max_exclusive | the exclusive upper bound or the maximum value but won't be returned. |
|
noexcept |
Return a random floating-point number within the range [min,max)
min_inclusive | the inclusive lower bound or the minimum value to be returned |
max_exclusive | the exclusive upper bound or the maximum value but won't be returned. |
|
noexcept |
Return a random integer number within the range [0,max)
It is the same as calling
max_exclusive | the exclusive upper bound or the maximum value but won't be returned. |
|
noexcept |
Return a random integer number within the range [min,max)
min_inclusive | the inclusive lower bound or the minimum value to be returned |
max_exclusive | the exclusive upper bound or the maximum value but won't be returned. |
|
noexcept |
Sets the seed value for noise().
By default, noise() produces different results each time the program is run. Set the value parameter to a constant to return the same pseudo-random numbers each time the software is run.
new_seed | The seed value |
Prints the following:
|
noexcept |
Sets the seed value for random().
By default, random() produces different results each time the program is run. Set the seed parameter to a constant to return the same pseudo-random numbers each time the software is run.
seed | the seed value |
|
noexcept |
Adjusts the character and level of detail produced by the Perlin noise function.
Similar to harmonics in physics, noise is computed over several octaves. Lower octaves contribute more to the output signal and as such define the overall intensity of the noise, whereas higher octaves create finer grained details in the noise sequence.
By default, noise is computed over 4 octaves with each octave contributing exactly half than its predecessor, starting at 50% strength for the 1st octave. This falloff amount can be changed by adding an additional function parameter. Eg. a falloff factor of 0.75 means each octave will now have 75% impact (25% less) of the previous lower octave. Any value between 0.0 and 1.0 is valid, however note that values greater than 0.5 might result in greater than 1.0 values returned by noise().
By changing these parameters, the signal created by the noise() function can be adapted to fit very specific needs and characteristics.
perlin_octaves | number of octaves to be used by the noise. default is 4 |
amplitude_falloff | falloff factor for each octave. default is 0.5 |
|
noexcept |
Convert KeboardButtons enum to std::string.
button | keyboard button |
|
noexcept |
Convert MouseButtons enum to std::string.
button | mouse button |
|
noexcept |
Convert KeboardButtons enum to std::wstring.
button | keyboard button |
|
noexcept |
Convert MouseButtons enum to std::wstring.
button | mouse button |