public ChannelSplitterNode() : base("Channel Splitter", new ColorNodeControl(), Colors.Yellow) { AddSocket("Color", InputNodeSocket.Create <DColor>(this)); AddSocket("Red", OutputNodeSocket.Create <DColor>(this, (location) => { var color = (DColor)Inputs["Color"].Data(location); return(DColor.FromArgb(255, color.R, color.R, color.R)); })); AddSocket("Green", OutputNodeSocket.Create <DColor>(this, (location) => { var color = (DColor)Inputs["Color"].Data(location); return(DColor.FromArgb(255, color.G, color.G, color.G)); })); AddSocket("Blue", OutputNodeSocket.Create <DColor>(this, (location) => { var color = (DColor)Inputs["Color"].Data(location); return(DColor.FromArgb(255, color.B, color.B, color.B)); })); AddSocket("Alpha", OutputNodeSocket.Create <DColor>(this, (location) => { var color = (DColor)Inputs["Color"].Data(location); return(DColor.FromArgb(255, color.A, color.A, color.A)); })); }
public GaussianBlurNode() : base("Gaussian Blur", new ColorNodeControl(), Colors.Yellow) { AddSocket("Color", InputNodeSocket.Create <DColor>(this)); AddSocket("Color", OutputNodeSocket.Create <DColor>(this, location => { float pDelta = 1.0f / 1024.0f; float totalR = 0; float totalG = 0; float totalB = 0; var weights = GenerateWeights(Strength); var dim = (Strength - 1) / 2; for (int x = -dim; x <= dim; x++) { for (int y = -dim; y <= dim; y++) { var locX = ClampNorm(location.X + pDelta * (double)x); var locY = ClampNorm(location.Y + pDelta * (double)y); var sample = (DColor)Inputs["Color"].Data(new WPoint(locX, locY)); float weight = weights[x + dim, y + dim]; totalR += (float)sample.R * weight; totalG += (float)sample.G * weight; totalB += (float)sample.B * weight; } } return(DColor.FromArgb(255, (int)totalR, (int)totalG, (int)totalB)); } )); }
public HueNode() : base("Hue", new ColorNodeControl(), Colors.Yellow) { AddSocket("Color", InputNodeSocket.Create <DColor>(this)); AddSocket("Color", OutputNodeSocket.Create <DColor>(this, (location) => { var color = ((DColor)Inputs["Color"].Data(location)); int invR = 255 - color.R; int invG = 255 - color.G; int invB = 255 - color.B; return(DColor.FromArgb(color.A, invR, invG, invB)); })); }
public ChannelMixerNode() : base("Channel Mixer", new ColorNodeControl(), Colors.Yellow) { AddSocket("Red", InputNodeSocket.Create <DColor>(this)); AddSocket("Green", InputNodeSocket.Create <DColor>(this)); AddSocket("Blue", InputNodeSocket.Create <DColor>(this)); AddSocket("Alpha", InputNodeSocket.Create <DColor>(this)); AddSocket("Color", OutputNodeSocket.Create <DColor>(this, (location) => { var colorR = ((DColor)Inputs["Red"].Data(location)).R; var colorG = ((DColor)Inputs["Green"].Data(location)).R; var colorB = ((DColor)Inputs["Blue"].Data(location)).R; var colorA = ((DColor)Inputs["Alpha"].Data(location)).R; return(DColor.FromArgb(colorA, colorR, colorG, colorG)); })); }
public DesaturateNode() : base("Desaturate", new ColorNodeControl(), Colors.Yellow) { AddSocket("Color", InputNodeSocket.Create <DColor>(this)); AddSocket("Color", OutputNodeSocket.Create <DColor>(this, (location) => { var color = ((DColor)Inputs["Color"].Data(location)); float lum = (color.R / 255.0f) * 0.3f + (color.G / 255.0f) * 0.6f + (color.B / 255.0f) * 0.1f; int colorLum = (int)(lum * 255.0f); return(DColor.FromArgb(255, colorLum, colorLum, colorLum)); })); }