LilyPath/DrawBatch.cs
/// <summary>
/// Computes and adds a quadrilateral path to the batch of figures to be rendered.
/// </summary>
/// <param name="pen">The pen 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>DrawQuad</c> was called, but <see cref="Begin()"/> has not yet been called.</exception>
Computes and adds a quadrilateral path to the batch of figures to be rendered.
Computes and adds a quadrilateral path to the batch of figures to be rendered .
public void DrawQuad (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(8, 24);
            _ws.ResetWorkspace(pen);
            AddInfo(PrimitiveType.TriangleList, 8, 24, pen.Brush);
            if (points != _geometryBuffer)
                Array.Copy(points, _geometryBuffer, 4);
            if (angle != 0) {
                float centerX = (_geometryBuffer[0].X + _geometryBuffer[1].X + _geometryBuffer[2].X + _geometryBuffer[3].X) / 4;
                float centerY = (_geometryBuffer[0].Y + _geometryBuffer[1].Y + _geometryBuffer[2].Y + _geometryBuffer[3].Y) / 4;
                Vector2 center = new Vector2(centerX, centerY);
                Matrix transform = Matrix.CreateRotationZ(angle);
                transform.Translation = new Vector3(center, 0);
                for (int i = 0; i < 4; i++)
                    _geometryBuffer[i] = Vector2.Transform(_geometryBuffer[i] - center, transform);
            }
            int baseVertexIndex = _vertexBufferIndex;
            JoinSample js = new JoinSample(_geometryBuffer[0], _geometryBuffer[1], _geometryBuffer[2]);
            AddMiteredJoint(ref js, pen, _ws);
            js.Advance(_geometryBuffer[3]);
            AddMiteredJoint(ref js, pen, _ws);
            js.Advance(_geometryBuffer[0]);
            AddMiteredJoint(ref js, pen, _ws);
            js.Advance(_geometryBuffer[1]);
            AddMiteredJoint(ref js, pen, _ws);
            AddSegment(baseVertexIndex + 0, baseVertexIndex + 2);
            AddSegment(baseVertexIndex + 2, baseVertexIndex + 4);
            AddSegment(baseVertexIndex + 4, baseVertexIndex + 6);
            AddSegment(baseVertexIndex + 6, baseVertexIndex + 0);
            if (_sortMode == DrawSortMode.Immediate)
                FlushBuffer();
        }
public void DrawQuad ( 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 ( 8 , 24 ) ; _ws . ResetWorkspace ( pen ) ; AddInfo ( PrimitiveType . TriangleList , 8 , 24 , pen . Brush ) ; if ( points != _geometryBuffer ) Array . Copy ( points , _geometryBuffer , 4 ) ; if ( angle != 0 ) { float centerX = ( _geometryBuffer [ 0 ] . X + _geometryBuffer [ 1 ] . X + _geometryBuffer [ 2 ] . X + _geometryBuffer [ 3 ] . X ) / 4 ; float centerY = ( _geometryBuffer [ 0 ] . Y + _geometryBuffer [ 1 ] . Y + _geometryBuffer [ 2 ] . Y + _geometryBuffer [ 3 ] . Y ) / 4 ; Vector2 center = new Vector2 ( centerX , centerY ) ; Matrix transform = Matrix . CreateRotationZ ( angle ) ; transform . Translation = new Vector3 ( center , 0 ) ; for ( int i = 0 ; i < 4 ; i ++ ) _geometryBuffer [ i ] = Vector2 . Transform ( _geometryBuffer [ i ] - center , transform ) ; } int baseVertexIndex = _vertexBufferIndex ; JoinSample js = new JoinSample ( _geometryBuffer [ 0 ] , _geometryBuffer [ 1 ] , _geometryBuffer [ 2 ] ) ; AddMiteredJoint ( ref js , pen , _ws ) ; js . Advance ( _geometryBuffer [ 3 ] ) ; AddMiteredJoint ( ref js , pen , _ws ) ; js . Advance ( _geometryBuffer [ 0 ] ) ; AddMiteredJoint ( ref js , pen , _ws ) ; js . Advance ( _geometryBuffer [ 1 ] ) ; AddMiteredJoint ( ref js , pen , _ws ) ; AddSegment ( baseVertexIndex + 0 , baseVertexIndex + 2 ) ; AddSegment ( baseVertexIndex + 2 , baseVertexIndex + 4 ) ; AddSegment ( baseVertexIndex + 4 , baseVertexIndex + 6 ) ; AddSegment ( baseVertexIndex + 6 , baseVertexIndex + 0 ) ; if ( _sortMode == DrawSortMode . Immediate ) FlushBuffer ( ) ; }
Computes and adds a quadrilateral path to the batch of figures to be rendered.
Computes and adds a quadrilateral path to the batch of figures to be rendered .
DrawQuad has not yet been called.
DrawQuad has not yet been called .
pen
Pen
The pen to render the path with.
The pen 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 .