Beispiel #1
0
        public Triangle SetFilled(Color lineColor, bool enable = true)
        {
            if (IsFilled = enable)
            {
                var PointListAmongPoint1Point2 = new List <Vector2>();
                var PointListAmongPoint1Point3 = new List <Vector2>();
                var PointListAmongPoint2Point3 = new List <Vector2>();

                PointListAmongPoint1Point2 = PointListAmong2Points(FirstPoint, SecondPoint);
                PointListAmongPoint1Point3 = PointListAmong2Points(FirstPoint, ThirdPoint);
                PointListAmongPoint2Point3 = PointListAmong2Points(SecondPoint, ThirdPoint);

                for (int i = 0; i < PointListAmongPoint1Point2.Count; i++)
                {
                    FillingLines.Add(new Line(lineColor, ThirdPoint, PointListAmongPoint1Point2[i]));
                }

                for (int i = 0; i < PointListAmongPoint1Point3.Count; i++)
                {
                    FillingLines.Add(new Line(lineColor, SecondPoint, PointListAmongPoint1Point3[i]));
                }

                for (int i = 0; i < PointListAmongPoint2Point3.Count; i++)
                {
                    FillingLines.Add(new Line(lineColor, FirstPoint, PointListAmongPoint2Point3[i]));
                }

                foreach (var line in FillingLines)
                {
                    line.LoadContent();
                }

                var rect = new Rectangle((int)Points.Min(p => p.X),
                                         (int)Points.Min(p => p.Y),
                                         (int)Points.Max(p => p.X) + 1,
                                         (int)Points.Max(p => p.Y) + 1);

                SetPosition(new Vector2(0, 0));
                SetSize(new Vector2(rect.Width, rect.Height));

                SetTexture(TextureManager.Shot(() => Draw(), rect.Width, rect.Height));
                SetTexture(TextureManager.Crop(Texture, new Rectangle(rect.X, rect.Y, rect.Width - rect.X, rect.Height - rect.Y)));

                TestInfo.Show(true);
                TestInfo.AddParameters("DestinationRectangle");

                if (Texture != null)
                {
                    FillingLines.Clear();
                }
            }

            return(this);
        }