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

Panton Kurve

Kurve, Verner Panton, 1960.
@author Mario Gonzalez, inspired by levitated
/**
 * Copyright onedayitwillmake ( http://wonderfl.net/user/onedayitwillmake )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/w1t5
 */

package  
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Matrix;
	import frocessing.color.ColorHSV;
	  import flash.display.GradientType;
    import flash.display.SpreadMethod;
	
	/**
	 * Kurve, Verner Panton, 1960.
	 * @author Mario Gonzalez, inspired by levitated
	 */
	[SWF(width="465",height="465", backgroundColor="#000000")]
	public class Kurve extends Sprite
	{
		public var _dy	:Number = 0;
		public var _dx	:Number = 0;
		public var _vx	:Number = 0;
		public var _vy	:Number = 0;
		
		private var _epicenter			:PantoneCurve;
		
		public static var ENVIRONMENT	:Kurve;
		public static var DEGREES		:Number = 0.0174532925;
		public static var HALF_STAGE	:int;
		public static var HSV			:ColorHSV;
		
		public function Kurve() 
		{
			Wonderfl.capture_delay(12);;
			
			stage.quality = 'medium';
			stage.frameRate = 120;
			HSV = new ColorHSV(-16, 0.75, 1);
			
			//var gradientColo1r:ColorHSV = new ColorHSV(200, 0.75, 1);
			var h:int = Math.random() * 360;
			var s:Number = 0.4;
			
			//addChild(createBG(new ColorHSV(h, s, 0.01).value, new ColorHSV(h, s, 0.0).value));
			ENVIRONMENT = this;
			HALF_STAGE = stage.stageWidth * 0.5;
			
			_epicenter = new PantoneCurve();
			addChild(_epicenter);
			
			addEventListener(Event.ENTER_FRAME, loop);
		}
		
		private function loop(e:Event):void 
		{
			_vx += (-_dx  - _epicenter.x + HALF_STAGE) * 0.000125
			_vy += (-_dy  - _epicenter.y + HALF_STAGE) * 0.000125
			
			_epicenter.x += _vx;
			_epicenter.y += _vy;
			
			_vx *= 0.99;
			_vy *= 0.99;
		}
	}
}

import flash.display.Graphics;
import flash.display.Shape;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.TimerEvent;
import flash.geom.ColorTransform;
import flash.geom.Point
import flash.utils.setTimeout;
import flash.utils.Timer;
import frocessing.color.ColorHSV;
import gs.easing.Sine;
import gs.TweenLite;
import gs.TweenMax;

class PantoneCurve extends Sprite
{
	private var _drawTimer		:Timer
	public var _sign			:int = -1;
	//
	public var _epicenter		:Point = new Point();
	public var _bands			:int;
	public var _bandwidth		:int;
	
	public var _omega			:Number;
	public var _theta			:Number;
	
	//old xy values
	public var _oldPoint			:Point = new Point();
	public var _reallyOldPoint		:Point = new Point();
	
	public static var CIRCLE	:Number = Math.PI * 2;
	
	
	public function PantoneCurve():void
	{
		setEpicenter(0, 0)
		setBands(6);
		setBandwidth(18)
		setTheta(0);
		
		_drawTimer = new Timer(500, 0);
		_drawTimer.addEventListener(TimerEvent.TIMER, draw);
		_drawTimer.dispatchEvent(new TimerEvent(TimerEvent.TIMER));
		_drawTimer.start();
		
	}
	
	
	public function draw(t:TimerEvent):void
	{
		_omega = _sign * (120 + Math.random() * 160)
		var n	:int = 0;
		var neo	:PantoneCurvePath;
		
		Kurve.HSV.h -= 4
		var kolor:ColorHSV = Kurve.HSV.clone();
		for (n = 0; n < _bands; n++) 
		{
			kolor.v -= (0.9 / _bands);
			kolor.s -= (0.2 / _bands);
			neo = new PantoneCurvePath(this);
			addChild(neo);
			
			if (_sign > 0) neo.setPath(n);
			else neo.setPath(_bands - n - 1);
			
			neo.setColor(kolor.value);
			neo.render(_bandwidth, _theta, _omega, _epicenter.x, _epicenter.y)
		}
		
		_theta += _omega;
		_epicenter.x += _bandwidth * (_bands + 2) * Math.sin(Kurve.DEGREES * _theta);
		_epicenter.y += _bandwidth * (_bands + 2) * Math.cos(Kurve.DEGREES * _theta);
		
		_sign *= -1;
		_theta = (_theta + 180) % 360;
		
		Kurve.ENVIRONMENT._dx = _oldPoint.x;
		Kurve.ENVIRONMENT._dy = _oldPoint.y;
		
		_reallyOldPoint.x = _oldPoint.x;
		_reallyOldPoint.y = _oldPoint.y;
		
		_oldPoint.x = _epicenter.x;
		_oldPoint.y = _epicenter.y;
	}
	
	public function setEpicenter($x:Number, $y:Number):void
	{
		_epicenter.x = x;
		_epicenter.y = y;
	}
	
	public function setBands(value:int):void
	{
		_bands = value
	}
	
	public function setBandwidth(value:int):void
	{
		_bandwidth = value;
	}
	
	public function setTheta(value:Number):void
	{
		_theta = value;
	}
}

import flash.display.Graphics;

class PantoneCurvePath extends Shape
{
	public var _color		:int;
	public var _path		:Number;
	public var _owner		:PantoneCurve;
	public var $			:Graphics = graphics;
	
	public var offset		:Number = 0;
	public function PantoneCurvePath(owner:PantoneCurve)
	{
		_owner = owner;
		fadeMe();
		
		TweenMax.to(this, 0.5, { ease: Sine.easeIn, offset: 1, onUpdate: fadeMe } );
		TweenMax.to(this, 1, {ease: Sine.easeIn, delay: 10, offset: 0, onUpdate: fadeMe, onComplete: destroy } );
	}
	
	/**
	 * Tweenmax doesn't work here, maybe my build is broken 
	 */
	private function fadeMe():void 
	{
		var ct:ColorTransform = transform.colorTransform // = //ct new ColorTransform (0.92, 0.9, 1, 1, 0, 0, 0, -32);
			ct.alphaMultiplier = offset;
			transform.colorTransform = ct;
	}
	
	
	private function destroy():void
	{
		parent.removeChild(this);
		removeEventListener(Event.ENTER_FRAME, fadeMe);
		_owner = null;
	}
	
	public function render(b:Number, theta:Number, omega:Number, $x:Number, $y:Number):void
	{
		x = $x;
		y = $y;
		
		var r1		:Number = _path + 1;
		var r2		:Number = _path + 2;
		var rez		:Number = (_owner._bands - _path) * 2;
		
		// calculate all control points
		var sinTheta:Number = Math.sin(Kurve.DEGREES * theta);
		var cosTheta:Number = Math.cos(Kurve.DEGREES * theta);
		var sinThetaPlusOmega:Number = Math.sin(Kurve.DEGREES * (theta + omega));
		var cosThetaPlusOmega:Number = Math.cos(Kurve.DEGREES * (theta + omega));

		
		var x0:Number = b * r1 * sinTheta;
		var y0:Number = b * r1 * cosTheta;
		var x1:Number = b * r2 * sinTheta;
		var y1:Number = b * r2 * cosTheta;
		var x2:Number = b * r2 * sinThetaPlusOmega;
		var y2:Number = b * r2 * cosThetaPlusOmega;
		var x3:Number = b * r1 * sinThetaPlusOmega;
		var y3:Number = b * r1 * cosThetaPlusOmega;
		
		// connect the dots
		$.moveTo(x0, y0);
		$.lineTo(x1, y1);
		
		var k:int;
		
		// draw outer curve
		if (omega > 0)
		{
			for (k = 0; k <= omega; k += rez)
				$.lineTo(b * r2 * Math.sin(Kurve.DEGREES * (theta + k)), b * r2 * Math.cos(Kurve.DEGREES * (theta + k)));
		} 
		else
		{
			for (k = 0; k >= omega; k -= rez)
				$.lineTo(b * r2 * Math.sin(Kurve.DEGREES * (theta + k)), b * r2 * Math.cos(Kurve.DEGREES * (theta + k)));
		}
		
		$.lineTo(x2, y2);
		$.lineTo(x3, y3);
		
		// draw inner curve
		if (omega > 0)
		{
			for (k = omega; k >= 0; k -= rez)
				$.lineTo(b * r1 * Math.sin(Kurve.DEGREES * (theta + k)), b * r1 * Math.cos(Kurve.DEGREES * (theta + k)));
		} else {
			for (k = omega; k <= 0; k += rez)
				$.lineTo(b * r1 * Math.sin(Kurve.DEGREES * (theta + k)), b * r1 * Math.cos(Kurve.DEGREES * (theta + k)));
		}
		$.lineTo(x0, y0);
	}
	
	public function setColor(color:uint):void
	{
		_color = color;
		
		$.beginFill(color, 1);
		$.lineStyle(0,color, 1);
	}
	
	public function setPath(value:Number):void
	{
		_path = value;
	}
}