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

クローバー

せっかくハートつくったのでついでにクローバー
Get Adobe Flash player
by zahir 30 Dec 2008
    Embed
// write as3 code here..
//せっかくハートつくったのでついでにクローバー
package{
	import flash.display.Sprite;
	import frocessing.core.GraphicsEx;
	
	[SWF(width="300", height="300", backgroundColor=0xFFFFFF)]

	public class Clover extends Sprite{
		public function Clover(){
			super();
			
			var leafW:int = 30;
			var leafH:int = 35;
			var fill:uint = 0x66FF00;
			var stroke:uint = 0x33EE00;
			var thickness:Number = 3;
			
			var clover:Sprite = new Sprite();
			var leaf1:Hart2 = new Hart2(leafW, leafH, fill, stroke, thickness);
			
			var leaf2:Hart2 = new Hart2(leafW, leafH, fill, stroke, thickness);
			leaf2.rotation = 110;
			leaf2.x = 55.5;
			leaf2.y = 36.8;
			
			var leaf3:Hart2 = new Hart2(leafW, leafH, fill, stroke, thickness);
			leaf3.rotation = 250;
			leaf3.x = -15;
			leaf3.y = 65;
			
			this.addChild(clover);
			clover.addChild(leaf1);
			clover.addChild(leaf2);
			clover.addChild(leaf3);
			
			var sw:Number = this.stage.stageWidth;
			var sh:Number = this.stage.stageHeight;
			
			clover.x = sw/2 - 15;
			clover.y = sh/2 - 44;
			
			
			var g:GraphicsEx = new GraphicsEx(graphics);
			
			g.lineStyle(thickness, stroke);
			g.moveTo(150, 150);
			g.bezierTo(140,175, 160,175 , 150, 200);
		}
	}
}


import flash.display.Shape;
import flash.geom.Point;
import frocessing.core.GraphicsEx;

class Hart2 extends Shape{
	
	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(w:int, h:int , fill:uint, stroke:uint, thickness:Number = 0, alp:Number = 1){
		super();
		hW = w/2; hH = h/2;
		
		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(thickness, stroke, alp)
		g.beginFill(fill,alp);
		
		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();
	}
	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;
	}
}