Posted by: pixelero | July 5, 2009

BelousovZhabotinsky, with perspective

I just couldn’t resist the temptation of checking the BZ-cellular automaton of my previous post with some perspective-effect.

Demo (keyboard: esc for fullScreen, delete for a new generation)

btw … if pattern appears too dense, make sure you’ve got the latest (FP 10.0r22) version installed.

I’ve already earlier demoed this principle, but I didn’t publish the code. The whole thing is done by first applying a perspective tiling, with graphics.drawTriangles, as in one of my earlier posts – and then adding the parallax effect by counting a displacement – a pixels position is raised by its color value – with BitmapData.set/getVector: then image is scanned through a vertical column by column. Here’s some essential part from the code: found in public function extrudeBitmapData

for (var column:Rectangle= new Rectangle(bmd.width,0,1,bmd.height); (column.x-=1)>-1 ; ) {

	levels = new Vector.<int>(bmd.height, true);

	pixels = bmd.getVector(column);

	heights = (heightMap) ? heightMap.getVector(column) : pixels ;

	//	first loop marks the displacements for each pixel
	//	'version 0.0' sampled from the blur-channel
	for (i = 0; ++i != bmd.height; ) {
		levels[i- ((heights[i]&0xFF) * i >>10) ] = i; // >>10 controls the height
	}

	//	displace the column
	for (iz = -1, i = 0; ++i != bmd.height;) {
		pixels[i] = (levels[i] > iz) ? pxl = pixels[iz = levels[i]] : pxl ;
	}

	//	rewrite on the image
	bmd.setVector(column, pixels);

}

So finally here’s that messy source with too few comments !

About these ads

Responses

  1. […] I just couldn’t resist the temptation of checking the BZ-cellular automaton of my previous post with some perspective-effect. Demo (keyboard: esc for fullScreen, delete for a new generation) btw … if pattern appears too dense, make sure you’ve got the latest (FP 10.0r22) version installed. See the original post here: BelousovZhabotinsky, with perspective […]

  2. Very cool. I’d bookmarked a few BZ resources a while ago but never got round to exploring it further. Nice to see your results.

  3. […] I was much more interested in ( impressed by) Pixelero’s Belousov-Zhabotinsky Reaction :) excellent article by Paul prudence here : […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: