예제 #1
0
        private void DrawHorizontalLine(IRenderTarget renderTarget, int y, int x1, int x2, Color color, Func <float, float, float> plan)
        {
            if (y >= 0 && y < renderTarget.Height)
            {
                if (x1 > x2)
                {
                    Utils.Exchange(ref x1, ref x2);
                }

                if (x2 >= 0 && x1 < renderTarget.Width)
                {
                    if (x1 < 0)
                    {
                        x1 = 0;
                    }

                    if (x2 >= renderTarget.Width)
                    {
                        x2 = renderTarget.Width - 1;
                    }

                    if (x1 <= x2)
                    {
                        for (int x = x1; x < x2; ++x)
                        {
                            float z = plan(x, y);

                            if (z > renderTarget.GetDepth(x, y))
                            {
                                renderTarget[x, y] = color;
                                renderTarget.SetDepth(x, y, z);
                            }
                        }
                    }
                }
            }
        }