Cross Smear - RealWorld forums

Log-in or register.

Cross Smear

PAEz
on November 8th 2013

If you apply this to the same image over and over you end up with a kindy crossy blur, try it.

Code
Configuration

Configuration.AddSlider("density", "Density Percentage", "", 1, 100, 4);
Configuration.AddSlider("scale", "Scale", "", 1, 100, 4);
Configuration.AddSlider("scale", "Scale", "", 1, 100, 4);

Execution

// Joel Besada
// https://github.com/JoelBesada/JSManipulate
// Plus PAEz touch here and there

this.mixColors = function(t, rgb1, rgb2){
          var r = this.linearInterpolate(t,rgb1 >> 16 & 255,rgb2 >> 16 & 255);
          var g = this.linearInterpolate(t,rgb1 >> 8 & 255,rgb2 >> 8 & 255);
          var b = this.linearInterpolate(t,rgb1 & 255,rgb2 & 255);
          var a = this.linearInterpolate(t,rgb1 >> 24 & 255,rgb2 >> 24 & 255);
          return b | (g << 8) | (r << 16) | (a << 24);
  }

  this.linearInterpolate = function(t,a,b){
          return a + t * (b-a);
  }

filter = function(distance, density, mix) {
	var output = Document.RasterImage;
	var width = output.sizeX;
	var height = output.sizeY;

	var input = Document.Duplicate();
	input = input.RasterImage;
                  var numShapes = parseInt(2*density*width * height / (distance + 1));
                   for(var i = 0; i < numShapes; i++){
                          var x = (Math.random()*Math.pow(2,32) & 0x7fffffff) % width;
                          var y = (Math.random()*Math.pow(2,32) & 0x7fffffff) % height;
                          var length = (Math.random()*Math.pow(2,32)) % distance + 1;
                          var rgb2 = input.GetPixel(x,y,0,0);
                          for (var x1 = x-length; x1 < x+length+1; x1++) {
                    if(x1 >= 0 && x1 < width){
                            var rgb1 = output.GetPixel(x1,y,0,0);
                            var mixedRGB = mixColors(mix,rgb1,rgb2)
                            output.SetPixel(x1,y,0,0,mixedRGB);
                    }

                }
                          for (var y1 = y-length; y1 < y+length+1; y1++) {
                    if(y1 >= 0 && y1 < height){
                            var rgb1 = output.GetPixel(x,y1,0,0);
                            var mixedRGB = mixColors(mix,rgb1,rgb2)
                            output.SetPixel(x,y1,0,0,mixedRGB);
                    }

                }
                  }
}

var size = Configuration.size;
var density = Configuration.density/100;
var mix = Configuration.mix/100;
filter(size, density, mix);
Page views: 1256       Posts: 1      
Select background
I wish there were...
Vista & Win 7 icons