Example #1
0
        public IEnumerable <Vec> Trace()
        {
            if ((Width > 1) && (Height > 1))
            {
                // trace all four sides
                foreach (Vec top in Row(TopLeft, Width - 1))
                {
                    yield return(top);
                }
                foreach (Vec right in Column(TopRight.OffsetX(-1), Height - 1))
                {
                    yield return(right);
                }
                foreach (Vec bottom in Row(Width - 1))
                {
                    yield return(BottomRight.Offset(-1, -1) - bottom);
                }
                foreach (Vec left in Column(Height - 1))
                {
                    yield return(BottomLeft.OffsetY(-1) - left);
                }
            }
            else if ((Width > 1) && (Height == 1))
            {
                // a single row
                foreach (Vec pos in Row(TopLeft, Width))
                {
                    yield return(pos);
                }
            }
            else if ((Height >= 1) && (Width == 1))
            {
                // a single column, or one unit
                foreach (Vec pos in Column(TopLeft, Height))
                {
                    yield return(pos);
                }
            }

            // otherwise, the rect doesn't have a positive size, so there's nothing to trace
        }