Sine Plasma - RealWorld forums

Log-in or register.

Sine Plasma

PAEz
on October 19th 2013

Sine Plasma
Renders a sine plasma.

Source
https://github.com/amsqr/Chromanin.js
with a little modding by me

Code
Configuration

Configuration.AddSlider("_amplitude", "Amplitude", "", 1, 256, 256);
Configuration.AddEditBox("_dx", "dx", "", 0.2);
Configuration.AddEditBox("_dy", "dy", "", 0.1);
Configuration.AddSlider("_a", "Alpha", "", 0, 255, 255);

Execution

//  Sine Plasma

var dx=Configuration._dx;
var dy=Configuration._dy;
var amplitude=Configuration._amplitude;

var image = Document.RasterImage;
var w = image.sizeX;
var h = image.sizeY;

amplitude /= 256;
var c;
var lookupX=[],lookupY=[];

for(var x=0;x<w;x++){
	lookupX[x]=63.5 * Math.sin(dx * x) + 127;
}

for(var y=0;y<h;y++){
	lookupY[y]=63.5 * Math.sin(dy * y);
}


for (x=0; x<w; x++){
for (y=0; y<h; y++){

c=((lookupX[x] + lookupY[y]) * amplitude);

c=(Configuration._a   << 24) |	// alpha
  (c << 16) |		// red
  (c <<  8) |		// green
  c;

image.SetPixel(x, y, 0, 0, c);

}
}
Page views: 1038       Posts: 1      
What about ICL files?
Select background
I wish there were...