Ejemplo n.º 1
0
        public void Render(ICanvas canvas, int width, int height, IPixelMapper pixelMapper)
        {
            (int topLeftColumn, int topLeftRow)         = pixelMapper.ViewPortPixelsToCoords(0, 0);
            (int bottomRightColumn, int bottomRightRow) = pixelMapper.ViewPortPixelsToCoords(pixelMapper.ViewPortWidth, pixelMapper.ViewPortHeight);

            bottomRightColumn += 1;
            bottomRightRow    += 1;

            var source = new Rectangle(topLeftColumn, topLeftRow, bottomRightColumn, bottomRightRow);

            (int destinationTopLeftX, int destinationTopLeftY, _)         = pixelMapper.CoordsToViewPortPixels(topLeftColumn, topLeftRow);
            (int destinationBottomRightX, int destinationBottomRightY, _) = pixelMapper.CoordsToViewPortPixels(bottomRightColumn, bottomRightRow);

            var destination = new Rectangle(destinationTopLeftX, destinationTopLeftY, destinationBottomRightX, destinationBottomRightY);

            canvas.DrawImage(_terrainMapRenderer.GetTerrainImage(), source, destination);
        }
Ejemplo n.º 2
0
        public void Render(ICanvas canvas, int width, int height)
        {
            if (!this.Enabled)
            {
                return;
            }

            canvas.Translate(width - _pixelMapper.Columns - 50, height - _pixelMapper.Rows - 50);

            canvas.DrawImage(_terrainMapRenderer.GetTerrainImage(), 0, 0);

            foreach (Track track in _trackLayout)
            {
                canvas.DrawRect(track.Column, track.Row, 1, 1, _paint);
            }

            (int left, int top)     = _pixelMapper.ViewPortPixelsToCoords(0, 0);
            (int right, int bottom) = _pixelMapper.ViewPortPixelsToCoords(_pixelMapper.ViewPortWidth, _pixelMapper.ViewPortHeight);

            canvas.DrawRect(left, top, right - left, bottom - top, _viewPortPaint);

            canvas.DrawRect(0, 0, _pixelMapper.Columns, _pixelMapper.Rows, _border);
        }