private void generatePlasma()
        {
#if !CODEGEN
            PlasmaProxy.Memory.position = PlasmaProxy.generatePlasma(DefaultWidth, DefaultHeight);
#endif
            Plasma.generatePlasma(DefaultWidth, DefaultHeight);
        }
        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();
        }
        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 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);
        }
示例#6
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);
        }