flash on 2011-7-15
package
{
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Matrix;
import flash.geom.Rectangle;
public class Main extends Sprite
{
private var matrix:Matrix = new Matrix();
private var pattern:BitmapData;
private const SIZE:int = 20;
private const COLORS:Array = [0xFBFFE8, 0xF6F1C6];
public function Main()
{
pattern = new BitmapData(SIZE * 2, SIZE * 2, false, 0xFE9E00);
pattern.fillRect(new Rectangle(SIZE, 0, SIZE, SIZE), 0xFDC200);
pattern.fillRect(new Rectangle(0, SIZE, SIZE, SIZE), 0xFDC200);
for (var i:int = 0; i < SIZE; i++)
{
pattern.setPixel(0, i, 0xFEB400);
pattern.setPixel(i, 0, 0xFEB400);
pattern.setPixel(SIZE - 1, SIZE - i - 1, 0xFC9900);
pattern.setPixel(SIZE - i - 1, SIZE - 1, 0xFC9900);
pattern.setPixel(SIZE, i, 0xFFCB02);
pattern.setPixel(SIZE + i, 0, 0xFFCB02);
pattern.setPixel(SIZE * 2 - 1, SIZE - i - 1, 0xFCA500);
pattern.setPixel(SIZE * 2 - i - 1, SIZE - 1, 0xFCA500);
pattern.setPixel(0, i + SIZE, 0xFFCB02);
pattern.setPixel(i, SIZE, 0xFFCB02);
pattern.setPixel(SIZE - 1, SIZE * 2 - i - 1, 0xFCA500);
pattern.setPixel(SIZE - i - 1, SIZE * 2 - 1, 0xFCA500);
pattern.setPixel(SIZE, i + SIZE, 0xFEB400);
pattern.setPixel(SIZE + i, SIZE, 0xFEB400);
pattern.setPixel(SIZE * 2 - 1, SIZE * 2 - i - 1, 0xFC9900);
pattern.setPixel(SIZE * 2 - i - 1, SIZE * 2 - 1, 0xFC9900);
}
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(event:Event):void
{
graphics.clear();
graphics.beginBitmapFill(pattern, matrix);
graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
graphics.endFill();
matrix.translate(-1, -1);
}
}
}