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

Fill Hart

Frocessingを使って塗りのあるハートを描画
Get Adobe Flash player
by zahir 12 May 2009
//Frocessingを使って塗りのあるハートを描画
package {
	import flash.display.*;
	import flash.geom.Point;
	
	import frocessing.core.GraphicsEx;

	[SWF(width="300", height="300")] 

	public class Hart2 extends Sprite{
		
		public var dx:Number=0; public var dy:Number=0; // 描画原点
		public var cx:Number; public var cy:Number; // スプライトの中心点
		public var lineW:Number; public var lineC:uint; public var lineA:Number; public var mode:String;
		public var fillC:uint; public var fillA:Number;
		
		private var hW:Number; private var hH:Number;
		private var r:Number; private var r2:Number; private var r3:Number; private var r4:Number;
		private var margin:Number; private var bh:Number;
		private var theta:Number;
		
		private var top:Point; private var bottom:Point;
		private var rlpt:Point; private var rrpt:Point;
		private var lpt1:Point; private var rpt1:Point;
		private var lpt2:Point; private var rpt2:Point;
		private var lpt3:Point; private var rpt3:Point;
		
		//左の分 右の分
		private var hcpt1:Point; private var hcpt5:Point;
		private var hcpt2:Point; private var hcpt6:Point;
		private var hcpt3:Point; private var hcpt7:Point;
		private var hcpt4:Point; private var hcpt8:Point;
		
		
		private var g:GraphicsEx = new GraphicsEx(graphics);
		
		
		public function Hart2(){
			super();
			var w:int = 240;
			var h:int = 210;
			hW = w/2; hH = h/2;
			cx = hW; cy = hH;
			
			r = Math.round(hW/1.704);//半径
			rlpt = new Point(r,r);
			rrpt = new Point(w-r,r);
			
			r2 = hW - r;
			margin = r-r2;
			r3 = r+margin;
			bh = (h-hW)/2;
			theta = Math.atan(r2/bh) * 180 / Math.PI;
			r4 = r*1.15;
			
			var t3:Number=28.2;
			
			lpt1 = sumPoint(rlpt,r,360-theta); rpt1 = sumPoint(rrpt,r,theta);
			lpt2 = sumPoint(rlpt,r,270-theta); rpt2 = sumPoint(rrpt,r,270+theta);
			lpt3 = sumPoint(rlpt,r,180-theta); rpt3 = sumPoint(rrpt,r,180+theta);
			hcpt1 = sumPoint(rlpt,r4,360-theta-t3); hcpt5 = sumPoint(rrpt,r4,theta-t3);
			hcpt2 = sumPoint(rlpt,r4,270-theta+t3); hcpt6 = sumPoint(rrpt,r4,270+theta+t3);
			hcpt3 = sumPoint(rlpt,r4,270-theta-t3); hcpt7 = sumPoint(rrpt,r4,270+theta-t3);
			hcpt4 = sumPoint(rlpt,r4,180-theta+t3); hcpt8 = sumPoint(rrpt,r4,180+theta+t3);
			var r7:Number = margin+(lpt1.y -margin)/2;
			top = new Point(hW,r7); bottom = new Point(hW,h);
			
			
			g.lineStyle(5, 0xFF0000, 0.5)
			g.beginFill(0xFF66CC);
			
			g.moveTo(top.x, top.y);
			//g.lineTo(lpt1.x , lpt1.y);
			g.bezierTo(hcpt1.x, hcpt1.y, hcpt2.x, hcpt2.y, lpt2.x, lpt2.y);
			g.bezierTo(hcpt3.x, hcpt3.y, hcpt4.x, hcpt4.y, lpt3.x, lpt3.y);
			g.lineTo(bottom.x,bottom.y);
			g.lineTo(rpt1.x,rpt1.y);
			g.bezierTo(hcpt5.x, hcpt5.y, hcpt6.x, hcpt6.y, rpt2.x, rpt2.y);
			g.bezierTo(hcpt7.x, hcpt7.y, hcpt8.x, hcpt8.y, top.x,top.y);
			//g.lineTo(top.x,top.y);
			
			g.endFill();
			this.x = 30;
			this.y = 35;

			Wonderfl.capture_delay( 1 );
		}
		private function sumPoint(c:Point,rr:Number,theta:Number):Point{
			var rad:Number = Math.PI/180*theta;
			var cos:Number = c.x + rr * Math.cos(rad);
			var sin:Number = c.y + rr * Math.sin(rad);
			var pt:Point = new Point(cos,sin);
			return pt;
		}
	}
}