noise-tool: add offset to positions for testing

allows us to peek at the negative quandrants for rounding and other
issues.
This commit is contained in:
Danny Robson 2015-05-29 15:55:36 +10:00
parent b4ddd287bf
commit 2e9698f53b

View File

@ -1,6 +1,7 @@
#include "image.hpp" #include "image.hpp"
#include "noise.hpp" #include "noise.hpp"
#include "noise/lerp.hpp" #include "noise/lerp.hpp"
#include "noise/basis/constant.hpp"
#include "noise/basis/value.hpp" #include "noise/basis/value.hpp"
#include "noise/basis/perlin.hpp" #include "noise/basis/perlin.hpp"
#include "noise/basis/worley.hpp" #include "noise/basis/worley.hpp"
@ -24,11 +25,15 @@ main (void)
b.basis.seed = time (NULL); b.basis.seed = time (NULL);
// generate the values. offset positions slightly to avoid simple axis issues with perlin basis // generate the values. offset positions slightly to avoid simple axis issues with perlin basis
{
auto offset = util::vector2f { -100 };
for (size_t y = 0; y < size.h; ++y) for (size_t y = 0; y < size.h; ++y)
for (size_t x = 0; x < size.w; ++x) { for (size_t x = 0; x < size.w; ++x) {
auto v = b ({float(x + 20), float(y + 20)}); auto v = b (util::point2f {float (x), float (y)} + offset); //{x + offset, y + offset});
img.data ()[y * size.w + x] = v; img.data ()[y * size.w + x] = v;
} }
}
// rescale into the range [0, 1] // rescale into the range [0, 1]
auto range = std::minmax_element (img.begin (), img.end ()); auto range = std::minmax_element (img.begin (), img.end ());