Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void ComputeFrame() {
- i = 0;
- x = 0;
- //lock the canvas, because i haven't delved into actual bitmap pointer drawing to the screen itself
- bmpData = canvas.LockBits(bmpRect, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
- currPos = (uint*)bmpData.Scan0;
- fixed (byte* f = field) { //field contains the entire grid plus swap
- t = f + w3; //starting point of the current generation
- a = t; //starting point of the next generation
- //determine which is which
- if (altFrame)
- t += outerL;
- else
- a += outerL;
- while (i++ < l) {
- //sum living neighbors
- n = (uint)(*(t - 1) + *(t + 1) + *(t - w2) + *(t + w2) + *(t - w1) + *(t + w1) + *(t - wp1) + *(t + wp1));
- if (*t == 1) { //current cell is alive
- *a = (byte)((n >> 1) == 1 ? 1 : 0);
- //*a = (byte)((n >> 1) & 0x01);
- *currPos = 0xffffffff; // col;
- }
- else { //he's dead, jim
- *a = (byte)(n == 3 ? 1 : 0);
- //if (fadeColors) { //fancy color cycling and fading, looks cool, but is slow
- // if ((*currPos & 0x00ff0000) > (uint)(colLimit << 16)) *currPos -= (uint)(colDecVal << 16);
- // if ((*currPos & 0x0000ff00) > (uint)(colLimit << 8)) *currPos -= (uint)(colDecVal << 8);
- // if ((*currPos & 0x000000ff) > (uint)(colLimit)) *currPos -= (uint)(colDecVal);
- //}
- //else
- *currPos = 0xff000000;
- }
- currPos++;
- if (++x == w) {
- x = 0;
- a += 3;
- t += 3;
- }
- else {
- a++;
- t++;
- }
- }
- }
- canvas.UnlockBits(bmpData);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement