/**
* Copyright demouth ( http://wonderfl.net/user/demouth )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/6EiK
*/
//イラレで描いたやつをぷよぷよする
package
{
import flash.display.Graphics;
import flash.display.Sprite;
import flash.events.Event;
import flash.utils.getTimer;
import frocessing.shape.AbstractFShape;
import frocessing.shape.FShapeContainer;
import frocessing.shape.FShapeSVG;
import frocessing.shape.IFShape;
public class FlashTest extends Sprite
{
private var svg:FShapeSVG;
public function FlashTest()
{
this.init();
}
private function init():void
{
this.svg = new FShapeSVG( this.getSVG() );
this.addEventListener(Event.ENTER_FRAME , enterFrameHandler);
}
private function enterFrameHandler(e:Event):void
{
this.graphics.clear();
var i:int;
var l:uint = this.svg.getChildCount();
for (i = 0; i < l; i++) this.puyopuyoFShape( this.svg.getChildAt(i) );
for (i = 0; i < l; i++) this.drawFShape( this.svg.getChildAt(i) , this.graphics );
}
private function drawFShape(shape:IFShape,g:Graphics):void
{
if ( shape is FShapeContainer )
{
var shapeContainer:FShapeContainer = shape as FShapeContainer;
var l:uint = shapeContainer.getChildCount();
for (var i:int = 0; i < l; i++)
{
arguments.callee( shapeContainer.getChildAt(i) , g );
}
}
else if( shape is AbstractFShape )
{
var abstractFShape:AbstractFShape = shape as AbstractFShape;
abstractFShape.drawGraphics(g);
}
}
private function puyopuyoFShape(shape:IFShape):void
{
var l:uint;
var i:int;
if ( shape is FShapeContainer )
{
var shapeContainer:FShapeContainer = shape as FShapeContainer;
l = shapeContainer.getChildCount();
for (i = 0; i < l; i++)
{
arguments.callee( shapeContainer.getChildAt(i) );
}
}
else if( shape is AbstractFShape )
{
var abstractFShape:AbstractFShape = shape as AbstractFShape;
l = abstractFShape.vertices.length;
for (i = 0; i < l; i++)
{
if( i % 2 ) abstractFShape.vertices[i] += Math.sin(getTimer() * 0.005 + i * 0.5)*0.2
else abstractFShape.vertices[i] += Math.cos(getTimer() * 0.005 + i*0.5)*0.2;
}
}
}
private function getSVG():XML
{
var xml:XML = <svg version="1.0" id="レイヤー_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="800px" height="600px" viewBox="0 0 800 600" enable-background="new 0 0 800 600" xml:space="preserve">
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="386.7817" y1="409.0488" x2="97.8081" y2="131.3944">
<stop offset="0" style="stop-color:#005AAA"/>
<stop offset="1" style="stop-color:#6FD2DD"/>
</linearGradient>
<path fill="url(#SVGID_1_)" d="M242.696,56.141c0,0-0.638-0.097-1.666,0.386c-1.027,0.482-2.443,1.542-4,3.857s-3.254,5.883-4.843,11.381s-3.07,12.924-4.193,22.955c-1.124,10.031-2.816,18.915-5.022,26.683c-2.206,7.768-4.927,14.42-8.109,19.988s-6.825,10.051-10.875,13.48s-8.508,5.805-13.321,7.158s-14.469,4.634-26.247,10.004c-11.778,5.371-25.678,12.832-38.975,22.546S99.45,216.26,90.078,230.643c-9.372,14.383-15.419,31.181-15.419,50.558c0,19.626,3.835,36.086,11.255,49.737c7.419,13.65,18.423,24.491,32.761,32.88s32.008,14.323,52.762,18.161s44.59,5.579,71.259,5.579s50.334-1.542,70.833-5.131c20.498-3.59,37.827-9.227,51.823-17.416s24.658-18.932,31.821-32.731C404.336,318.479,408,301.621,408,281.2c0-18.979-4.666-35.188-12.269-49.008c-7.603-13.819-18.142-25.25-29.887-34.672s-24.698-16.837-37.127-22.625c-12.429-5.789-24.336-9.95-33.99-12.867c-4.087-1.235-7.942-2.61-11.558-4.858c-3.616-2.248-6.992-5.368-10.123-10.09c-3.13-4.723-6.015-11.048-8.646-19.707c-2.631-8.659-5.009-19.652-7.127-33.71c-0.537-3.565-1.232-7.693-2.094-11.879c-0.862-4.187-1.891-8.431-3.094-12.229c-1.203-3.799-2.582-7.152-4.144-9.556C246.379,57.595,244.633,56.141,242.696,56.141z"/>
<path fill="#FFFFFF" d="M233.883,284.918c0,14.297-11.59,24.591-25.887,24.591s-25.887-10.294-25.887-24.591c0-14.297,11.59-25.887,25.887-25.887S233.883,270.622,233.883,284.918z"/>
<path d="M218.989,284.918c0,6.072-4.922,9.697-10.993,9.697c-6.072,0-10.993-3.625-10.993-9.697c0-6.071,4.921-10.993,10.993-10.993 C214.067,273.925,218.989,278.847,218.989,284.918z"/>
<path fill="#FFFFFF" d="M251.506,284.918c0,14.297,11.59,24.591,25.887,24.591s25.887-10.294,25.887-24.591c0-14.297-11.59-25.887-25.887-25.887S251.506,270.622,251.506,284.918z"/>
<path d="M266.4,284.918c0,6.072,4.922,9.697,10.993,9.697c6.072,0,10.993-3.625,10.993-9.697c0-6.071-4.921-10.993-10.993-10.993C271.322,273.925,266.4,278.847,266.4,284.918z"/>
<g>
<g>
<path d="M313.57,321.789c-4.473-1.438-9.267,1.023-10.708,5.498c-0.796,2.418-2.125,4.469-4.566,6.584c-2.432,2.094-6.044,4.145-10.99,5.865c-9.879,3.475-44.611,5.461-44.611,5.461s-34.732-1.986-44.611-5.461c-4.945-1.721-8.558-3.771-10.99-5.865c-2.441-2.115-3.771-4.166-4.566-6.584c-1.441-4.475-6.235-6.936-10.708-5.498c-4.476,1.439-6.937,6.234-5.497,10.707c1.764,5.547,5.179,10.457,9.689,14.297c6.797,5.787,15.781,9.463,26.804,11.895c11.043,2.408,24.264,3.527,39.879,3.531c15.615-0.004,28.835-1.123,39.878-3.531c11.022-2.432,20.006-6.107,26.803-11.895c4.511-3.84,7.926-8.75,9.69-14.297C320.507,328.023,318.045,323.229,313.57,321.789z"/>
</g>
</g>
</svg>;
return xml;
}
}
}