summaryrefslogtreecommitdiff
path: root/rotord/src/nodes_source.h
diff options
context:
space:
mode:
authorComment <tim@gray.(none)>2013-10-07 06:19:14 -0700
committerComment <tim@gray.(none)>2013-10-07 06:19:14 -0700
commitba2831c3a456e860761978cb848f38d825b4c128 (patch)
tree7ced990051d059fae90fd55cea40ef3f3cbdb333 /rotord/src/nodes_source.h
parent3252e78c0a43613e2a48d39a8dec74ffaf5ee100 (diff)
refacoring
Diffstat (limited to 'rotord/src/nodes_source.h')
-rw-r--r--rotord/src/nodes_source.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/rotord/src/nodes_source.h b/rotord/src/nodes_source.h
new file mode 100644
index 0000000..3ce9fdd
--- /dev/null
+++ b/rotord/src/nodes_source.h
@@ -0,0 +1,74 @@
+#ifndef ROTOR_NODES_SOURCE
+#define ROTOR_NODES_SOURCE
+
+#include "rotor.h"
+
+namespace Rotor {
+ class Signal_colour: public Image_node {
+ public:
+ Signal_colour(){
+ create_signal_input("Selector","Selector input");
+ create_attribute("palette","palette list of web colours","Colour palette","000000");
+ title="Signal colour";
+ description="Cycles through a palette of background colours according to selector signal";
+ UID="a2183fe0-2d09-11e3-9a64-538ee2cf40bc";
+ };
+ Signal_colour(map<string,string> &settings):Signal_colour() {
+ base_settings(settings);
+ for (int i=0;i<attributes["palette"]->value.size()/6;i++){
+ palette.push_back(Colour(attributes["palette"]->value.substr(i*6,6)));
+ }
+ prevcol=-1;
+ };
+ ~Signal_colour(){};
+ Image *output(const Frame_spec &frame){
+ if (palette.size()) {
+ int col=((int)inputs[0]->get((Time_spec)frame))%palette.size();
+ //if (col!=prevcol){ //how about when starting a new render?
+ for (int i=0;i<image.w*image.h;i++){
+ image.RGBdata[i*3]=palette[col].r;
+ image.RGBdata[i*3+1]=palette[col].g;
+ image.RGBdata[i*3+2]=palette[col].b;
+ }
+ prevcol=col;
+ //}
+ return &image;
+ }
+ return nullptr;
+ }
+ Signal_colour* clone(map<string,string> &_settings) { return new Signal_colour(_settings);};
+ private:
+ vector<Colour> palette;
+ int prevcol;
+ };
+ class Signal_greyscale: public Image_node {
+ //Draws signal bars in greyscale
+ public:
+ Signal_greyscale(){
+ create_signal_input("Signal","Signal input");
+ title="Signal greyscale";
+ description="Renders signal level as greyscale background";
+ UID="ae91b8a0-2d09-11e3-aa7d-8b7f1ef1a439";
+ };
+ Signal_greyscale(map<string,string> &settings):Signal_greyscale() {
+ base_settings(settings);
+ prevcol=-1;
+ };
+ ~Signal_greyscale(){};
+ Image *output(const Frame_spec &frame){
+ uint8_t col=((uint8_t)(inputs[0]->get((Time_spec)frame)*255.0f));
+ if (col!=prevcol){ //how about when starting a new render?
+ for (int i=0;i<image.w*image.h*3;i++){
+ image.RGBdata[i]=col;
+ }
+ prevcol=col;
+ }
+ return &image;
+
+ }
+ Signal_greyscale* clone(map<string,string> &_settings) { return new Signal_greyscale(_settings);};
+ private:
+ uint8_t prevcol;
+ };
+}
+#endif