3737// --------------------------------------------------------------
3838ColorPalette::ColorPalette () : PatchObject(" color palette" ){
3939
40- this ->numInlets = 1 ;
40+ this ->numInlets = 2 ;
4141 this ->numOutlets = 1 ;
4242
4343 _inletParams[0 ] = new vector<float >(); // base color
44+ _inletParams[1 ] = new float (); // bang
45+ *(float *)&_inletParams[1 ] = 0 .0f ;
46+
4447 _outletParams[0 ] = new vector<float >(); // palette
4548
4649 this ->initInletsState ();
@@ -62,6 +65,7 @@ void ColorPalette::newObject(){
6265 PatchObject::setName ( this ->objectName );
6366
6467 this ->addInlet (VP_LINK_ARRAY," baseColor" );
68+ this ->addInlet (VP_LINK_NUMERIC," bang" );
6569
6670 this ->addOutlet (VP_LINK_ARRAY," palette" );
6771
@@ -98,6 +102,22 @@ void ColorPalette::updateObjectContent(map<int,shared_ptr<PatchObject>> &patchOb
98102 }
99103 }
100104
105+ if (this ->inletsConnected [1 ] && *(float *)&_inletParams[1 ] == 1.0 ){
106+ if (selectedGeneration == 0 ){
107+ generateRandom (numColors);
108+ }else if (selectedGeneration == 1 ){
109+ generateMonoChromatic ((ColorChannel)selectedChannel,numColors);
110+ }else if (selectedGeneration == 2 ){
111+ generateComplementary ((ColorChannel)selectedChannel,numColors);
112+ }else if (selectedGeneration == 3 ){
113+ generateTriad ();
114+ }else if (selectedGeneration == 4 ){
115+ generateComplementaryTriad ();
116+ }else if (selectedGeneration == 5 ){
117+ generateAnalogous (numColors,spread);
118+ }
119+ }
120+
101121 static_cast <vector<float > *>(_outletParams[0 ])->clear ();
102122 for (int i=0 ;i<palette.size ();i++){
103123 static_cast <vector<float > *>(_outletParams[0 ])->push_back (palette.at (i).r );
@@ -136,6 +156,8 @@ void ColorPalette::drawObjectNodeGui( ImGuiEx::NodeCanvas& _nodeCanvas ){
136156
137157 drawObjectNodeConfig ();
138158
159+ this ->configMenuWidth = ImGui::GetWindowWidth ();
160+
139161 ImGui::EndMenu ();
140162 }
141163 _nodeCanvas.EndNodeMenu ();
0 commit comments