Exemple #1
0
        public void FillScreen()
        {
            _canvas.Clear();
            var rows = _canvas.Height;
            var cols = _canvas.Width;

            for (var y = 0; y < rows; y++)
            {
                for (var x = 0; x < cols; x++)
                {
                    var color = new Color(0, 0, 0);

                    if (x == 0 && y == 0)
                    {
                        color = new Color(255, 0, 0);
                    }
                    else if (x == 0 && y == rows - 1)
                    {
                        color = new Color(0, 255, 0);
                    }
                    else if (x == cols - 1 && y == 0)
                    {
                        color = new Color(0, 0, 255);
                    }
                    else if (x == cols - 1 && y == rows - 1)
                    {
                        color = new Color(255, 255, 255);
                    }

                    _canvas.SetPixel(x, y, color);
                }
            }
            _matrix.SwapOnVsync(_canvas);
        }
Exemple #2
0
        public void Render(TetrisGameState state)
        {
            _canvas.Clear();

            DrawBorder(state);
            DrawBlocks(state);
            DrawScore(state);

            _matrix.SwapOnVsync(_canvas);
        }
Exemple #3
0
        private void Render()
        {
            while (true)
            {
                _signal.WaitOne(60);

                if (!NoRender)
                {
                    _queue.TryDequeue(out Canvas item);
                    if (item != null)
                    {
                        convertApplicationCanvasToCanvas(item);
                    }
                    matrix.SwapOnVsync(canvas);
                    canvas.Clear();
                }
            }
        }