LilyPath/DrawBatch.cs
/// <summary>
/// Adds a primitive quadrilateral to the batch of figures to be rendered.
/// </summary>
/// <param name="pen">The pen supplying a color to render the path with.</param>
/// <param name="points">An array containing the coordinates of the quad.</param>
/// <param name="offset">The offset into the points array.</param>
/// <param name="angle">The angle to rotate the quad by around its weighted center in radians.  Positive values rotate clockwise.</param>
/// <exception cref="InvalidOperationException"><c>DrawPrimitiveQuad</c> was called, but <see cref="Begin()"/> has not yet been called.</exception>
Adds a primitive quadrilateral to the batch of figures to be rendered.
Adds a primitive quadrilateral to the batch of figures to be rendered .
public void DrawPrimitiveQuad (Pen pen, Vector2[] points, int offset, float angle)
        {
            if (!_inDraw)
                throw new InvalidOperationException();
            if (pen == null)
                throw new ArgumentNullException("pen");
            if (points == null)
                throw new ArgumentNullException("points");
            if (points.Length < offset + 4)
                throw new ArgumentException("Points array is too small for the given offset.");
            RequestBufferSpace(4, 8);
            AddInfo(PrimitiveType.LineList, 4, 8, pen.Brush);
            int baseVertexIndex = _vertexBufferIndex;
            _vertexBuffer[_vertexBufferIndex++] = new VertexPositionColorTexture(new Vector3(points[offset + 0], 0), pen.Color, points[offset + 0]);
            _vertexBuffer[_vertexBufferIndex++] = new VertexPositionColorTexture(new Vector3(points[offset + 1], 0), pen.Color, points[offset + 1]);
            _vertexBuffer[_vertexBufferIndex++] = new VertexPositionColorTexture(new Vector3(points[offset + 2], 0), pen.Color, points[offset + 2]);
            _vertexBuffer[_vertexBufferIndex++] = new VertexPositionColorTexture(new Vector3(points[offset + 3], 0), pen.Color, points[offset + 3]);
            if (angle != 0) {
                float centerX = (points[offset + 0].X + points[offset + 1].X + points[offset + 2].X + points[offset + 3].X) / 4;
                float centerY = (points[offset + 0].Y + points[offset + 1].Y + points[offset + 2].Y + points[offset + 3].Y) / 4;
                Vector3 center = new Vector3(centerX, centerY, 0);
                Matrix transform = Matrix.CreateRotationZ(angle);
                transform.Translation = center;
                for (int i = _vertexBufferIndex - 4; i < _vertexBufferIndex; i++)
                    _vertexBuffer[i].Position = Vector3.Transform(_vertexBuffer[i].Position - center, transform);
            }
            _indexBuffer[_indexBufferIndex++] = (short)(baseVertexIndex);
            _indexBuffer[_indexBufferIndex++] = (short)(baseVertexIndex + 1);
            _indexBuffer[_indexBufferIndex++] = (short)(baseVertexIndex + 1);
            _indexBuffer[_indexBufferIndex++] = (short)(baseVertexIndex + 2);
            _indexBuffer[_indexBufferIndex++] = (short)(baseVertexIndex + 2);
            _indexBuffer[_indexBufferIndex++] = (short)(baseVertexIndex + 3);
            _indexBuffer[_indexBufferIndex++] = (short)(baseVertexIndex + 3);
            _indexBuffer[_indexBufferIndex++] = (short)(baseVertexIndex);
            if (_sortMode == DrawSortMode.Immediate)
                FlushBuffer();
        }
public void DrawPrimitiveQuad ( Pen pen , Vector2 [ ] points , int offset , float angle ) { if ( ! _inDraw ) throw new InvalidOperationException ( ) ; if ( pen == null ) throw new ArgumentNullException ( " " ) ; if ( points == null ) throw new ArgumentNullException ( " " ) ; if ( points . Length < offset + 4 ) throw new ArgumentException ( " " ) ; RequestBufferSpace ( 4 , 8 ) ; AddInfo ( PrimitiveType . LineList , 4 , 8 , pen . Brush ) ; int baseVertexIndex = _vertexBufferIndex ; _vertexBuffer [ _vertexBufferIndex ++ ] = new VertexPositionColorTexture ( new Vector3 ( points [ offset + 0 ] , 0 ) , pen . Color , points [ offset + 0 ] ) ; _vertexBuffer [ _vertexBufferIndex ++ ] = new VertexPositionColorTexture ( new Vector3 ( points [ offset + 1 ] , 0 ) , pen . Color , points [ offset + 1 ] ) ; _vertexBuffer [ _vertexBufferIndex ++ ] = new VertexPositionColorTexture ( new Vector3 ( points [ offset + 2 ] , 0 ) , pen . Color , points [ offset + 2 ] ) ; _vertexBuffer [ _vertexBufferIndex ++ ] = new VertexPositionColorTexture ( new Vector3 ( points [ offset + 3 ] , 0 ) , pen . Color , points [ offset + 3 ] ) ; if ( angle != 0 ) { float centerX = ( points [ offset + 0 ] . X + points [ offset + 1 ] . X + points [ offset + 2 ] . X + points [ offset + 3 ] . X ) / 4 ; float centerY = ( points [ offset + 0 ] . Y + points [ offset + 1 ] . Y + points [ offset + 2 ] . Y + points [ offset + 3 ] . Y ) / 4 ; Vector3 center = new Vector3 ( centerX , centerY , 0 ) ; Matrix transform = Matrix . CreateRotationZ ( angle ) ; transform . Translation = center ; for ( int i = _vertexBufferIndex - 4 ; i < _vertexBufferIndex ; i ++ ) _vertexBuffer [ i ] . Position = Vector3 . Transform ( _vertexBuffer [ i ] . Position - center , transform ) ; } _indexBuffer [ _indexBufferIndex ++ ] = ( short ) ( baseVertexIndex ) ; _indexBuffer [ _indexBufferIndex ++ ] = ( short ) ( baseVertexIndex + 1 ) ; _indexBuffer [ _indexBufferIndex ++ ] = ( short ) ( baseVertexIndex + 1 ) ; _indexBuffer [ _indexBufferIndex ++ ] = ( short ) ( baseVertexIndex + 2 ) ; _indexBuffer [ _indexBufferIndex ++ ] = ( short ) ( baseVertexIndex + 2 ) ; _indexBuffer [ _indexBufferIndex ++ ] = ( short ) ( baseVertexIndex + 3 ) ; _indexBuffer [ _indexBufferIndex ++ ] = ( short ) ( baseVertexIndex + 3 ) ; _indexBuffer [ _indexBufferIndex ++ ] = ( short ) ( baseVertexIndex ) ; if ( _sortMode == DrawSortMode . Immediate ) FlushBuffer ( ) ; }
Adds a primitive quadrilateral to the batch of figures to be rendered.
Adds a primitive quadrilateral to the batch of figures to be rendered .
DrawPrimitiveQuad has not yet been called.
DrawPrimitiveQuad has not yet been called .
pen
Pen
The pen supplying a color to render the path with.
The pen supplying a color to render the path with .
points
Vector2[]
An array containing the coordinates of the quad.
An array containing the coordinates of the quad .
offset
int
The offset into the points array.
The offset into the points array .
angle
float
The angle to rotate the quad by around its weighted center in radians.  Positive values rotate clockwise.
The angle to rotate the quad by around its weighted center in radians . Positive values rotate clockwise .