WEAVE beta – Flash: BitmapData.hitTest()
Der Computational Artisan Mario Klingemann aus München zweckentfremdet gerne Technik. Beispielsweise mit seiner generativen, auf Flash basierenden Technik “Image Foam”. Hier der Code für die Basis-Anwendung:
var brush:Shape = new Shape();
brush.graphics.beginFill( 0 );
brush.graphics.drawCircle( 0, 0, 60 );
brush.graphics.endFill();
var map:BitmapData = new BitmapData( 500, 500, true, 0 );
addChild( new Bitmap( map ) );
var testMap:BitmapData = map.clone();
var m:Matrix = new Matrix();
var nextPoint:int = 1 + Math.random() * map.width * map.height;
var origin:Point = new Point();
stage.addEventListener( Event.ENTER_FRAME, draw );
function draw( event:Event ):void
{
for ( var i:int = 0; i < 20; i++ )
{
var ok:Boolean = false;
nextPoint = testMap.pixelDissolve( testMap, testMap.rect,origin, nextPoint, 1 );
m.tx = nextPoint % map.width;
m.ty = nextPoint / map.width;
if ( map.getPixel32( m.tx, m.ty ) == 0 )
{
var targetWidth:int = 5;
while ( targetWidth <= brush.width )
{
m.a = m.d = targetWidth / brush.width;
testMap.fillRect( testMap.rect, 0 );
testMap.draw( brush, m );
if ( map.hitTest( origin, 127, testMap, origin, 127 ) ) break;
ok = true;
targetWidth++;
}
if ( ok )
{
m.a = m.d = ( targetWidth - 1 ) / brush.width;
map.draw( brush, m );
}
}
}
}










