from a stable rectangle I received W -shaped periodic pattern
xx ox
a##x a#x
x##ao oa##x
x#a x##a
xo xx
where # is blue, x is 'half'blue, a is 'one third' blue and o - 'quarter' blue
Embed
/**
* Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/smsu
*/
package {
import flash.text.TextField;
import flash.geom.ColorTransform;
import flash.events.MouseEvent;
import flash.geom.Matrix;
import flash.events.Event;
import flash.display.BitmapData;
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
deb = new TextField();
deb.width = 320; deb.height=240; deb.mouseEnabled=false;
deb.textColor=0xFF0000;
addChild(deb);
var f:int;
f = 1 | 2 | 4 | 8;
deb.text = "" + (f & 16);
pic = new BitmapData(64,64, false, 0);
map = new BitmapData(pic.width, pic.height, false, 0);
canvas = new BitmapData(pic.width, pic.height, false, 0);
stage.addEventListener(MouseEvent.MOUSE_DOWN, onMdown);
stage.addEventListener(MouseEvent.MOUSE_UP, onMup);
stage.addEventListener(Event.ENTER_FRAME, onEnter);
}//ctor
public var deb:TextField;
public function onMdown(e:MouseEvent):void { mdown = 1; }
public function onMup(e:MouseEvent):void { mdown = 0; }
public var mdown:int = 0;
public var pic:BitmapData;
public var map:BitmapData;
public var canvas:BitmapData;
public var mat:Matrix = new Matrix();
public var gt:int = 0;
public var ct:ColorTransform = new ColorTransform(1,1,1,0.5);
public function onEnter(e:Event):void
{
var cw:Number; var ch:Number;
var mx:Number; var my:Number;
var tx:int; var ty:int;
cw = 16; ch = 16;
mx = stage.mouseX; my = stage.mouseY;
tx = Math.floor(mx/cw); ty = Math.floor(my/ch);
mat.a = cw; mat.d = ch;
if (mdown > 0)
{
pic.setPixel(tx,ty, 0xFF);
pic.setPixel(tx+1,ty, 0xFF);
pic.setPixel(tx,ty+1, 0xFF);
}
// if (gt % 4 ==0 && mdown <= 0)
{
var c:int; var t:int;
var c2:int;
var i:int; var k:int; var v:int; var f:int;
var mw:int; var mh:int;
t = 32;
mw = pic.width; mh = pic.height;
map.fillRect(map.rect, 0);
for (i = 0; i < mh; i++)
for (k = 0; k < mw; k++)
{
c = pic.getPixel(k, i);
c -= 16; if (c < 16) { c =0; }
pic.setPixel(k,i, c);
v = 0; f = 0;
if ( pic.getPixel(k+1, i)>t ) { v += 1; f |= 1; }
if ( pic.getPixel(k-1, i)>t ) { v += 1; f |= 2; }
if ( pic.getPixel(k, i+1)>t ) { v += 1; f |= 4; }
if ( pic.getPixel(k, i-1)>t ) { v += 1; f |= 8; }
if ( pic.getPixel(k+1, i+1)>t ) { v += 1; f |= 16; }
if ( pic.getPixel(k-1, i+1)>t ) { v += 1; f |= 32; }
if ( pic.getPixel(k+1, i-1)>t ) { v += 1; f |= 64; }
if ( pic.getPixel(k-1, i-1)>t ) { v += 1; f |= 128; }
if (v == 4 || v > 6){ pic.setPixel(k,i, 0xFF); }
/*
if (c <255)
if ((f & 8) > 0)
{
c2 = pic.getPixel(k,i-1); c2 -= 32; if (c2 <= 0) {c2 = 0; }
pic.setPixel(k,i-1,c2);
c+=32; if (c >= 255) { c = 255; }
pic.setPixel(k,i, c);
}
*/
//if (c == 0 && (f&15)==15 || (f&240)==240 ) { pic.setPixel(k,i,0xFF); }
if (c <= 0 ) { continue; }
//if (v >= 5) { pic.setPixel(k,i, 0); }
//if (v < 2) { pic.setPixel(k,i, 0); }
map.setPixel(k,i, 0x444444 + (0x11111*v));
}//nextk
}
canvas.draw(pic);
canvas.draw(map, null, ct);
graphics.clear();
graphics.beginBitmapFill(canvas, mat,false, false);
graphics.drawRect(0,0,465,465);
graphics.endFill();
graphics.lineStyle(2, 0x00FF00,0.5);
graphics.drawRect(tx*cw,ty*ch,cw,ch);
gt += 1;
}//onenter
}//classend
}