Author Archives: Zevan

Convex/Concave Function

Didn’t get a chance to post today but will do two posts tomorrow… been looking into things related to convex and concave functions… here are some links related to that topic:
http://en.wikipedia.org/wiki/Convex_function
http://www.economics.utoronto.ca/osborne/MathTutorial/CVNF.HTM
Will probably have at least two snippets related to this in the near future…

Posted in misc | Leave a comment

Another Matrix.transformPoint()

CLICK HERE TO COPY
Actionscript:

[SWF(width = 628, height=500)]

var trans:Matrix = new Matrix();

var pnt:Point = new Point();

x = stage.stageWidth / 2;

y = stage.stageHeight / 2;

addEventListener(Event.ENTER_FRAME, onLoop);

function onLoop(evt:Event):void {

    graphics.clear();

    graphics.lineStyle(10, 0x000000, 1, false, LineScaleMode.NORMAL, CapsStyle.SQUARE);

    pnt.x = 0;

    pnt.y = 0;

    trans.identity();

    trans.translate(15,15);

    trans.rotate(mouseX/10 * Math.PI / 180);

    graphics.moveTo(pnt.x, [...]

Posted in matrix, motion | 2 Comments

setVector vs copyPixels

CLICK HERE TO COPY
Actionscript:

var brushNum:int = 10000;

var canvas:BitmapData = new BitmapData(800,600,false, 0x000000);

addChild(new Bitmap(canvas));

 

var shape:Shape = new Shape();

with(shape.graphics) beginFill(0xFF0000), drawCircle(10,10,5);

shape.filters = [new BlurFilter(6, 6, 4)];

 

var brush:BitmapData = new BitmapData(20, 20, false, 0x000000);

brush.draw(shape, shape.transform.matrix);

 

 

 

// make sure brushVect is fixed length

var brushVect:Vector.<uint> = new Vector.<uint>(brush.width * brush.height, true);

var tempVect:Vector.<uint> =  brush.getVector(brush.rect);

var i:int = 0;

// quick hack to retain [...]

Posted in BitmapData, Vector | 7 Comments

BlendModes & Blur

CLICK HERE TO COPY
Actionscript:

[SWF(width = 750, height = 750)]

var canvas:BitmapData = new BitmapData(750,1000,false, 0x000000);

addChild(new Bitmap(canvas));

 

var loader:Loader = new Loader();

loader.load(new URLRequest("http://actionsnippet.com/imgs/paint.jpg"));

loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded);

var bit:BitmapData

var blurred:BitmapData;

function onLoaded(evt:Event):void{

    bit = Bitmap(evt.target.content).bitmapData;

    blurred = bit.clone();

    blurred.applyFilter(blurred, blurred.rect, new Point(0,0), new BlurFilter(4, 4, 6));

    var blends:Array = [BlendMode.NORMAL,BlendMode.ADD, BlendMode.DARKEN,BlendMode.HARDLIGHT,BlendMode.LIGHTEN, BlendMode.MULTIPLY, BlendMode.OVERLAY,BlendMode.SCREEN, BlendMode.DIFFERENCE];

    var m:Matrix = new [...]

Posted in BitmapData, misc | Tagged , , | 6 Comments