Пример #1
0
        //Return a LineBatch contain the lines that make up a filled circle of specified colour.
        public static LineBatch FilledCircle(Vec2 position, int radius, Brush colour)
        {
            var lineBatch = new LineBatch();

            lineBatch.SetColour(colour);
            lineBatch.LineThickness = 1;
            var increment = 360 / 45 / 4;
            var a         = 0f;

            while (a < 360)
            {
                var heading = (a + increment) * (Math.PI / 180);

                var newLightLine = new LightLine
                {
                    X1 = position.X,
                    Y1 = position.Y,
                    X2 = Math.Cos(heading) * radius + position.X,
                    Y2 = Math.Sin(heading) * radius + position.Y
                };
                lineBatch.Add(newLightLine);

                a += increment;
            }

            return(lineBatch);
        }
Пример #2
0
        //Return a line batch that contains lines that make up a box of specifed width, height, line thickness and colour.
        public static LineBatch Border(double width, double height, double lineThickness, Brush colour)
        {
            var border = new LineBatch();

            border.SetColour(Brushes.Black);
            border.LineThickness = lineThickness;
            border.SetColour(colour);

            var newLightLine = new LightLine
            {
                X1 = 0,
                Y1 = 0,
                X2 = width,
                Y2 = 0
            };

            var newLightLine2 = new LightLine
            {
                X1 = 0,
                Y1 = 0,
                X2 = 0,
                Y2 = height
            };

            var newLightLine3 = new LightLine
            {
                X1 = width,
                Y1 = 0,
                X2 = width,
                Y2 = height
            };

            var newLightLine4 = new LightLine
            {
                X1 = 0,
                Y1 = height,
                X2 = width,
                Y2 = height
            };

            border.Add(newLightLine);
            border.Add(newLightLine2);
            border.Add(newLightLine3);
            border.Add(newLightLine4);

            return(border);
        }
Пример #3
0
        //Return a LineBatch contain the lines that make up a circle of a specified colour.
        public static LineBatch Circle(Vec2 position, int radius, Brush colour)
        {
            var lineBatch = new LineBatch();

            lineBatch.SetColour(colour);
            int increment = 360 / 45 / 4;

            for (var a = 0; a < 360; a += increment)
            {
                var heading1 = a * (Math.PI / 180);
                var heading2 = (a + increment) * (Math.PI / 180);

                var newLightLine = new LightLine
                {
                    X1 = Math.Cos(heading1) * radius + position.X,
                    Y1 = Math.Sin(heading1) * radius + position.Y,
                    X2 = Math.Cos(heading2) * radius + position.X,
                    Y2 = Math.Sin(heading2) * radius + position.Y
                };
                lineBatch.Add(newLightLine);
            }
            return(lineBatch);
        }