pixled-lib  1.0
pixled/random/normal.cpp

A pixled::random::NormalDistribution usage example.

random_normal_t.gif random_normal_xy_t.gif random_normal_xy_t_hue.gif
#include "pixled.h"
#include "pixled/gif_output.h"
int main(int argc, char** argv) {
pixled::LedPanel panel(16, 16, pixled::LEFT_RIGHT_RIGHT_LEFT_FROM_BOTTOM);
pixled::GifOutput out(256, pixled::FIT_WIDTH, 20, panel);
{
// Random engine that only depends upon time.
// The value will be the same for every leds, and will change every 10
// frames.
// Normal integer distribution centered on 200 with a variation of 20
// Animation
pixled::rgb color(random_red, 50, 50);
pixled::Runtime runtime(panel, out, color);
// Writes 100 frames to gif file
out.write(runtime, 100, "random_normal_t.gif");
}
{
// Random engine that only depends upon time and space.
// The value will be different for every leds, and will change every 10
// frames.
// Normal integer distribution centered on 200 with a variation of 20
// (same as above)
// Animation
pixled::rgb color(random_red, 50, 50);
pixled::Runtime runtime(panel, out, color);
// Writes 100 frames to gif file
out.write(runtime, 100, "random_normal_xy_t.gif");
}
{
// Same as above
// A random hue with values distributed according to a normal
// distribution
// The center of the normal distribution varies from 0 to 360
// Variation
20,
// Random engine
);
// Animation
pixled::hsb color(random_hue, 1.0, 1.0);
pixled::Runtime runtime(panel, out, color);
// Writes 100 frames to gif file
out.write(runtime, 100, "random_normal_xy_t_hue.gif");
}
}
Definition: runtime.h:28
Definition: animation.h:88
Definition: chroma.h:25
Definition: chroma.h:46
Definition: mapping.h:150
Definition: random.h:153
Definition: random.h:75
Definition: random.h:95
std::minstd_rand random_engine
Definition: random.h:13