Revision: 25196
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at March 23, 2010 04:43 by ninemill
Initial Code
function findBlingPoints(o:*, n:Number, s:String="right"){ var myBitmapData:BitmapData = new BitmapData(o.width, o.height, true, 0x000000); myBitmapData.draw(o); var pixelValue:uint; var pointArray:Array = []; var currPixel:Boolean = false; var lastPixel:Boolean = false; for(var i=0; i<myBitmapData.width; i++){ pixelValue = myBitmapData.getPixel32(i, n); if(pixelValue==0){currPixel=false}else{currPixel=true}; switch (s){ case "right": if(!currPixel&&lastPixel){ pointArray[pointArray.length]=i; pointArray[pointArray.length]=n; } break; case "left": if(!lastPixel&&currPixel){ pointArray[pointArray.length]=i; pointArray[pointArray.length]=n; } break; case "both": if(lastPixel!=currPixel){ pointArray[pointArray.length]=i; pointArray[pointArray.length]=n; } break; } lastPixel = currPixel; } return pointArray; }
Initial URL
Initial Description
Initial Title
Find edges of an object
Initial Tags
Initial Language
ActionScript 3