Posts Tagged ‘math’

Make a regular N-gon, or two.

Posted in Flash on December 7th, 2009 by hp. – 2 Comments
package views.shapes {
import flash.events.Event;
import flash.display.Shape;
 
public class Ngon extends Shape {
 
	protected function redraw():void {			
		var r:Number = radius;
		var a:Number = angle;							
		var s:Number = Math.PI*2/sides;
		graphics.clear();
		graphics.beginFill(color,1);
		for (var i:uint = 0; i<=sides; ++i) {
			graphics.lineTo(r*Math.cos(a+s*i),r*Math.sin(a+s*i));
		}			
	}
 
	private var _sides:uint = 3;
	public function get sides():uint { return _sides; }
	public function set sides(value:uint):void {
		if (value !== _sides) { 
			_sides = value;
			redraw();
		}
	}	
 
	private var _color:uint = 0x0;
	public function get color():uint { return _color; }
	public function set color(value:uint):void {
		if (value !== _color) { 
			_color = value; 
			redraw()
		}
	}
 
	private var _radius:Number;
	public function get radius():Number { return _radius; }
	public function set radius(value:Number):void {
		if (value !== _radius) { 
			_radius = value;
			redraw();
		}
	}
 
	private var _angle:Number;
	public function get angle():Number { return _angle; }
	public function set angle(value:Number):void {
		if (value !== _angle) { 
			_angle = value; 
			redraw();
		}
	}
 
}
}

Nature is math.

Posted in Flash on August 27th, 2009 by hp. – 1 Comment

And a great reference when you want to create natural curves.
Found Functions

How about a bell-curve?

How about a bell-curve?

Awesome search engine..

Posted in Flash on May 22nd, 2009 by Thomas H – Be the first to comment

..or should I say Computational knowledge engine. NRK Beta reports on WolframAlpha who is gathering all the information gathered by our civilization ( they claim ) and making the data computational. Its pretty impressive. Watch the introduction or just try it out yourself. Type in your name, a piece of math ( e.g. sin(2pi*x)^2 from Alexanders flash challenge ) or AGTAAAAATTGAGTT or something completely different. Maybe not really flash related but a great tool nontheless.