Ejemplo n.º 1
0
        public void DrawLine(Vector2 p1, Vector2 p2, Color color, int lineWidth = 1)
        {
            var di = DrawInfo.ForLine(BasicEffect, _blankTexture, lineWidth);

            CheckFlush(di);

            var v1 = AddVertex(p1, color);
            var v2 = AddVertex(p2, color);

            AddIndex(v1);
            AddIndex(v2);
        }
Ejemplo n.º 2
0
        public void DrawRoundedRect(RectangleF rect, Color color, int lineWidth = 1)
        {
            var di = DrawInfo.ForLine(BasicEffect, _blankTexture, lineWidth);

            CheckFlush(di);

            var v1 = AddVertex(new Vector2(rect.Left, rect.Top), color);
            var v2 = AddVertex(new Vector2(rect.Right, rect.Top), color);
            var v3 = AddVertex(new Vector2(rect.Right, rect.Bottom), color);
            var v4 = AddVertex(new Vector2(rect.Left, rect.Bottom), color);

            AddIndex(v1);
            AddIndex(v2);
            AddIndex(v2);
            AddIndex(v3);
            AddIndex(v3);
            AddIndex(v4);
            AddIndex(v4);
            AddIndex(v1);
        }
Ejemplo n.º 3
0
        public void DrawLineStrip(IEnumerable <Vector2> points, Color color, int lineWidth = 1)
        {
            var di = DrawInfo.ForLine(BasicEffect, _blankTexture, lineWidth);

            CheckFlush(di);

            var enumerator = points.GetEnumerator();

            if (!enumerator.MoveNext())
            {
                throw new Exception("Need at least 3 vertices for a triangle strip.");
            }
            var v0 = AddVertex(enumerator.Current, color);

            while (enumerator.MoveNext())
            {
                var v1 = AddVertex(enumerator.Current, color);
                AddIndex(v0);
                AddIndex(v1);
                v0 = v1;
            }

            enumerator.Dispose();
        }