예제 #1
0
        public static void DrawSolidTriangle(SpriteBatch spriteBatch, float width, Color color, Vector2 pointA, Vector2 pointB, Vector2 pointC)
        {
            float[] arrX = { pointA.X, pointB.X, pointC.X };
            float[] arrY = { pointA.Y, pointB.Y, pointC.Y };

            float minX = arrX.Min();
            float maxX = arrX.Max();
            float minY = arrY.Min();
            float maxY = arrY.Max();

            for (int Pointy = (int)minY; Pointy <= maxY; Pointy++)
            {
                for (int Pointx = (int)minX; Pointx < maxX; Pointx++)
                {
                    if (IsInTriangle(new Vector2(Pointx, Pointy), pointA, pointB, pointC))
                    {
                        LineDrawer.DrawPixel(spriteBatch, color, new Vector2(Pointx, Pointy));
                    }
                }
            }
        }
예제 #2
0
        public static void DrawSolidTriangle(SpriteBatch spriteBatch, float width, Color color, Vector2 pointA, Vector2 pointB, Vector2 pointC)
        {
            float[] arrayX = { pointA.X, pointB.X, pointC.X };
            float[] arrayY = { pointA.Y, pointB.Y, pointC.Y };

            float xMin = arrayX.Min();
            float xMax = arrayX.Max();

            float yMin = arrayY.Min();
            float yMax = arrayY.Max();

            for (int yPt = (int)yMin; yPt <= yMax; yPt++)
            {
                for (int xPt = (int)xMin; xPt <= xMax; xPt++)
                {
                    if (InTriangle(new Vector2(xPt, yPt), pointA, pointB, pointC))
                    {
                        LineDrawer.DrawPixel(spriteBatch, color, new Vector2(xPt, yPt));
                    }
                }
            }
        }