Acumen Development

  • Acumen Development
  • Acumen Systems
  • Acumen Third Sector
  • About Us
  • Websites
  • Web Applications
  • Branding
  • Support
  • Contact Us

Actionscript 3 Twirl Filter

recent news

  • Wordpress and Subversion
    Leo Brown, 1st June

  • Working with Corrupt Subversion Repositories
    Leo Brown, 20th January

  • Integrating with Web1.0 Service Providers
    Leo Brown, 4th June

  • WordPress Text Replacement Plugin
    Leo Brown, 14th February

  • Direct Email Reception
    Leo Brown, 2nd January

Project Request Form

Download a project request form here

Actionscript 3 Twirl Filter

November 18, 2008
categories: General

I’m releasing this filter as I couldn’t find an appropriate one out there. It lets you twirl a spiral into any Actionscript display object, and is fast enough to allow it to be animated.


You can get the source from here, both an animated and static examples are included.


One Response to “Actionscript 3 Twirl Filter”

  • update on August 4th, 2010 at 4:04 pm

    hi, thanks for the filter idea.

    i made it a little bit lighter and faster:
    public static function twirl(x_pos:Number,y_pos:Number,w:Number,h:Number,radius:Number,twistyness:Number):DisplacementMapFilter
    {
    var imageData:BitmapData=new BitmapData(w,h,true,0xFF808080);
    var half_w:Number=w/2
    var half_h:Number=h/2
    var maxDistance:Number=Math.sqrt(Math.pow(half_w,2)+Math.pow(half_h,1));
    for(var x:int=0;x<w;x++)
    {
    for(var y:int=0;y<h;y++)
    {
    var p:Point=new Point(x-half_w,y-half_h);
    var r:Number=Math.sqrt(Math.pow(p.x,2)+Math.pow(p.y,2));
    var angularDisplacement:Number=Math.atan2(p.y,p.x)+Math.pow(twistyness*Math.max(Math.max(radius,radius)-r,0)/maxDistance,2);
    imageData.setPixel(x,y,new ColorTransform(1,1,1,1,128*(1+(((r)*Math.cos(angularDisplacement))-p.x)/maxDistance),128*(1+(((r)*Math.sin(angularDisplacement))-p.y)/maxDistance)).color);
    };
    };
    return new DisplacementMapFilter(imageData,new Point(x_pos,y_pos),BitmapDataChannel.RED,BitmapDataChannel.GREEN,w,h,"ignore");


Leave a Reply