Microscopy Sketch (emboss)
Monday, September 29th, 2008I've been tweaking a programmatic sketch for the past couple days... It contains three cell-like elements that randomly move around the screen. I've been trying to decide how to take it further...
Click above image to view flash version
To take it farther I just want to add some additional elements and maybe change the cells behavior a bit - something more than just floating around randomly - I'd like to have them eat other little cells - or change/die over time...
A few years back I wrote something like this in director. It runs super fast now because I put the framerate at 999... too lazy to go through my archives and dig up the .dir... so here's a still:
Using a convolution filter to create an emboss works nicely, but is very very slow. You can create an emboss effect by using copyPixels(), draw(), blend modes and a BlurFilter:
-
var canvas:BitmapData = new BitmapData(500, 500, true, 0xFFFFFFFF);
-
var color:BitmapData= new BitmapData(500, 500, true, 0x81666666);
-
var over:BitmapData = new BitmapData(500, 500, true, 0xFF000000);
-
addChild(new Bitmap(canvas, "auto", true));
-
-
var circle:Shape = new Shape();
-
circle.graphics.beginFill(0xFFFFFF,1);
-
circle.graphics.drawCircle(0,0,50);
-
-
-
var m:Matrix = new Matrix();
-
-
m.tx = 0;
-
m.ty = 1;
-
-
addEventListener(Event.ENTER_FRAME, onLoop);
-
function onLoop(evt:Event):void {
-
-
circle.x = mouseX;
-
circle.y = mouseY;
-
canvas.draw(circle, circle.transform.matrix);
-
-
canvas.copyPixels(color, color.rect, new Point(0,0), null, null, true);
-
-
over.copyPixels(canvas, canvas.rect, new Point(0,0), null, null, true);
-
-
canvas.draw(over, m, null, BlendMode.SCREEN);
-
over.applyFilter(over, over.rect, new Point(-2,-2), new BlurFilter(10,10,1));
-
-
canvas.draw(over, m, null, BlendMode.SUBTRACT);
-
}
I also did this kind of emboss in processing a few years back. The meat of that looked like this:
-
ellipse(mouseX,mouseY,60,60);
-
-
for(int i=0; i<(width*height)-offset; i++){
-
pixels[i] = ((int)((~pixels[i] & 0xff)*0.25f + (pixels[i+offset] & 0xff) * 0.75f)*65793);
-
}