Heart Generator
I am making something for my girlfriend for valentines and needed a heart shape, figure why not toss it out there for anyone to use.
/**
* Copyright netgrind ( http://wonderfl.net/user/netgrind )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/6Acc
*/
package {
import flash.display.Graphics;
import flash.display.Sprite;
/**
* @author netgrind
* HAPPY VALENTINES :D
* You can use this code to draw a heart shape (reg point in center)
*/
public class Heart extends Sprite {
public function Heart():void {
var h:Sprite = drawHeart(stage.stageHeight);
h.x = stage.stageHeight*.5;
h.y = stage.stageHeight*.5;
addChild(h);
}
public static function drawHeart(size:int = 100, color:uint = 0xFF0000, alpha:Number = 1):Sprite {
var s: Sprite = new Sprite();
var g:Graphics = s.graphics;
g.beginFill(color, alpha);;
g.moveTo(0, size * -.25);
g.cubicCurveTo(size*-.1, size*-.5, size*-.5,size*-.4,size*-.5, size*-.1);
g.cubicCurveTo(size*-.5, size*.1, size*-.1,size*.4,0, size*.5);
g.cubicCurveTo(size*.1,size*.4, size*.5, size*.1,size*.5, size*-.1);
g.cubicCurveTo(size*.5,size*-.4, size*.1, size*-.5,0, size*-.25);
g.endFill();
return s;
}
}
}