pouët.net

flaxor by Mr.doob [web]
[nfo]
screenshot added by mrdoob on 2008-07-17 15:01:30
platform :
type :
release date : july 2008
  • 27
  • 7
  • 6
popularity : 59%
 59%
  • 0.53
alltime top: #6290
added on the 2008-07-17 15:01:30 by mrdoob mrdoob

popularity helper

increase the popularity of this prod by spreading this URL:

or via: facebook twitter pinterest tumblr

comments

smth'n psychodelic... not so cool but enough for thumb up)
rulez added on the 2008-07-17 15:11:30 by RRROAR RRROAR
This was mainly a performance test. After testing different ways for drawing pixels, I found out that I was just missing the lock(), unlock() methods. Having them on place it's amazing how fast the flash raster can go (compared to my 20fps at 512x256 tests).
added on the 2008-07-17 15:13:54 by mrdoob mrdoob
Nah.. It's just a scrolling xor pattern with some kind of distortion that looks more like the result of a bug.
But since I have no idea about the difficulty of size optimization in flash I'm not going to thumb it down.
added on the 2008-07-17 15:17:52 by mic mic
I think I made this effect once, before I fixed the bug :D
added on the 2008-07-17 15:26:28 by Preacher Preacher
@mic_:
The code it's on the nfo file. It doesn't really have anything special apart that it's the first time I've seen flash rendering pixels into a bitmap bigger than 256x256.

@preacher:
I don't consider it a bug at all, I test a lot of combinations, and this one was the one I liked the most :)
added on the 2008-07-17 15:31:36 by mrdoob mrdoob
For filling my screen with flash pixels - didnt know that was possible.
rulez added on the 2008-07-17 15:33:51 by auld auld
1k pixel flash :)
rulez added on the 2008-07-17 15:40:44 by Queen_Luna Queen_Luna
@auld2:
You got it! :D
added on the 2008-07-17 15:41:38 by mrdoob mrdoob
weird that it takes so "many" bytes to do a XOR pattern in Flash. o_O
added on the 2008-07-17 15:42:01 by p01 p01
neat! (although I don't understand any math behind it)
rulez added on the 2008-07-17 15:44:09 by Axel Axel
c = (x+t) & (y+t) + t?
added on the 2008-07-17 15:44:28 by Gargaj Gargaj
@p01:
It also has to handle if the user resizes the screen to create a new bitmapData at that resolution and stuff like that. The effect is not optimised, you could take it down to 500bytes, but then people would complain that when they resize the browser the effect stops or doesn't update. You know.

@gargaj:
(x+t) ^ (y+t) * t
added on the 2008-07-17 15:46:22 by mrdoob mrdoob
Adobe whore
added on the 2008-07-17 15:49:23 by Zplex Zplex
I don't know how limited it is what you have there, but a bit of roll to the camera will improve the travelling quite a lot.
sucks added on the 2008-07-17 15:57:55 by mentor mentor
trace: I suspected that most of the byte actually are in the inits and events handling. Dunno if the two unused variables mx & my cost much.
added on the 2008-07-17 16:01:30 by p01 p01
bitmap.rotation ++; LOL!
sucks added on the 2008-07-17 16:14:49 by mrdoob mrdoob
whoop
rulez added on the 2008-07-17 16:15:08 by rc55 rc55
What auld said.
rulez added on the 2008-07-17 16:22:18 by xernobyl xernobyl
I get it down to 692 bytes with this:

package
{
import flash.display.*;
import flash.events.*;

public class Main extends Sprite
{
public var sw:int;
public var timer:int = 0;
public var mx:Number;
public var my:Number;
public var bitmap:Bitmap;
public var sh:int;
public var canvas:BitmapData;

public function Main()
{
stage.scaleMode = "noScale";
stage.align = "T_L";
stage.addEventListener("resize", init);
init(null);
addEventListener("enterFrame", loop);
return;
}// end function

public function init(param1:Event) : void
{
sw = stage.stageWidth;
sh = stage.stageHeight;
canvas = new BitmapData(sw, sh, false);
bitmap = new Bitmap(canvas);
if (contains(bitmap))
{
removeChild(bitmap);
}// end if
addChild(bitmap);
return;
}// end function

public function loop(param1:Event) : void
{
var _loc_3:int;
canvas.lock();
var _loc_2:int;
while (_loc_2 < sw)
{
// label
_loc_3 = 0;
while (_loc_3 < sh)
{
// label
canvas.setPixel(_loc_2, _loc_3, (_loc_2 + timer ^ _loc_3 + timer) * timer);
_loc_3++;
}// end while
_loc_2++;
}// end while
canvas.unlock();
timer++;
return;
}// end function

}
}
added on the 2008-07-17 16:23:46 by Zplex Zplex
Thumb up to you, I guess.
added on the 2008-07-17 16:28:06 by xernobyl xernobyl
Code by Sothink SWF decompiler...lulz
rulez added on the 2008-07-17 16:28:20 by Zplex Zplex
Why would you try to decompile it if you have the actual source code on the .nfo? :P Interesting tho :)
added on the 2008-07-17 16:29:25 by mrdoob mrdoob
Well, i did read the .nfo after i decompiled it. Well, i didnt know the source was in the .nfo :) Anyway, cheers for the source
added on the 2008-07-17 16:32:40 by Zplex Zplex
Hmm, funny how fast your version is in Flash 10 player. I guess most people watch it in Flash 9 player where it is slow atleast here.
added on the 2008-07-17 16:38:12 by Zplex Zplex
flash is not cool, xor is not cool - get it? :)
sucks added on the 2008-07-17 16:53:42 by thec thec
Quote:
Hmm, funny how fast your version is in Flash 10 player. I guess most people watch it in Flash 9 player where it is slow atleast here.
I'm using flash 9 on my 1.6Ghz monocore and it's fast.
added on the 2008-07-17 17:05:00 by xernobyl xernobyl
Killed my ie after after clicking prev page button. Very nice, though.
rulez added on the 2008-07-17 17:16:28 by wrthlss wrthlss
trace: Hmm, did you compile it in Flex 3? When i compile it in Flash CS3 it runs slower then your swf version, then i compiled it in Flex 3 it ran as fast as your swf. Kinda strange.
added on the 2008-07-17 17:26:04 by Zplex Zplex
Oops, seems like Flash CS3 doesn`t read the SWF meta stuff in the code, set the fps to 50 and it ran as fast :) Cool.
added on the 2008-07-17 17:30:36 by Zplex Zplex
what chernobyl said
rulez added on the 2008-07-17 17:57:25 by relias abardon relias abardon
Interresting cause it filled my 22"
rulez added on the 2008-07-17 18:05:12 by Buckethead Buckethead
XOR patterns are cliche, but thumb up for pulling off a fast full-screen pixel effect in a small .swf. I actually like that 'distortion', btw.
rulez added on the 2008-07-17 18:20:12 by Alpha C Alpha C
Nice production and thumb up for sharing code.
rulez added on the 2008-07-17 18:56:57 by benny! benny!
Decided to have some fun with the code, try this:

package
{
import flash.display.*;
import flash.events.*;

public class main extends Sprite
{
public var sw:int;
public var timer:int = 0;
public var bitmap:Bitmap;
public var sh:int;
public var canvas:BitmapData;

public function main()
{
stage.scaleMode = "noScale";
stage.align = "T_L";
stage.addEventListener("resize", init);
init(null);
addEventListener("enterFrame", loop);

}

public function init(param1:Event) : void
{
sw = stage.stageWidth;
sh = stage.stageHeight;
canvas = new BitmapData(sw, sh, false);
bitmap = new Bitmap(canvas);

addChild(bitmap);

}

public function loop(param1:Event) : void
{
var _loc_3:int;
var _loc_2:int;
canvas.lock();


while (_loc_2 < sw >> 1)
{

_loc_3 = 0;
while (_loc_3 < sh >> 1)
{

canvas.setPixel(_loc_2 << 1, _loc_3 << 1, (_loc_3 + timer | _loc_2 + timer) * timer);
canvas.setPixel(_loc_2, _loc_3, (_loc_3 + timer | _loc_2 - timer) * timer);
_loc_3 = _loc_3 + 2;
}// end while
_loc_2 = _loc_2 + 2;
}// end while
canvas.scroll(1,1)
canvas.unlock();
timer++;

}// end function

}
}
added on the 2008-07-17 19:20:13 by Zplex Zplex
hehe, nice! :D
added on the 2008-07-17 19:32:50 by mrdoob mrdoob
I tried Flash 9 and 10, both had same speed. Its interesting to see that when you zoom in 3 times the screen goes black, but only on High Quality. When you turn it to Medium or Low then you can zoom in much more.

Still thumb up for the spacey business ;)
And ofcourse press the rulez button =)
rulez added on the 2008-07-17 20:44:49 by Fleshlight Fleshlight
1k flash? It's the first I see. Cool!
rulez added on the 2008-07-17 21:04:15 by Optimus Optimus
Uhh.. This should be done as a tutorial or news report ("hey guys, flash is reasonably fast now) rather than a prod. There isn't much to look at here :)
added on the 2008-07-17 21:39:50 by bigcheese bigcheese
Code: function loop(e:Event):void { canvas.lock(); var rect:Rectangle = new Rectangle(0, 0, sw, 1); var tempvec:Vector.<uint> = new Vector.<uint>(sw,true); for (var yy:int = 0; yy < sh; yy++) { var yt:uint = yy+timer; for (var xx:uint = 0; xx < sw; xx++) tempvec[xx] = ( (xx+timer) ^ yt ) * timer; rect.y=yy; canvas.setVector(rect,tempvec); } canvas.unlock(); timer++; }


is way faster, needs flash 10 though...
even faster would be some hydra pixel shader, but i am too lazy to write that now :)
rulez added on the 2008-07-18 02:24:52 by shiva shiva
considering the platform's limitations, I like it
rulez added on the 2008-07-18 09:45:12 by Weyland Yutani Weyland Yutani
@shiva:
Coming from you, I'll believe it ;) Actually, thanks for the snippet, I really want to start toying with flash 10.
added on the 2008-07-18 11:44:50 by mrdoob mrdoob
1K: very nice
Sources: nice
Overall: I think, I've seen stuff like this before... ;)

Here's your thumb...
rulez added on the 2008-07-18 15:21:03 by ascodefabrik ascodefabrik
...and here's your shader:
Code:<languageVersion : 1.0;> kernel NewFilter < namespace : "ascodefabrik"; vendor : "AS Codefabrik"; version : 1; description : "simple XOR-Filter"; > { parameter int timer <minValue: 0; maxValue: 255; defaultValue: 0;>; input image4 src; output pixel4 dst; void evaluatePixel() { float coordX = outCoord().x + float( timer ); float coordY = outCoord().y + float( timer ); int x_bit_0 = 0; int x_bit_1 = 0; int x_bit_2 = 0; int x_bit_3 = 0; int x_bit_4 = 0; int x_bit_5 = 0; int x_bit_6 = 0; int x_bit_7 = 0; int y_bit_0 = 0; int y_bit_1 = 0; int y_bit_2 = 0; int y_bit_3 = 0; int y_bit_4 = 0; int y_bit_5 = 0; int y_bit_6 = 0; int y_bit_7 = 0; int out_bit_0 = 0; int out_bit_1 = 0; int out_bit_2 = 0; int out_bit_3 = 0; int out_bit_4 = 0; int out_bit_5 = 0; int out_bit_6 = 0; int out_bit_7 = 0; // x stuff float dummy = 0.0; dummy = coordX / 1.0; if ( mod( dummy, 2.0 ) < 1.0 ) x_bit_0 = 1; dummy = coordX / 2.0; if ( mod( dummy, 2.0 ) < 1.0 ) x_bit_1 = 1; dummy = coordX / 4.0; if ( mod( dummy, 2.0 ) < 1.0 ) x_bit_2 = 1; dummy = coordX / 8.0; if ( mod( dummy, 2.0 ) < 1.0 ) x_bit_3 = 1; dummy = coordX / 16.0; if ( mod( dummy, 2.0 ) < 1.0 ) x_bit_4 = 1; dummy = coordX / 32.0; if ( mod( dummy, 2.0 ) < 1.0 ) x_bit_5 = 1; dummy = coordX / 64.0; if ( mod( dummy, 2.0 ) < 1.0 ) x_bit_6 = 1; dummy = coordX / 128.0; if ( mod( dummy, 2.0 ) < 1.0 ) x_bit_7 = 1; // y stuff dummy = coordY / 1.0; if ( mod( dummy, 2.0 ) < 1.0 ) y_bit_0 = 1; dummy = coordY / 2.0; if ( mod( dummy, 2.0 ) < 1.0 ) y_bit_1 = 1; dummy = coordY / 4.0; if ( mod( dummy, 2.0 ) < 1.0 ) y_bit_2 = 1; dummy = coordY / 8.0; if ( mod( dummy, 2.0 ) < 1.0 ) y_bit_3 = 1; dummy = coordY / 16.0; if ( mod( dummy, 2.0 ) < 1.0 ) y_bit_4 = 1; dummy = coordY / 32.0; if ( mod( dummy, 2.0 ) < 1.0 ) y_bit_5 = 1; dummy = coordY / 64.0; if ( mod( dummy, 2.0 ) < 1.0 ) y_bit_6 = 1; dummy = coordY / 128.0; if ( mod( dummy, 2.0 ) < 1.0 ) y_bit_7 = 1; // output if ( ( x_bit_0 == 1 ) && ( y_bit_0 == 1 ) ) out_bit_0 = 0; if ( ( x_bit_0 == 0 ) && ( y_bit_0 == 0 ) ) out_bit_0 = 0; if ( ( x_bit_0 == 0 ) && ( y_bit_0 == 1 ) ) out_bit_0 = 1; if ( ( x_bit_0 == 1 ) && ( y_bit_0 == 0 ) ) out_bit_0 = 1; if ( ( x_bit_1 == 1 ) && ( y_bit_1 == 1 ) ) out_bit_1 = 0; if ( ( x_bit_1 == 0 ) && ( y_bit_1 == 0 ) ) out_bit_1 = 0; if ( ( x_bit_1 == 0 ) && ( y_bit_1 == 1 ) ) out_bit_1 = 1; if ( ( x_bit_1 == 1 ) && ( y_bit_1 == 0 ) ) out_bit_1 = 1; if ( ( x_bit_2 == 1 ) && ( y_bit_2 == 1 ) ) out_bit_2 = 0; if ( ( x_bit_2 == 0 ) && ( y_bit_2 == 0 ) ) out_bit_2 = 0; if ( ( x_bit_2 == 0 ) && ( y_bit_2 == 1 ) ) out_bit_2 = 1; if ( ( x_bit_2 == 1 ) && ( y_bit_2 == 0 ) ) out_bit_2 = 1; if ( ( x_bit_3 == 1 ) && ( y_bit_3 == 1 ) ) out_bit_3 = 0; if ( ( x_bit_3 == 0 ) && ( y_bit_3 == 0 ) ) out_bit_3 = 0; if ( ( x_bit_3 == 0 ) && ( y_bit_3 == 1 ) ) out_bit_3 = 1; if ( ( x_bit_3 == 1 ) && ( y_bit_3 == 0 ) ) out_bit_3 = 1; if ( ( x_bit_4 == 1 ) && ( y_bit_4 == 1 ) ) out_bit_4 = 0; if ( ( x_bit_4 == 0 ) && ( y_bit_4 == 0 ) ) out_bit_4 = 0; if ( ( x_bit_4 == 0 ) && ( y_bit_4 == 1 ) ) out_bit_4 = 1; if ( ( x_bit_4 == 1 ) && ( y_bit_4 == 0 ) ) out_bit_4 = 1; if ( ( x_bit_5 == 1 ) && ( y_bit_5 == 1 ) ) out_bit_5 = 0; if ( ( x_bit_5 == 0 ) && ( y_bit_5== 0 ) ) out_bit_5 = 0; if ( ( x_bit_5 == 0 ) && ( y_bit_5 == 1 ) ) out_bit_5 = 1; if ( ( x_bit_5 == 1 ) && ( y_bit_5 == 0 ) ) out_bit_5 = 1; if ( ( x_bit_6 == 1 ) && ( y_bit_6 == 1 ) ) out_bit_6 = 0; if ( ( x_bit_6 == 0 ) && ( y_bit_6 == 0 ) ) out_bit_6 = 0; if ( ( x_bit_6 == 0 ) && ( y_bit_6 == 1 ) ) out_bit_6 = 1; if ( ( x_bit_6 == 1 ) && ( y_bit_6 == 0 ) ) out_bit_6 = 1; if ( ( x_bit_7 == 1 ) && ( y_bit_7 == 1 ) ) out_bit_7 = 0; if ( ( x_bit_7 == 0 ) && ( y_bit_7 == 0 ) ) out_bit_7 = 0; if ( ( x_bit_7 == 0 ) && ( y_bit_7 == 1 ) ) out_bit_7 = 1; if ( ( x_bit_7 == 1 ) && ( y_bit_7 == 0 ) ) out_bit_7 = 1; int result = 0; if ( out_bit_0 == 1 ) result += 1; if ( out_bit_1 == 1 ) result += 2; if ( out_bit_2 == 1 ) result += 4; if ( out_bit_3 == 1 ) result += 8; if ( out_bit_4 == 1 ) result += 16; if ( out_bit_5 == 1 ) result += 32; if ( out_bit_6 == 1 ) result += 64; if ( out_bit_7 == 1 ) result += 128; dst = float4( float(result) / 256.0, 0, 0, 1.0 ); } }


Can't test it at the moment cause I'm still developing under FP 9.
Remember you don't have a logical XOR-operator under Hydra, this makes things harder to code.

Maybe the shader isn't coded very well since this was my first experiment with Pixel Bender... ;-)
Optimization hints are welcome.
Ah, sorry...
wrote: logical
meant: binary
what do u need to compile AS3? >_>;;
rulez added on the 2008-07-18 17:05:22 by panic panic
rulez added on the 2008-07-18 17:54:14 by texel texel
@xiaomega:
flashdevelop (windows ide) and flex sdk (compiler)
added on the 2008-07-18 18:12:30 by mrdoob mrdoob
@ascodefabrik:
Did you? I never saw a fullscreen BitmapData being updated at that speed, sorry if there were lots of them out there already :S
added on the 2008-07-18 18:14:55 by mrdoob mrdoob
Don't get me wrong. "seen stuff like this" was based on the XOR-Bitmap, not on performance. The rendering speed is very nice... ;)
i don't think 30 lines flash experiments belong to pouet. (nb. ditto for 30 lines asm experiments)
sucks added on the 2008-07-18 19:50:32 by blala blala
trace: if you never saw BitmapData being updated at that speed, you didn't saw much ;) as i remember, andre made perspective correct texturemapper with 3ds object loader, running damn fast actually (and it was fully pixel based, no distortions), in times of flash player 8.5 (unfortunately final fp9 is slower in that). my quick hack to my own texturemapper to make it use setpixel obviously slows it down, but it's still no slower than your stuff, so...
piggy.
added on the 2008-07-18 20:04:00 by unic0rn unic0rn
ascodefabric: you're performing 8 comparisons per bit to do a simple XOR. You can reduce it to 1 with:

if(bit1 == bit2) result = 0; else result = 1;

Anyway, if you don't have a XOR operator you can always substitute it with an equivalent version using ANDs, NOTs and ORs. You wouldnt need to operate bit by bit :)

Never heard of hydra or flash pixel shaders. Googling.
added on the 2008-07-18 20:09:10 by ithaqua ithaqua
ithaqua: You're so right...Of course,
Code:if ( x_bit_0 != y_bit_0 ) out_bit_0 = 1;
is much shorter and much more performant... ;)
Thx for the hint.

Anyway: the problem of Hydra/Pixel Bender is that you don't have even ANY binary operator, no AND, no OR etc. Only logical operators such as &&, || and ^^ are available. Due to this fact, I splittet the floats into bits and performed some shifting operation by / 2.0, / 4.0, / 8.0 etc. etc.
trace: thx ^^.
added on the 2008-07-18 21:15:20 by panic panic
I like the idea of small flash intros. It's cool to launch the intro with just one click!
rulez added on the 2008-07-18 21:39:20 by dairos dairos
uuh,very nice code indeed !

i just ask myself when i´ll be able to fully understand how hard it is in flash,hehe....just too busy to look into it...
rulez added on the 2008-07-19 06:15:17 by ɧ4ɾɗվ. ɧ4ɾɗվ.
rulez added on the 2008-07-19 13:15:17 by iks iks
Mr Doob!
rulez added on the 2008-07-19 13:27:59 by Sander Sander
rulez added on the 2008-07-19 13:55:14 by stage7 stage7
Fast! In flash...
rulez added on the 2008-07-19 13:57:40 by Neko Neko
Cool 1K flash!
rulez added on the 2008-07-21 15:09:49 by untel untel
32B.
rulez added on the 2008-09-03 20:29:04 by Pirx Pirx
XOR pattern.
sucks added on the 2008-09-03 20:32:16 by stijn stijn
1k + screenshot vote
sucks added on the 2015-05-16 21:25:01 by sensenstahl sensenstahl

submit changes

if this prod is a fake, some info is false or the download link is broken,

do not post about it in the comments, it will get lost.

instead, click here !

[previous edits]

add a comment