diff options
| -rw-r--r-- | rotord/src/nodes_drawing.h | 7 | ||||
| -rw-r--r-- | rotord/src/nodes_maths.h | 108 | ||||
| -rw-r--r-- | rotord/src/rotor.h | 4 |
3 files changed, 52 insertions, 67 deletions
diff --git a/rotord/src/nodes_drawing.h b/rotord/src/nodes_drawing.h index 7e7a178..f428fd8 100644 --- a/rotord/src/nodes_drawing.h +++ b/rotord/src/nodes_drawing.h @@ -215,19 +215,16 @@ namespace Rotor { ~Mosaic(){}; Mosaic* clone(map<string,string> &_settings) { return new Mosaic(_settings);}; void vector_output(cairo_t * cr,const Frame_spec &frame){ - double vpix=max(parameters["pixels"]->value,1.0); + double vpix=min((double)frame.h,max(parameters["pixels"]->value,1.0)); double pixel_size=frame.h/vpix; int h_padded=ceil(vpix/2)*2; int w_padded=ceil((((vpix/frame.h)*frame.w))/2)*2; - Image *in1=image_inputs[0]->get(frame); if (in1){ Image in=*(in1); in.crop(w_padded*pixel_size,h_padded*pixel_size); in.resize(w_padded,h_padded); - int x_start=-((w_padded*pixel_size)/2); - int y_start=-((h_padded*pixel_size)/2); - cairo_translate(cr,x_start,y_start); + cairo_translate(cr,-((w_padded*pixel_size)/2),-((h_padded*pixel_size)/2)); for (int i=0;i<w_padded;i++){ for (int j=0;j<h_padded;j++){ double R=((double)in.rgb.data[3*(w_padded*j + i) + 0])/255.0; diff --git a/rotord/src/nodes_maths.h b/rotord/src/nodes_maths.h index ce474cf..6bbccdc 100644 --- a/rotord/src/nodes_maths.h +++ b/rotord/src/nodes_maths.h @@ -90,67 +90,55 @@ namespace Rotor { } Arithmetic* clone(map<string,string> &_settings) { return new Arithmetic(_settings);}; const double output(const Time_spec &time) { - //if (attributes["operator"]->intVal==ARITHMETIC_divide||attributes["operator"]->intVal==ARITHMETIC_modulo){ - // if (value==0.0) { - // Poco::Logger& logger = Poco::Logger::get("Rotor"); - // logger.error("Arithmetic node: caught division by zero, frame "+time.frame()); - // return 0.0; - // } - //} - if (inputs.size()) { //there should there be a way to specify number of inputs in the code rather than in xml - if (inputs[0]->connection) { - double in= inputs[0]->get(time); - int inint; //this old chestnut - switch (attributes["operator"]->intVal) { - case ARITHMETIC_plus: - return in+parameters["value"]->value; - break; - case ARITHMETIC_minus: - return in-parameters["value"]->value; - break; - case ARITHMETIC_multiply: - return in*parameters["value"]->value; - break; - case ARITHMETIC_divide: - return in/parameters["value"]->value; - break; - case ARITHMETIC_modulo: - //cerr <<in<<" % "<<parameters["value"]->value<<" = "<<fmod(in,parameters["value"]->value)<<endl; - return fmod(in,parameters["value"]->value); - //return (((int)in)%12); //+(in-((int)in)); - break; - case ARITHMETIC_pow: - return pow(in,parameters["value"]->value); - break; - case ARITHMETIC_sin: - phase+=(in-inputs[0]->get(time.lastframe()))*parameters["frequency"]->value; - return sin(phase)*parameters["value"]->value; - break; - case ARITHMETIC_cos: - phase+=(in-inputs[0]->get(time.lastframe()))*parameters["frequency"]->value; - return cos(phase)*parameters["value"]->value; - break; - case ARITHMETIC_ease: - return ((1.0-parameters["value"]->value)*in)+(parameters["value"]->value*(0.5f+((cos((fmod(in,1.0)+1.0)*M_PI))*0.5f))); - break; - case ARITHMETIC_jolt: - return ((1.0-parameters["value"]->value)*in)+(parameters["value"]->value*(0.5f+((sin((fmod(in,1.0)+1.0)*M_PI))*0.5f))); - break; - case ARITHMETIC_floor: - return floor(in); - break; - case ARITHMETIC_2pow: - return pow(2,in); - break; - case ARITHMETIC_reciprocal: - return parameters["value"]->value/in; - break; - case ARITHMETIC_rminus: - return parameters["value"]->value-in; - break; - } + if (inputs[0]->connection) { + double in= inputs[0]->get(time); + switch (attributes["operator"]->intVal) { + case ARITHMETIC_plus: + return in+parameters["value"]->value; + break; + case ARITHMETIC_minus: + return in-parameters["value"]->value; + break; + case ARITHMETIC_multiply: + return in*parameters["value"]->value; + break; + case ARITHMETIC_divide: + return in/parameters["value"]->value; + break; + case ARITHMETIC_modulo: + return fmod(in,parameters["value"]->value); + break; + case ARITHMETIC_pow: + return pow(in,parameters["value"]->value); + break; + case ARITHMETIC_sin: + phase+=(in-inputs[0]->get(time.lastframe()))*parameters["frequency"]->value; + return sin(phase)*parameters["value"]->value; + break; + case ARITHMETIC_cos: + phase+=(in-inputs[0]->get(time.lastframe()))*parameters["frequency"]->value; + return cos(phase)*parameters["value"]->value; + break; + case ARITHMETIC_ease: + return ((1.0-parameters["value"]->value)*in)+(parameters["value"]->value*(0.5f+((cos((fmod(in,1.0)+1.0)*M_PI))*0.5f))); + break; + case ARITHMETIC_jolt: + return ((1.0-parameters["value"]->value)*in)+(parameters["value"]->value*(0.5f+((sin((fmod(in,1.0)+1.0)*M_PI))*0.5f))); + break; + case ARITHMETIC_floor: + return floor(in); + break; + case ARITHMETIC_2pow: + return pow(2,in); + break; + case ARITHMETIC_reciprocal: + return parameters["value"]->value/in; + break; + case ARITHMETIC_rminus: + return parameters["value"]->value-in; + break; } - } + } return 0.0; } int op; diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index decae01..27d3820 100644 --- a/rotord/src/rotor.h +++ b/rotord/src/rotor.h @@ -1159,8 +1159,8 @@ namespace Rotor { //cerr<<"video feedback: added, "<<feedback.size()<<" images in cache"<<endl; list<Image>::iterator it1=feedback.begin(); //list<int>::iterator iit1=feedbacknums.begin(); - if (feedback.size()>((int)parameters["delay"]->value)-1){ - if (feedback.size()>((int)parameters["delay"]->value)){ + if (feedback.size()>((uint32_t)parameters["delay"]->value)-1){ + if (feedback.size()>((uint32_t)parameters["delay"]->value)){ list<Image>::iterator it2=feedback.begin(); //list<int>::iterator iit2=feedbacknums.begin(); advance(it2,feedback.size()-(((int)parameters["delay"]->value))); |
