Пример #1
0
        public void PostProcess(MapRegionLayer layer, Graphics graphics, BlockColumnMeta block)
        {
            var rect = layer.GetBlockRectangle(block.Position);

            var alpha = (int)MathUtils.Clamp(MaxOverlayAlpha * ((MaxLightLevel - block.LightLevel) / MaxLightLevel), 0f, MaxOverlayAlpha);

            using (var brush = new SolidBrush(Color.FromArgb(alpha, Color.Black)))
            {
                graphics.FillRectangle(brush, rect);
            }
        }
Пример #2
0
        public void PostProcess(MapRegionLayer layer, Graphics graphics, BlockColumnMeta block)
        {
            var rect = layer.GetBlockRectangle(block.Position);

            var chunkPos    = block.Position.GetChunkPosition();
            var chunkBounds = chunkPos.GetBlockBounds();

            var chunkRect = layer.GetChunkRectangle(chunkPos);

            var rX = block.Position.X % 16;
            var rZ = block.Position.Z % 16;


            if (rX == 15 && rZ == 15)
            {
                graphics.DrawRectangle(_chunkPen, chunkRect);
            }

            graphics.DrawRectangle(_gridPen, rect);

            if (rX == 15 && rZ == 15)
            {
                DrawText(graphics, chunkPos.ToString(), chunkRect, _chunkCoordFont);

                var min = chunkBounds.Min;
                var max = chunkBounds.Max;

                var tl = min;
                var tr = new BlockPosition(min.X, max.Z);
                var bl = new BlockPosition(max.X, min.Z);
                var br = max;

                DrawText(graphics, tl.ToString(), chunkRect, _coordFont, StringAlignment.Near, StringAlignment.Near);
                DrawText(graphics, tr.ToString(), chunkRect, _coordFont, StringAlignment.Far, StringAlignment.Near);
                DrawText(graphics, bl.ToString(), chunkRect, _coordFont, StringAlignment.Near, StringAlignment.Far);
                DrawText(graphics, br.ToString(), chunkRect, _coordFont, StringAlignment.Far, StringAlignment.Far);
            }
        }
Пример #3
0
        private void DrawShadow(MapRegionLayer layer, Graphics graphics, BlockColumnMeta column, int sizeTop,
                                int sizeLeft, int sizeRight, int sizeBottom)
        {
            var rect = layer.GetBlockRectangle(column.Position);

            int actSizeTop = 0, actSizeLeft = 0, actSizeRight = 0, actSizeBottom = 0;

            if (sizeTop > 0)
            {
                actSizeTop = (int)MathUtils.Clamp(Math.Round(MaxShadowSize * (MathUtils.Clamp(sizeTop * ShadowSizeMultiplier, 0.25f, 1f))), 1f, MaxShadowSize);
                for (int i = 0; i < actSizeTop; i++)
                {
                    using (var pen = new Pen(Color.FromArgb((int)(MathUtils.Clamp(sizeTop * AlphaMultiplier, 64f, 255f) / actSizeTop) * (i + 1)
                                                            , Color.Black)))
                    {
                        graphics.DrawLine(pen, rect.Left, rect.Top + i, rect.Right, rect.Top + i);
                    }
                }
            }

            if (sizeBottom > 0)
            {
                actSizeBottom = (int)MathUtils.Clamp(Math.Round(MaxShadowSize * (MathUtils.Clamp(sizeBottom * ShadowSizeMultiplier, 0.25f, 1f))), 1f, MaxShadowSize);
                for (int i = 0; i < actSizeBottom; i++)
                {
                    using (var pen =
                               new Pen(Color.FromArgb((int)(MathUtils.Clamp(sizeBottom * AlphaMultiplier, 64f, 255f) / actSizeBottom) * (i + 1),
                                                      Color.Black)))
                    {
                        graphics.DrawLine(pen, rect.Left, rect.Bottom - actSizeBottom + i, rect.Right, rect.Bottom - actSizeBottom + i);
                    }
                }
            }

            if (sizeLeft > 0)
            {
                actSizeLeft = (int)MathUtils.Clamp(Math.Round(MaxShadowSize * (MathUtils.Clamp(sizeLeft * ShadowSizeMultiplier, 0.25f, 1f))), 1f, MaxShadowSize);
                for (int i = 0; i < actSizeLeft; i++)
                {
                    using (var pen = new Pen(Color.FromArgb((int)(MathUtils.Clamp(sizeLeft * AlphaMultiplier, 64f, 255f) / actSizeLeft) * (i + 1),
                                                            Color.Black)))
                    {
                        graphics.DrawLine(pen, rect.Left + i, rect.Top, rect.Left + i, rect.Bottom);
                    }
                }
            }

            if (sizeRight > 0)
            {
                actSizeRight = (int)MathUtils.Clamp(Math.Round(MaxShadowSize * (MathUtils.Clamp(sizeRight * ShadowSizeMultiplier, 0.25f, 1f))), 1f, MaxShadowSize);
                for (int i = 0; i < actSizeRight; i++)
                {
                    using (var pen =
                               new Pen(Color.FromArgb((int)(MathUtils.Clamp(sizeRight * AlphaMultiplier, 64f, 255f) / actSizeRight) * (i + 1),
                                                      Color.Black)))
                    {
                        graphics.DrawLine(pen, rect.Right - actSizeRight + i, rect.Top, rect.Right - actSizeRight + i, rect.Bottom);
                    }
                }
            }
        }