Ejemplo n.º 1
0
        protected override void FillMaze(Graphics graphics,
                                         RectangularStructure structure,
                                         DrawingParameters parameters,
                                         IEnumerable <Cell> order)
        {
            graphics.TranslateTransform(parameters.strokeWidth, parameters.strokeWidth);

            float drawWidth  = parameters.cellSize;
            float drawHeight = parameters.cellSize;

            int   i     = 0;
            int   count = order.Count();
            Brush brush = new SolidBrush(parameters.fillColor);

            foreach (Cell cell in order)
            {
                if (parameters.fillType == FillType.GenerationGradient)
                {
                    brush = new SolidBrush(Helpers.Lerp(Color.Black, parameters.fillColor, (float)i / count));
                }

                RectangularPosition pos = cell.Position as RectangularPosition;
                int x = pos.x;
                int y = pos.y;

                PointF p1 = new PointF(x * drawWidth, y * drawHeight);
                PointF p2 = new PointF((x + 1) * drawWidth, y * drawHeight);
                PointF p3 = new PointF((x + 1) * drawWidth, (y + 1) * drawHeight);
                PointF p4 = new PointF(x * drawWidth, (y + 1) * drawHeight);

                GraphicsPath bounds = new GraphicsPath();
                bounds.AddLine(p1, p2);
                bounds.AddLine(p2, p3);
                bounds.AddLine(p3, p4);
                bounds.AddLine(p4, p1);

                graphics.FillPath(brush, bounds);

                i++;
            }

            graphics.ResetTransform();
        }
Ejemplo n.º 2
0
        public bool ContainsAtPosition(RectangularPosition position)
        {
            Color color = _bitmap.GetPixel(position.x, position.y);

            return(ShapeSelector(color));
        }