<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dirty Motherfucking Blog &#187; graffiti</title>
	<atom:link href="http://dirty-motherfucker.org/blog/tag/graffiti/feed/" rel="self" type="application/rss+xml" />
	<link>http://dirty-motherfucker.org/blog</link>
	<description>All kinds of shit</description>
	<lastBuildDate>Wed, 09 May 2012 12:49:30 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4-beta4-20750</generator>
		<item>
		<title>Furry Blog Logo</title>
		<link>http://dirty-motherfucker.org/blog/2008/11/13/furry-blog-logo/</link>
		<comments>http://dirty-motherfucker.org/blog/2008/11/13/furry-blog-logo/#comments</comments>
		<pubDate>Thu, 13 Nov 2008 00:20:39 +0000</pubDate>
		<dc:creator>gencha</dc:creator>
				<category><![CDATA[actionscript]]></category>
		<category><![CDATA[graffiti]]></category>

		<guid isPermaLink="false">http://www.dirty-motherfucker.org/blog/?p=186</guid>
		<description><![CDATA[Update: I updated the .swf files. So hopefully now those pesky Flash Player errors are gone :( Shame on me for bad coding. I had a little fun with particles in AS3 the past days. I wrote a small piece based on my Processing port framework that traces the paths of particles. The particles pick [...]]]></description>
			<content:encoded><![CDATA[<p>Update: I updated the .swf files. So hopefully now those pesky Flash Player errors are gone :( Shame on me for bad coding.</p>
<p>I had a little fun with particles in AS3 the past days. I wrote a small piece based on my Processing port framework that traces the paths of particles. The particles pick up color from a given input texture. As they move, they plot their color onto the canvas. Although i added the condition that the color is only plotted if the target pixel is darker than the particle color. This results in a nice glowing effect around the outline of the image.<br />
I built the swf files against Flash Player 10 this time. There is actually no need at all to do so, but i just couldn&#8217;t resist Vector<T>. Arrays are so dirty :(</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_tracer_small_696452187"
			class="flashmovie"
			width="466"
			height="220">
	<param name="movie" value="http://www.dirty-motherfucker.org/blog/wp-content/uploads/2008/11/tracer_small.swf" />
	<param name="play" value="false" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.dirty-motherfucker.org/blog/wp-content/uploads/2008/11/tracer_small.swf"
			name="fm_tracer_small_696452187"
			width="466"
			height="220">
		<param name="play" value="false" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>Here is the <a href="http://www.dirty-motherfucker.org/blog/wp-content/uploads/2008/11/tracer_large.swf">larger version</a> with the complete blog logo. ;)</p>
<p>And here&#8217;s some source to go with it. Although it&#8217;ll hardly compile outside of the Processing Port framework ;D But since i moved servers my SVN repository isn&#8217;t publicly available anymore. So if anyone has any interest in the complete source, i&#8217;ll wrap it up and put it online ;)</p>
<p>Particle.as</p>
<pre class="brush: as3; title: ; notranslate">
package org.dirty_dirtymotherfucker.tracer {
  import flash.display.BitmapData;
  import flash.geom.Point;
  import flash.geom.Rectangle;
  import org.dirty_dirtymotherfucker.processing.*;
  
  public class Particle {
    
    public var position_x:Number;
    public var position_y:Number;
    public var direction_x:Number;
    public var direction_y:Number;
    public var color:uint;
    public var life:Number;
    public var source:BitmapData;
    public var randomSource:BitmapData;
    
    public function Particle( source:BitmapData, randomSource:BitmapData, sourceOffset:uint ) {
      this.source = source;
      if( Tracer.USE_PERLIN_NOISE ) {
        this.randomSource = new BitmapData( randomSource.width, 1, false );
        this.randomSource.copyPixels( randomSource, new Rectangle( 0, sourceOffset, randomSource.width, 1 ), new Point( 0, 0 ) );
      }
      birth();
    }
    
    public function birth( ):void {
      life        = Tracer.MAX_PARTICLE_LIFE;
      position_x  = MathHelper.randomRange( -Tracer.CANVAS_SIZE_X, Tracer.CANVAS_SIZE_X );
      position_y  = MathHelper.randomRange( -Tracer.CANVAS_SIZE_Y, Tracer.CANVAS_SIZE_Y );
      direction_x = MathHelper.randomRange( -1.0, 1.0 );
      direction_y = MathHelper.randomRange( -1.0, 1.0 );
      color       = source.getPixel32( position_x, position_y );
    }
    
    public function travel( source:BitmapData, canvas:BitmapData, blend:Number ):void {
      if( Tracer.USE_PERLIN_NOISE ) {
        direction_x += ( ColorHelper.getR( randomSource.getPixel( life * 10, 0 ) ) - 128 ) / 256;
        direction_y += ( ColorHelper.getG( randomSource.getPixel( life * 10, 0 ) ) - 128 ) / 256;
      } else {
        direction_x += MathHelper.randomRange( -0.1, 0.1 );
        direction_y += MathHelper.randomRange( -0.1, 0.1 );
      }
      
      // normalize direction
      var len:Number = Math.sqrt( direction_x * direction_x + direction_y * direction_y );
      direction_x /= len;
      direction_y /= len;
      
      position_x += direction_x;
      position_y += direction_y;
      life -= 0.1;
      //if( 0 == color ) life = 0;
      
      var sourceColor:uint = source.getPixel32( position_x, position_y );
      var canvasColor:uint = canvas.getPixel32( position_x, position_y );
      
      if( sourceColor != canvasColor ) {
        color = ColorHelper.blend( color, sourceColor, blend );
      
        var colorFit:Boolean = ColorHelper.getR( ColorHelper.toGrayScale( color ) ) &gt; ColorHelper.getR( ColorHelper.toGrayScale( canvasColor ) );
        if( 0 != ColorHelper.getA( color ) &amp;&amp; colorFit ) {
          canvas.setPixel32( position_x, position_y, ColorHelper.blend( color, canvasColor, 25 ) );
          //canvas.setPixel32( position.x, position.y, color );
        }
      }
      
      if( 0 &gt; position_x || position_x &gt; Tracer.CANVAS_SIZE_X || 0 &gt; position_y || position_y &gt; Tracer.CANVAS_SIZE_Y || 0 &gt;= life ) birth();
    }
    
  }
  
}
</pre>
<p>Tracer.as</p>
<pre class="brush: as3; title: ; notranslate">
package org.dirty_dirtymotherfucker.tracer {
  
  import flash.display.*;
  import flash.events.*;
  import flash.geom.Matrix;
  import flash.geom.Point;
  import flash.geom.Rectangle;
  import flash.net.URLLoader;
  import flash.net.URLRequest;
  
  import org.dirty_dirtymotherfucker.processing.*;
  
  /**
   * The main implementation of the Tracer project
   */
  public class Tracer extends BlogSprite {
    
    // Main application settings
    
    public static const CANVAS_BACKGROUND_COLOR:uint  = 0xFF000000;
    
    public static const UPDATES_PER_SECOND:uint       = 1200;
    
    public static const ITERATIONS_PER_UPDATE:uint    = 10;
    
    public static const CANVAS_SIZE_X:uint            = 466;// 840;
    public static const CANVAS_SIZE_Y:uint            = 220;
    
    public static const ADDITIVE_BLENDING:Boolean     = true;
    public static const SUBTRACTIVE_BLENDING:Boolean  = false;
    private static const MAX_ITERATIONS:uint          = 0;// 120 * 20;
    
    public static const MAX_PARTICLE_LIFE:Number      = 100;
    public static const NUM_PARTICLES:int             = 1000;
    
    public static const USE_PERLIN_NOISE:Boolean      = false;
    
    private var iterationCount:int = 0;
    
    private var loader:Loader;
    private var source:BitmapData;
    private var randomSeed:BitmapData;
    
    private var particles:Vector.&lt;Particle&gt;;
    
    private var blend:Number;
    
    public function Tracer():void {
      ColorHelper.loadPalette( );
      
      super( CANVAS_SIZE_X, CANVAS_SIZE_Y, CANVAS_BACKGROUND_COLOR );
      
      loader = new Loader();
      //loader.load( new URLRequest( &quot;map.png&quot; ) );
      loader.load( new URLRequest( &quot;http://www.dirty-motherfucker.org/blog/wp-content/uploads/2008/11/motherfucking.png&quot; ) );
      
      loader.contentLoaderInfo.addEventListener( Event.COMPLETE, drawMap );
    }
    
    override protected function onDraw( event:TimerEvent ):void {
      canvas.lock();
      for( var iteration:uint = 0; iteration &lt; ITERATIONS_PER_UPDATE; ++iteration ) {
        // draw
        if( null == loader.content ) break;
        for each( var particle:Particle in particles ) {
          particle.travel( source, canvas, blend );
        }
        
        blend += 0.06;
        if( blend &gt;= 255 ) stopApp();
        
        // cycle limiter
        if( MAX_ITERATIONS &gt; 0 &amp;&amp; ++iterationCount &gt; MAX_ITERATIONS ) {
          restart();
        }
      }
      canvas.unlock();

    }
    
    override protected function startApp( updatesPerSecond:uint = 0 ):void {
      super.startApp( UPDATES_PER_SECOND );
      
      particles = new Vector.&lt;Particle&gt;();
      
      blend = 10;
      
      iterationCount = 0;
      
      canvas.fillRect( new Rectangle( 0, 0, CANVAS_SIZE_X, CANVAS_SIZE_Y ), CANVAS_BACKGROUND_COLOR );
      
      initContent();
    }
    
    private function drawMap( e:Event ):void {
      loader.removeEventListener( Event.COMPLETE, drawMap );
      
      initContent();
    }
    
    private function initContent():void {
      if( null == loader ) return;
      source = new BitmapData( CANVAS_SIZE_X, CANVAS_SIZE_Y, true, 0x00000000 );
      var matrix:Matrix = new Matrix();
      matrix.translate( 0, CANVAS_SIZE_Y / 2 - loader.height / 2 );
      source.draw( loader, matrix );
      
      if( USE_PERLIN_NOISE ) {
        randomSeed = new BitmapData( MAX_PARTICLE_LIFE * 10, NUM_PARTICLES, false, 0x000000 );
        randomSeed.perlinNoise( MAX_PARTICLE_LIFE * 10, NUM_PARTICLES, 8, Math.random() * uint.MAX_VALUE, true, true, BitmapDataChannel.GREEN | BitmapDataChannel.RED, false );
      }
      
      for( var i:uint = 0; i &lt; NUM_PARTICLES; ++i ) {
        particles.push( new Particle( source, randomSeed, i ) );
      }
      
    }

  }
  
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://dirty-motherfucker.org/blog/2008/11/13/furry-blog-logo/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

