diff options
| author | Tim Redfern <tim@eclectronics.org> | 2014-05-22 08:36:24 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2014-05-22 08:36:24 +0100 |
| commit | bb6498e5ff6a8a8af8c06300dac051659a37e89b (patch) | |
| tree | 873cd3f3eba85e38c12995b077ce0db9ee82afab /NT/src/nodes_source.h | |
| parent | ebc874413991fbc3d07493ece55f88f23e437af6 (diff) | |
NT figuring out type system
Diffstat (limited to 'NT/src/nodes_source.h')
| -rw-r--r-- | NT/src/nodes_source.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/NT/src/nodes_source.h b/NT/src/nodes_source.h new file mode 100644 index 0000000..08da163 --- /dev/null +++ b/NT/src/nodes_source.h @@ -0,0 +1,77 @@ +#ifndef ROTOR_NODES_SOURCE +#define ROTOR_NODES_SOURCE + +#include "rotor.h" + +namespace Rotor { + class Signal_colour: public Image_node { + public: + Signal_colour(){ + selector=create_inlet<double>("selector"); + 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"; + NODEID="a2183fe0-2d09-11e3-9a64-538ee2cf40bc"; + }; + Signal_colour(map<string,string> &settings):Signal_colour() { + base_settings(settings); + for (uint32_t 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) cerr<<"colour now "<<palette[col].r<<","<<palette[col].g<<","<<palette[col].b<<endl; + //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 ℑ + } + return nullptr; + } + Signal_colour* clone(map<string,string> &_settings) { return new Signal_colour(_settings);}; + private: + vector<Colour> palette; + int prevcol; + Number_inlet *selector; + }; + 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"; + NODEID="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.0)); + 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; + memset(image.RGBdata,col,image.w*image.h*3); + } + return ℑ + + } + Signal_greyscale* clone(map<string,string> &_settings) { return new Signal_greyscale(_settings);}; + private: + uint8_t prevcol; + }; +} +#endif |
