In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

ひよこちゃん [2.5D] 増殖の巻

//////////////////////////////////////////////////////////////////////////////
ひよこちゃん [2.5D] 増殖の巻
//////////////////////////////////////////////////////////////////////////////
Get Adobe Flash player
by ProjectNya 18 Jun 2010
    Embed
/**
 * Copyright ProjectNya ( http://wonderfl.net/user/ProjectNya )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/flKJ
 */

////////////////////////////////////////////////////////////////////////////////
// ひよこちゃん [2.5D] 増殖の巻
////////////////////////////////////////////////////////////////////////////////

package {

	import flash.display.Sprite;
	import flash.display.MovieClip;
	import flash.display.Loader;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.net.URLRequest;
	import flash.system.Security;
	import flash.system.LoaderContext;
	import flash.geom.Rectangle;
	import frocessing.color.ColorHSV;

	[SWF(backgroundColor="#FFFFFF", width="465", height="465", frameRate="30")]

	public class Main extends Sprite {
		private var loader:Loader;
		private static var piyoPath:String = "http://www.project-nya.jp/images/flash/piyo25d.swf";
		private var Piyo:Class;
		private var piyos:Array;

		public function Main() {
			//Wonderfl.disable_capture();
			Wonderfl.capture_delay(4);
			init();
		}

		private function init():void {
			draw();
			Security.allowDomain("www.project-nya.jp");
			loader = new Loader();
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, complete, false, 0, true);
			loader.load(new URLRequest(piyoPath), new LoaderContext(true));
		}
		private function complete(evt:Event):void {
			loader.removeEventListener(Event.COMPLETE, complete);
			var content:MovieClip = MovieClip(evt.target.content);
			//Piyoクラス
			Piyo = MovieClip(content.piyo).constructor;
			setup();
			loader = null;
		}
		private function setup():void {
			piyos = new Array();
			for (var n:uint = 0; n < 44; n++) {
				var piyo:MovieClip = new Piyo();
				addChild(piyo);
				piyo.x = 55 + 70*(n%5.5);
				piyo.y = 80 + 50*Math.floor(n/5.5);
				piyo.rotate(0);
				piyos.push(piyo);
			}
			stage.addEventListener(MouseEvent.MOUSE_MOVE, update, false, 0, true);
		}
		private function update(evt:MouseEvent):void {
			var mx:Number = (stage.mouseX - 232)%232;
			for (var n:uint = 0; n < 44; n++) {
				var piyo:MovieClip = piyos[n];
				piyo.rotate(mx/232*90);
			}
		}
		/////////////////////////////////////////////
		//背景
		/////////////////////////////////////////////
		private function draw():void {
			var rect:Rectangle = new Rectangle(0, 0, 465, 465);
			var wavelet:Wavelet = new Wavelet(rect);
			addChild(wavelet);
			var color:ColorHSV = new ColorHSV();
			color.hsv(70, 1, 0.6);
			var color1:uint = color.value;
			color.hsv(60, 1, 0.4);
			var color2:uint = color.value;
			wavelet.color(color1, color2);
		}

	}

}




import flash.display.Sprite;
import flash.display.Shape;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.geom.Matrix;
import flash.display.GradientType;
import flash.display.SpreadMethod;
import flash.display.InterpolationMethod;
import flash.filters.BlurFilter;
import flash.geom.Rectangle;
import flash.geom.Point;
import flash.display.BlendMode;
import flash.filters.ColorMatrixFilter;
//import com.quasimondo.geom.ColorMatrix;

class Wavelet extends Sprite {
	private var rect:Rectangle;
	private var wavelet:BitmapData;
	private var noise:BitmapData;
	private var overlay:Shape;
	private static var scale:Number = 1.6;
	private var color1:uint;
	private var color2:uint;

	public function Wavelet(r:Rectangle) {
		rect = r;
	}

	public function color(c1:uint, c2:uint):void {
		color1 = c1;
		color2 = c2;
		draw();
	}
	private function draw():void {
		wavelet = new BitmapData(rect.width, rect.height, false);
		noise = new BitmapData(rect.width/scale, rect.height/scale, false);
		noise.noise(1, 0, 255, 7, true);
		var blur:BlurFilter = new BlurFilter(20, 0, 3);
		noise.applyFilter(noise, noise.rect, new Point(), blur);
		var matrix:Matrix = new Matrix();
		matrix.scale(scale, scale);
		var colorMatrixFilter:ColorMatrixFilter = new ColorMatrixFilter();
		//var colorMatrix:ColorMatrix = new ColorMatrix();
		//colorMatrix.adjustContrast(0.6);
		//colorMatrixFilter.matrix = colorMatrix.matrix;
		colorMatrixFilter.matrix = adjustContrast(0.6);
		noise.applyFilter(noise, noise.rect, new Point(), colorMatrixFilter);
		wavelet.draw(noise, matrix, null, BlendMode.DIFFERENCE);
		drawOverlay();
		addChild(new Bitmap(wavelet));
	}
	private function adjustContrast(s:Number):Array {
		var r:Number;
		var g:Number;
		var b:Number;
		r = g = b = s + 1;
		return [r, 0, 0, 0, (128 * (1 - r)), 0, g, 0, 0, (128 * (1 - g)), 0, 0, b, 0, (128 * (1 - b)), 0, 0, 0, 1, 0];
	}
	private function drawOverlay():void {
		overlay = new Shape();
		var colors:Array = [color1, color2]
		var alphas:Array = [1, 1];
		var ratios:Array = [0, 255];
		var matrix:Matrix = new Matrix();
		matrix.createGradientBox(rect.width, rect.height, 0.5*Math.PI, 0, 0);
		overlay.graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, matrix, SpreadMethod.REFLECT, InterpolationMethod.RGB, 0);
		overlay.graphics.drawRect(0, 0, rect.width, rect.height);
		overlay.graphics.endFill();
		wavelet.draw(overlay, null, null, BlendMode.HARDLIGHT);
		wavelet.draw(overlay, null, null, BlendMode.OVERLAY);
	}

}