Nodebundle for playing with nodes

 From:  Karsten (KMRQUS)
7777.1272 In reply to 7777.1271 
Hello James,

I'm not sure which way is the best, but a RGB input would create a lot of styles or you have to create and delete again and again. I made a while ago a function for coloring vectors and for the curvature analysis, that create some kind of rainbow styles. It uses sigmoid functions to calculate the RGB parts for blending the colors. It's not perfect, but short code:-) I've included it in the SetStyle-node. So you can put a value between 0 and 254 to choose a color. The node is now multiprocessing the input objects. It's a proposal. Maybe we will find a better solution later.

code:
    // SetStyle
 function SetStyle()
 {
 this.addInput("obj","objectlist");
 this.addInput("idx","numarray");

 this.addOutput("Out","objectlist");
	  this.properties = {/*mode: ["Long", "Long", "Short"],*/Style: [0]};
 }

 SetStyle.title = "SetStyle";
 SetStyle.desc = "SetStyle";
    SetStyle.prototype.onAdded = function (){this.rbID = createRainbow();}
 SetStyle.prototype.onExecute = function()
 {
            var data = this.processInOut("Long" /*this.properties.mode[0]*/, this.multiProcess, null, this.properties.Style);
            this.properties.Style = data.inputs[1];
            this.setOutputData(0, data.outputs[0]);
        
    };


    SetStyle.prototype.multiProcess = function (obj, style)
    {
        var out = [];
        obj.setProperty('styleIndex', this.rbID[style]);
        out[0]=obj;
        return out;
    };
 
 LiteGraph.registerNodeType("Objects2/SetStyle", SetStyle);


Have a nice day
Karsten
Attachments: