pixled-lib  1.0
pixled/conditional/conditional.cpp

Demonstrates the If statement usage.

conditional_eq.gif conditional_less_greater.gif

Greater"

Greater"

Greater"

Greater" |

#include "pixled.h"
#include "pixled/gif_output.h"
using namespace pixled;
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);
{
// If based animation
auto anim = pixled::If<color>(
// condition
pixled::Cast<int>(pixled::X() + pixled::Y()) % 2 == 0,
// then
50, 200, pixled::RandomXYT(10)
),
0
),
// else
50, 200, pixled::RandomXYT(10)
)
)
);
pixled::Runtime runtime(panel, out, anim);
// Writes 100 frames to gif file
out.write(runtime, 100, "conditional_eq.gif");
}
{
auto anim = pixled::If<color>(
pixled::X() > 10,
pixled::X() <= 6,
)
);
pixled::Runtime runtime(panel, out, anim);
// Writes 20 frames to gif file
out.write(runtime, 20, "conditional_less_greater.gif");
}
}
Definition: runtime.h:28
Definition: chroma.h:46
Definition: conditional.h:33
Definition: geometry.h:13
Definition: geometry.h:27
Definition: mapping.h:150
Definition: random.h:95
Definition: random.h:126
static color RED
Definition: chroma.h:56
static color BLUE
Definition: chroma.h:64
static color GREEN
Definition: chroma.h:60
Definition: animation.cpp:3