public MainPage()
        {
            InitializeComponent();

            this.Width  = 600;
            this.Height = 600;

            var i = new Image();

            //var s = new WriteableBitmap(600, 600, 96, 96, PixelFormats.Pbgra32, null);
            var s = new WriteableBitmap(600, 600, PixelFormats.Pbgra32);

            Plasma.generatePlasma(600, 600);
            var shift = 0;

            Action Refresh =
                delegate
            {
                var buffer = Plasma.shiftPlasma(shift);

                s.Lock();


                for (int j = 0; j < buffer.Length; j++)
                {
                    //Marshal.WriteInt32(s.BackBuffer, j * 4, unchecked((int)(buffer[j] | 0xff000000)));
                    s[j] = unchecked ((int)(buffer[j] | 0xff000000));
                }

                //s.AddDirtyRect(new Int32Rect(0, 0, 600, 600));
                s.Invalidate();
                s.Unlock();
            };

            var t = new DispatcherTimer();

            t.Tick +=
                delegate
            {
                shift++;
                Refresh();
            };

            t.Interval = TimeSpan.FromMilliseconds(50);
            t.Start();

            Refresh();

            i.Source = s;


            this.Content = i;
        }
        public FlashPlasmaDocument()
        {
            Plasma.generatePlasma(DefaultWidth, DefaultHeight);

            var shift = 0;

            var canvas = new IHTMLCanvas();

            canvas.width  = DefaultWidth;
            canvas.height = DefaultHeight;

            var context = (CanvasRenderingContext2D)canvas.getContext("2d");

            var xx = context.getImageData(0, 0, DefaultWidth, DefaultHeight);
            var x  = (ImageData)(object)xx;

            Action AtTick = null;

            AtTick = delegate
            {
                var buffer = Plasma.shiftPlasma(shift);

                //var x = context.createImageData(DefaultWidth, DefaultHeight);


                var k = 0;
                for (int i = 0; i < DefaultWidth; i++)
                {
                    for (int j = 0; j < DefaultHeight; j++)
                    {
                        var i4 = i * 4;
                        var j4 = j * 4;


                        x.data[i4 + j4 * DefaultWidth + 2] = (byte)((buffer[k] >> (0 * 8)) & 0xff);
                        x.data[i4 + j4 * DefaultWidth + 1] = (byte)((buffer[k] >> (1 * 8)) & 0xff);
                        x.data[i4 + j4 * DefaultWidth + 0] = (byte)((buffer[k] >> (2 * 8)) & 0xff);
                        x.data[i4 + j4 * DefaultWidth + 3] = 0xff;

                        k++;
                    }
                }

                context.putImageData(xx, 0, 0, 0, 0, DefaultWidth, DefaultHeight);
                shift++;
                Native.Window.requestAnimationFrame += AtTick;
            };

            Native.Window.requestAnimationFrame += AtTick;


            canvas.AttachToDocument();
        }
        private void enterFrame2()
        {
            var shift = getTimer() / 10;

            Buffer.@lock();

            if (RenderMode % 3 == 0)
            {
#if !CODEGEN
                PlasmaProxy.Memory.position = PlasmaProxy.shiftPlasma(shift);

                // -- Alchemy palette shifting
                //alchemyMemory.position = plasmaLib.ToFunc<int, uint>("shiftPlasma")(shift);
                // -- write the ByteArray straight to the bitmap data
                Buffer.setPixels(Buffer.rect, PlasmaProxy.Memory);
#endif
            }
            else
            {
                Plasma.shiftPlasma(shift);

                if (RenderMode % 3 == 1)
                {
                    var m = new ByteArray();
                    foreach (var i in Plasma.newPlasma)
                    {
                        m.writeUnsignedInt(i);
                    }
                    m.position = 0;
                    Buffer.setPixels(Buffer.rect, m);
                }
                else
                {
                    // -- AS3.0 palette shifting
                    for (var x = 0; x < DefaultWidth; x++)
                    {
                        for (var y = 0; y < DefaultHeight; y++)
                        {
                            //bmd.setPixel(x, y, 0xff00ff00);
                            //uint c = palette[(plasma[x][y] + shift) % 256];


                            Buffer.setPixel(x, y, Plasma.newPlasma[x + y * DefaultWidth] | 0xff000000u);
                        }
                    }
                }
            }

            Buffer.unlock();
        }
        public Page1()
        {
            // Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

            InitializeComponent();

            var i = new Image();

            var s = new WriteableBitmap(600, 600, 96, 96, PixelFormats.Pbgra32, null);

            Plasma.generatePlasma(600, 600);
            var shift = 0;

            Action Refresh =
                delegate
            {
                var buffer = Plasma.shiftPlasma(shift);

                s.Lock();


                for (int j = 0; j < buffer.Length; j++)
                {
                    Marshal.WriteInt32(s.BackBuffer, j * 4, unchecked ((int)(buffer[j] | 0xff000000)));
                }

                s.AddDirtyRect(new Int32Rect(0, 0, 600, 600));
                s.Unlock();
            };

            var t = new DispatcherTimer();

            t.Tick +=
                delegate
            {
                shift++;
                Refresh();
            };

            t.Interval = TimeSpan.FromMilliseconds(10);
            t.Start();

            Refresh();

            i.Source = s;

            this.Content = i;
        }
        public void run()
        {
            while (!that.__stop)
            {
                that.shift++;
                var a = Plasma.shiftPlasma(that.shift);

                for (int i = 0; i < a.Length; i++)
                {
                    a[i] = 0xFF000000u | a[i];
                }

                that.buffer.newPixels();
                that.paint(that.getGraphics());

                Thread.yield();
            }
        }
        public override void init()
        {
            base.resize(DefaultWidth, DefaultHeight);

            Plasma.generatePlasma(DefaultWidth, DefaultHeight);
            var pix = Plasma.shiftPlasma(0);

            this.buffer = new MemoryImageSource(DefaultWidth, DefaultHeight, pix, 0, DefaultWidth);

            buffer.setAnimated(true);
            buffer.setFullBufferUpdates(true);


            new Thread(new SinePlasmaTimer {
                that = this
            }).start();


            base.resize(DefaultWidth, DefaultHeight);


            this.img = this.createImage(buffer);
        }
Beispiel #7
0
        public static void Main(string[] args)
        {
            var f = new DoubleBufferedForm
            {
                FormBorderStyle = FormBorderStyle.FixedDialog,
                ClientSize      = new Size(
                    global::FlashPlasma.ActionScript.FlashPlasma.DefaultWidth,
                    global::FlashPlasma.ActionScript.FlashPlasma.DefaultHeight
                    )
            };

            Plasma.generatePlasma(
                global::FlashPlasma.ActionScript.FlashPlasma.DefaultWidth,
                global::FlashPlasma.ActionScript.FlashPlasma.DefaultHeight
                );

            var shift = 0;

            var bitmap = new Bitmap(
                global::FlashPlasma.ActionScript.FlashPlasma.DefaultWidth,
                global::FlashPlasma.ActionScript.FlashPlasma.DefaultHeight
                );


            f.Paint +=
                (object sender, PaintEventArgs e) =>
            {
                e.Graphics.DrawImage(bitmap, new Rectangle(0, 0, bitmap.Width, bitmap.Height));
            };

            var t = new Timer();

            t.Interval = 1;
            t.Tick    +=
                delegate
            {
                shift++;
                Plasma.shiftPlasma(shift);

                var buffer = Plasma.newPlasma;

                var data = bitmap.LockBits(
                    new Rectangle(0, 0, bitmap.Width, bitmap.Height),
                    System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb
                    );


                for (int i = 0; i < buffer.Length; i++)
                {
                    Marshal.WriteInt32(data.Scan0, i * 4, unchecked ((int)(buffer[i] | 0xff000000)));
                }



                bitmap.UnlockBits(data);

                f.Invalidate();
            };

            t.Start();

            Application.Run(f);
        }