From 741cba373d7e982026de91ee1ceeb18a8f64b367 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Wed, 4 Dec 2013 11:10:55 +0000 Subject: min/max --- rotord/src/cvimage.cpp | 28 ++++++++++++++++++++++++++-- rotord/src/cvimage.h | 15 ++++++++++++++- rotord/src/nodes_channels.h | 34 +++++++++++++++++++++++++++++----- rotord/src/rotor.h | 2 -- 4 files changed, 69 insertions(+), 10 deletions(-) diff --git a/rotord/src/cvimage.cpp b/rotord/src/cvimage.cpp index 2d0f8e2..7aae63e 100644 --- a/rotord/src/cvimage.cpp +++ b/rotord/src/cvimage.cpp @@ -150,6 +150,30 @@ namespace Rotor { } return *this; } + Image & Image::min(const Image &other) { + if (other.w!=w||other.h!=h) { + cerr<<"Rotor: cannot min images with different sizes! (wanted "<>7):255-(((0xFF-i)*(0xFF-j))>>7); + min[i][j]=ji?j:i; } } mono_weights=new uint8_t*[3]; @@ -54,10 +60,14 @@ namespace Rotor { delete[] add[i]; delete[] multiply[i]; delete[] overlay[i]; + delete[] min[i]; + delete[] max[i]; } delete[] add; delete[] multiply; delete[] overlay; + delete[] min; + delete[] max; for (int i=0;i<3;i++) { delete[] mono_weights[i]; } @@ -67,7 +77,8 @@ namespace Rotor { uint8_t **multiply; uint8_t **overlay; uint8_t **mono_weights; - + uint8_t **max; + uint8_t **min; }; static pixeltables pixels; class Image{ @@ -208,6 +219,8 @@ namespace Rotor { Image & add_wrap(const Image &other); Image & divide_wrap(const Image &other); Image & overlay(const Image &other); + Image & min(const Image &other); + Image & max(const Image &other); Image & operator*=(const float &amount); Image & operator+=(const float &amount); Image & operator-=(const float &amount); diff --git a/rotord/src/nodes_channels.h b/rotord/src/nodes_channels.h index 1cb151e..4fdcd01 100644 --- a/rotord/src/nodes_channels.h +++ b/rotord/src/nodes_channels.h @@ -70,13 +70,15 @@ namespace Rotor { #define BLEND_wrap 5 #define BLEND_xor 6 #define BLEND_overlay 7 +#define BLEND_min 8 +#define BLEND_max 9 class Blend: public Image_node { public: Blend(){ create_image_input("image input 1","Image input 1"); create_image_input("image input 2","Image input 2"); create_parameter("amount","number","amount to blend input 2","Blend amount",0.5f,0.0f,1.0f); - create_attribute("mode","Blend mode","Blend mode","blend",{"blend","screen","multiply","alpha","wrap","xor","overlay"}); + create_attribute("mode","Blend mode","Blend mode","blend",{"blend","screen","multiply","alpha","wrap","xor","overlay","min","max"}); title ="Blend"; description="Blend images in various modes"; NODEID="12ed7af0-2d0a-11e3-ae32-2b44203b93c9"; @@ -111,6 +113,12 @@ namespace Rotor { case BLEND_overlay: image=image.overlay(*in2); break; + case BLEND_min: + image=image.min(*in2); + break; + case BLEND_max: + image=image.max(*in2); + break; case BLEND_blend: //has to be last because of initialser of *in? go figure image*=(1.0f-parameters["amount"]->value); @@ -412,7 +420,7 @@ namespace Rotor { //calls base class constructor first create_parameter("number","number","number of echoes","Number echoes",25.0f); create_parameter("fadeto","number","amount that echoes fade out","Fadout amount",1.0f,0.0f,1.0f); - create_attribute("mode","blend mode for echoes","Blend mode","screen",{"screen","wrap"}); + create_attribute("mode","blend mode for echoes","Blend mode","screen",{"screen","wrap","min","max"}); title="Echo trails"; description="Draw trail frames additively that fade off over time"; NODEID="5b1ab684-2d0b-11e3-8fa2-970be8c360dd"; @@ -476,14 +484,30 @@ namespace Rotor { if (attributes["mode"]->value=="screen") { image+=*temp; } - else { + if (attributes["mode"]->value=="wrap") { image.add_wrap(*temp); } + if (attributes["mode"]->value=="min") { + image.min(*temp); + } + if (attributes["mode"]->value=="max") { + image.max(*temp); + } delete temp; } else { - if (attributes["mode"]->value=="screen") image+=*(images[absframe]); - else image=image.add_wrap(*(images[absframe])); + if (attributes["mode"]->value=="screen") { + image+=*(images[absframe]); + } + if (attributes["mode"]->value=="screen") { + image=image.add_wrap(*(images[absframe])); + } + if (attributes["mode"]->value=="min") { + image=image.min(*(images[absframe])); + } + if (attributes["mode"]->value=="max") { + image=image.max(*(images[absframe])); + } } } } diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index c96663f..943464d 100644 --- a/rotord/src/rotor.h +++ b/rotord/src/rotor.h @@ -114,8 +114,6 @@ inputs: [ ] -REARCHITECTING STARTS HERE - -------------------------*/ -- cgit v1.2.3