示例#1
0
        private void DrawFixture(Fixture fixture)
        {
            var color = Color.FromArgb(242, 242, 153);
            var xf    = fixture.Body.GetTransform();

            switch (fixture.Shape)
            {
            case CircleShape circle:
            {
                var center = MathUtils.Mul(xf, circle.Position);
                var radius = circle.Radius + 0.01f;

                _drawer.DrawCircle(center, radius, color);
            }
            break;

            case PolygonShape polygonShape:
            {
                var vertexCount = polygonShape.Count;
                Debug.Assert(vertexCount <= Settings.MaxPolygonVertices);
                var vertices = new Vector2[Settings.MaxPolygonVertices];

                for (var i = 0; i < vertexCount; ++i)
                {
                    var v = MathUtils.Mul(xf, polygonShape.Vertices[i]);
                    v.X        += 0.01f;
                    v.Y        += 0.01f;
                    vertices[i] = v;
                }

                _drawer.DrawPolygon(vertices, vertexCount, color);
            }
            break;
            }
        }
示例#2
0
 public void Draw(IDrawer drawer)
 {
     drawer.DrawCircle(this);
 }
示例#3
0
 public override void Draw(IDrawer drawer)
 {
     drawer.DrawCircle(X, Y, Radius, Type);
 }