Archive for June 16th, 2009

16
Jun
09

Random Gradient CIFilter JavaScript

Creates linear gradients between two random points across RGB channels every time ‘Trigger’ is clicked.

CIFilter Kernel Code (top panel)

kernel vec4 combineChannels(sampler ImageR, sampler ImageG, sampler ImageB)
{
	float R = sample(ImageR, samplerCoord(ImageR)).r;
	float G = sample(ImageG, samplerCoord(ImageG)).r;
	float B = sample(ImageB, samplerCoord(ImageB)).r;

	return vec4(R, G, B, 1.0);
}

Javascript (bottom panel)

function __image main(__boolean Trigger) {
	
	var dims = new Vec(256,256);
	var gradDims = new Vec(0,0,dims.x,dims.y);
	
	var black = new Vec(0,0,0,1);
	var white = new Vec(1,1,1,1);
	
	var p0 = new Vec(Math.random() * dims.x, Math.random() * dims.y);
	var p1 = new Vec(Math.random() * dims.x, Math.random() * dims.y);
	
	var gradR = Filter.CILinearGradient(p0, p1, black, white);
	gradR = Filter.CICrop(gradR, gradDims);

	p0 = new Vec(Math.random() * dims.x, Math.random() * dims.y);
	p1 = new Vec(Math.random() * dims.x, Math.random() * dims.y);
	
	var gradG = Filter.CILinearGradient(p0, p1, black, white);
	gradG = Filter.CICrop(gradG, gradDims);
	
	p0 = new Vec(Math.random() * dims.x, Math.random() * dims.y);
	p1 = new Vec(Math.random() * dims.x, Math.random() * dims.y);
	
	var gradB = Filter.CILinearGradient(p0, p1, black, white);
	gradB = Filter.CICrop(gradB, gradDims);
	
	
	// Call kernel function and return result
	return combineChannels.apply(gradR.definition, null, gradR, gradG, gradB);
}
16
Jun
09

Borg 2D

Another 2D pattern-generator.




Twitter

  • RT @qikipedia: "Anyone who is capable of getting themselves made President should on no account be allowed to do the job." DOUGLAS ADAMS 2 days ago
  • RT @_psonice: @johnreppion Did they really put Paul Nuttal's orgasm face on the bus? That has to be photoshopped. 1 week ago
  • RT @_psonice: Also happened by Lacy's Caves. Good spot. Path was washed away further up, nearly lost a bollock to barb wire going round. Wo… 1 week ago
June 2009
M T W T F S S
« May   Jul »
1234567
891011121314
15161718192021
22232425262728
2930  

Links

Blog Stats

  • 470,062 hits