SetPoint() public method

Set the position of a point. Don't forget that the polygon must remain convex, and the points need to stay ordered! PointCount must be set first in order to set the total number of points. The result is undefined if index is out of the valid range.
public SetPoint ( uint index, Vector2f point ) : void
index uint Index of the point to change, in range [0 .. PointCount - 1]
point Vector2f New position of the point
return void
示例#1
0
        public void DrawQuad(int x, int y, int width, int height, Color color, Color color2, int thickness)
        {
            var zoom = GetZoom();

            int real_x      = (int)(x * zoom);
            int real_y      = (int)(y * zoom);
            int real_width  = (int)(width * zoom);
            int real_height = (int)(height * zoom);

            SFML.System.Vector2f position = new SFML.System.Vector2f(real_x, real_y);
            SFML.System.Vector2f size     = new SFML.System.Vector2f(real_width, real_height);

            float offset_x = 0;
            float offset_y = 0;

            SFML.Graphics.ConvexShape rect = new SFML.Graphics.ConvexShape(4);
            rect.OutlineThickness = thickness;
            rect.OutlineColor     = new SFML.Graphics.Color(color2.R, color2.G, color2.B, color2.A);
            rect.FillColor        = new SFML.Graphics.Color(color.R, color.G, color.B, color.A);
            rect.Position         = position;
            rect.SetPoint(0, new SFML.System.Vector2f(offset_x, offset_y));
            rect.SetPoint(1, new SFML.System.Vector2f(offset_x + size.X, offset_y));
            rect.SetPoint(2, new SFML.System.Vector2f(offset_x + size.X - size.Y, offset_y + size.Y));
            rect.SetPoint(3, new SFML.System.Vector2f(offset_x - size.Y, offset_y + size.Y));
            RenderWindow.Draw(rect);
        }
        public Triangle(float width, float height)
            : base(0.5f * width * height)
        {
            float halfWidth = width / 2f;
            float halfHeight = height / 2f;

            triangle = new ConvexShape(3);
            triangle.SetPoint(0, new Vector2f(halfWidth, 0));
            triangle.SetPoint(1, new Vector2f(width, height));
            triangle.SetPoint(2, new Vector2f(0, height));
            triangle.FillColor = Color.Yellow;

            Origin = new Vector2f(halfWidth, halfHeight);

            this.width = width;
            this.height = height;
        }
示例#3
0
        // Create color primitive render component from a body
        private static ColorPrimitiveRenderComponent createColorPrimitiveRenderComponent(int entityId, Body body, Color color)
        {
            ColorPrimitiveRenderComponent component = new ColorPrimitiveRenderComponent(entityId, color);
            List<BodyRenderData> allRenderData = new List<BodyRenderData>();
            BodyRenderData renderData = new BodyRenderData();
            List<ConvexShape> shapes = new List<ConvexShape>();

            foreach (Fixture fixture in body.FixtureList)
            {
                if (fixture.Shape.ShapeType == ShapeType.Polygon)
                {
                    PolygonShape polygonShape = fixture.Shape as PolygonShape;
                    ConvexShape sfmlShape = new ConvexShape((uint)polygonShape.Vertices.Count);

                    for (int i = 0; i < polygonShape.Vertices.Count; i++)
                    {
                        Vector2 vertex = polygonShape.Vertices[i];

                        sfmlShape.SetPoint((uint)i, new Vector2f(vertex.X, vertex.Y));
                    }

                    sfmlShape.FillColor = color;
                    shapes.Add(sfmlShape);
                }
            }

            renderData.body = body;
            renderData.shapes = shapes;

            allRenderData.Add(renderData);

            component.renderData = allRenderData;

            return component;
        }