forked from: 俺はそう考えてる
壷ったのでなんとなく。
「亀田の親父のブログが面白すぎる件」
http://blog.livedoor.jp/news23vip/archives/1964823.html
俺はそう考えてる
/**
* Copyright uwi ( http://wonderfl.net/user/uwi )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/frvQ
*/
// forked from y_tti's 俺はそう考えてる
/*
壷ったのでなんとなく。
「亀田の親父のブログが面白すぎる件」
http://blog.livedoor.jp/news23vip/archives/1964823.html
俺はそう考えてる
*/
package
{
import __AS3__.vec.Vector;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.GradientType;
import flash.display.Shape;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.filters.*;
import flash.geom.ColorTransform;
import flash.geom.Matrix;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.display.Graphics;
import net.hires.debug.Stats;
import frocessing.color.*;
import org.libspark.betweenas3.BetweenAS3;
import org.libspark.betweenas3.tweens.ITween;
import org.libspark.betweenas3.easing.*;
[SWF(width="465", height="465", backgroundColor="0x000000", frameRate="60")]
public class ytti_OrehaSouKangaeteru extends Sprite
{
private var _base : BitmapData;
private var _surface : BitmapData;
private var _panel : Sprite;
private var _text : String = "俺はそう\n考えてる";
public function ytti_OrehaSouKangaeteru()
{
addEventListener(Event.ADDED_TO_STAGE , _init );
}
private function _init(e:Event):void {
removeEventListener(Event.ADDED_TO_STAGE , _init );
//TextField作成
var oretf:Sprite = new OreTextField(_text);
_base = new BitmapData(465, 465, false, 0x000000);
var mat:Matrix = new Matrix(1,0,0,1,(465-oretf.width)>>1,(465-oretf.height)>>1);
_base.draw(oretf, mat);
var drawshape : Shape = new Shape();
var g : Graphics = drawshape.graphics;
var margin : int = 3;
for(var iy:int = 0;iy < _base.height;iy+=margin){
for(var ix:int = 0;ix < _base.width;ix+=margin){
if(_base.getPixel(ix,iy)) {
//ライン書く
g.lineStyle(3, 0xbf0000 + (uint(0x3f*(Math.random()+1)) << 8));// + (uint(0x7f*Math.random())));
g.moveTo(ix, iy);
g.lineTo(465 / 2, 500);
}
}
}
_base.draw(drawshape);
_base.draw(oretf, mat);
_surface = new BitmapData(465, 465, false, 0x000000);
var bmp : Bitmap = new Bitmap(_surface);
_panel = new Sprite();
_panel.addChild(bmp);
bmp.x = -465 / 2;
bmp.y = -500;
addChild(_panel);
_panel.x = 465 / 2;
_panel.y = 500;
addEventListener(Event.ENTER_FRAME , _update );
addEventListener(MouseEvent.CLICK , onClick );
addChild(new Stats());
}
private var _r : Number = 0.0;
private var _on : int = -1;
private var _onstep : int = 10;
private function _update(e:Event):void {
_surface.lock();
_surface.fillRect(_surface.rect, 0x000000);
var i : int;
var gs : Array = new Array(256);
var bs : Array = new Array(256);
if(_on == -1){
for(i = 0;i < 255;i++){
gs[i] = new ColorHSV(_r * 1.5, 0.3, i / 100).valueOf();
}
gs[255] = 0;
for(i = 0;i < 256;i++)bs[i] = 0;
for(i = 0;i < _text.length;i++){
bs[255-i] = new ColorHSV(_r + 360 / _text.length * i, 0.8, 0.8).valueOf();
}
_surface.paletteMap(_base, _base.rect, new Point(), null, gs, bs);
_r+= 10;
}else{
for(i = 1;i < 255;i++){
gs[i] = 0xcf << 16 | i << 8 | i;
}
gs[0] = 0;
gs[255] = 0;
var rs : Array = new Array(256);
for(i = 0;i < _on / _onstep;i++){
bs[255-i] = new ColorHSV(_r + 360 / _text.length * i, 0.8, 0.8).valueOf();
}
if(_on >= 1)_on++;
if(_on == _text.length * _onstep)_on = -1;
_surface.paletteMap(_base, _base.rect, new Point(), rs, gs, bs);
}
_surface.unlock();
}
private function onClick(e : MouseEvent) : void
{
_on = 0;
var it : ITween = BetweenAS3.serial(
BetweenAS3.to(_panel, {scaleX : 0.2, scaleY : 0.2}, 0.1),
BetweenAS3.to(_panel, {scaleX : 1, scaleY : 1}, 0.1)
);
it.onComplete = onComplete;
it.play();
}
private function onComplete() : void
{
_on = 1;
}
}
}
import flash.text.TextField;
import flash.display.Sprite;
import flash.text.TextFormat;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormatAlign;
class OreTextField extends Sprite
{
public function OreTextField(text : String){
var tf:TextField = new TextField();
var fmt:TextFormat = new TextFormat("_ゴシック" , 100 , 0xFFFFFF );
fmt.align = TextFormatAlign.CENTER;
tf.defaultTextFormat = fmt;
tf.autoSize = TextFieldAutoSize.LEFT;
tf.multiline = true;
var html : String = "";
for(var i : int = 0;i < text.length;i++){
html += "<font color='#" + (0xffffff-i).toString(16) + "'>" + text.charAt(i) + "</font>";
}
addChild(tf);
tf.htmlText = html;
// tf.text = "俺はそう\n考えてる";
}
}