protected override void DisposeManaged()
        {
            if (_data != null) {
                _data.FillInvalidated -= HandleFillInvalidated;
                _data.FillGlowInvalidated -= HandleFillGlowInvalidated;
                _data.OutlineInvalidated -= HandleOutlineInvalidated;
                _data.OutlineGlowInvalidated -= HandleOutlineGlowInvalidated;
                _data = null;
            }

            if (_fillBrush != null) {
                _fillBrush.Dispose();
                _fillBrush = null;
            }

            if (_fillGlowBrush != null) {
                _fillGlowBrush.Dispose();
                _fillGlowBrush = null;
            }

            if (_outlinePen != null) {
                _outlinePen.Dispose();
                _outlinePen = null;
            }

            if (_outlineGlowPen != null) {
                _outlineGlowPen.Dispose();
                _outlineGlowPen = null;
            }

            base.DisposeManaged();
        }
示例#2
0
        public static XnaDrawing.Pen Create(GraphicsDevice device, Drawing.Pen pen)
        {
            if (pen.GetType() == typeof(Drawing.Pen))
            {
                XnaDrawing.Brush brush = BrushFactory.Create(device, pen.Brush);
                return(new XnaDrawing.Pen(brush, (int)pen.Width));
            }
            else if (pen.GetType() == typeof(Drawing.PrimitivePen))
            {
                Drawing.SolidColorBrush brush = pen.Brush as Drawing.SolidColorBrush;
                return(new XnaDrawing.PrimitivePen(brush.Color.ToXnaColor()));
            }

            return(null);
        }
        /// <summary>
        /// Adds a filled rectangle to the batch of figures to be rendered.
        /// </summary>
        /// <param name="brush">The brush to render the shape with.</param>
        /// <param name="rect">The rectangle to be rendered.</param>
        /// <param name="angle">The angle to rotate the rectangle by around its center in radians.  Positive values rotate clockwise.</param>
        /// <exception cref="InvalidOperationException"><c>FillRectangle</c> was called, but <see cref="Begin()"/> has not yet been called.</exception>
        public void FillRectangle (Brush brush, CCRect rect, float angle)
        {
            _geometryBuffer[0] = new CCVector2(rect.MinX, rect.MaxY);
            _geometryBuffer[1] = new CCVector2(rect.MaxX, rect.MaxY);
            _geometryBuffer[2] = new CCVector2(rect.MaxX, rect.MinY);
            _geometryBuffer[3] = new CCVector2(rect.MinX, rect.MinY);

            FillQuad(brush, _geometryBuffer, 0, angle);
        }
示例#4
0
 /// <summary>
 /// Creates a new <see cref="Pen"/> with the given brush and a width of 1.
 /// </summary>
 /// <param name="brush">The <see cref="Brush"/> used to stroke the pen.</param>
 /// <remarks>By default, the pen will not take resposibility for disposing the <see cref="Brush"/>.</remarks>
 public Pen (Brush brush)
     : this(brush, 1, false)
 {
 }
示例#5
0
        /// <summary>
        /// Creates a new <see cref="Pen"/> with the given brush and width.
        /// </summary>
        /// <param name="brush">The <see cref="Brush"/> used to stroke the pen.</param>
        /// <param name="width">The width of the paths drawn by the pen.</param>
        /// <param name="ownsBrush"><c>true</c> if the pen should be responsible for disposing the <see cref="Brush"/>, <c>false</c> otherwise.</param>
        public Pen (Brush brush, float width, bool ownsBrush)
            : this()
        {
            if (brush == null)
                throw new ArgumentNullException("brush");

            _width = width;

            Brush = brush;
            OwnsBrush = ownsBrush;

            StartCapInfo = CreateLineCapInfo(StartCap, Width);
            EndCapInfo = CreateLineCapInfo(EndCap, Width);
        }
        /// <summary>
        /// Adds a filled region enclosed by the given multisegment path to the batch of figures to be rendered.
        /// </summary>
        /// <param name="brush">The brush to render the shape with.</param>
        /// <param name="points">The list of points that make up the multisegment path enclosing the region.</param>
        /// <param name="offset">The offset into the <paramref name="points"/> list to begin rendering.</param>
        /// <param name="count">The number of points that should be rendered, starting from <paramref name="offset"/>.</param>
        /// <exception cref="InvalidOperationException"><c>FillPath</c> was called, but <see cref="Begin()"/> has not yet been called.</exception>
        /// <remarks>Paths should be created with a clockwise winding order, or the resulting geometry will be backface-culled.</remarks>
        public void FillPath (Brush brush, IList<CCVector2> points, int offset, int count)
        {
            if (!_inDraw)
                throw new InvalidOperationException();
            if (brush == null)
                throw new ArgumentNullException("brush");

            //if (_triangulator == null)
            //    _triangulator = new Triangulator();

            //_triangulator.Triangulate(points, offset, count);

            //RequestBufferSpace(count, _triangulator.ComputedIndexCount);
            //AddInfo(PrimitiveType.TriangleList, count, _triangulator.ComputedIndexCount, brush);

            //int baseVertexIndex = _vertexBufferIndex;

            //for (int i = 0; i < count; i++) {
            //    AddVertex(points[offset + i], brush);
            //}

            //for (int i = 0; i < _triangulator.ComputedIndexCount; i++) {
            //    _indexBuffer[_indexBufferIndex + i] = (short)(_triangulator.ComputedIndexes[i] + baseVertexIndex);
            //}

            //_indexBufferIndex += _triangulator.ComputedIndexCount;

            //if (_sortMode == DrawSortMode.Immediate)
            //    FlushBuffer();
        }
        private void AddVertex (CCVector2 position, Brush brush)
        {
            VertexPositionColorTexture vertex = new VertexPositionColorTexture();
            //vertex.Position = new Vector3(position, 0);
            //vertex.Color = brush.Color;

            //if (brush != null && brush.Texture != null) {
            //    Texture2D tex = brush.Texture;
            //    vertex.TextureCoordinate = new CCVector2(position.X / tex.Width, position.Y / tex.Height);
            //    vertex.TextureCoordinate = CCVector2.Transform(vertex.TextureCoordinate, brush.Transform);
            //    vertex.Color *= brush.Alpha;
            //}
            //else {
            //    vertex.TextureCoordinate = new CCVector2(position.X, position.Y);
            //}

            //_vertexBuffer[_vertexBufferIndex++] = vertex;
        }
 /// <summary>
 /// Adds a filled ellipse to the batch of figures to be rendered.
 /// </summary>
 /// <param name="brush">The brush to render the shape with.</param>
 /// <param name="center">The center coordinate of the ellipse.</param>
 /// <param name="xRadius">The radius of the ellipse along the x-axis.</param>
 /// <param name="yRadius">The radius of the llipse along the y-axis.</param>
 /// <param name="angle">The angle to rotate the ellipse by in radians.  Positive values rotate clockwise.</param>
 /// <exception cref="InvalidOperationException"><c>FillEllipse</c> was called, but <see cref="Begin()"/> has not yet been called.</exception>
 /// <remarks>The number of subdivisions in the ellipse is computed as max(xRadius, yRadius) / 1.5.</remarks>
 public void FillEllipse (Brush brush, CCVector2 center, float xRadius, float yRadius, float angle)
 {
     FillEllipse(brush, center, xRadius, yRadius, angle, DefaultSubdivisions(xRadius, yRadius));
 }
        /// <summary>
        /// Adds a filled ellipse to the batch of figures to be rendered.
        /// </summary>
        /// <param name="brush">The brush to render the shape with.</param>
        /// <param name="center">The center coordinate of the ellipse.</param>
        /// <param name="xRadius">The radius of the ellipse along the x-axis.</param>
        /// <param name="yRadius">The radius of the llipse along the y-axis.</param>
        /// <param name="angle">The angle to rotate the ellipse by in radians.  Positive values rotate clockwise.</param>
        /// <param name="subdivisions">The number of subdivisions to render the circle with.</param>
        /// <exception cref="InvalidOperationException"><c>FillEllipse</c> was called, but <see cref="Begin()"/> has not yet been called.</exception>
        public void FillEllipse (Brush brush, CCVector2 center, float xRadius, float yRadius, float angle, int subdivisions)
        {
            if (!_inDraw)
                throw new InvalidOperationException();
            if (brush == null)
                throw new ArgumentNullException("brush");

            RequestBufferSpace(subdivisions + 1, subdivisions * 3);
            AddInfo(PrimitiveType.TriangleList, subdivisions + 1, subdivisions * 3, brush);

            BuildEllipseGeometryBuffer(center, xRadius, yRadius, angle, subdivisions);

            //int baseVertexIndex = _vertexBufferIndex;

            //for (int i = 0; i < subdivisions; i++)
            //    AddVertex(_geometryBuffer[i], brush);

            //AddVertex(new CCVector2(center.X, center.Y), brush);

            //for (int i = 0; i < subdivisions - 1; i++)
            //    AddTriangle(baseVertexIndex + subdivisions, baseVertexIndex + i + 1, baseVertexIndex + i);

            //AddTriangle(baseVertexIndex + subdivisions, baseVertexIndex, baseVertexIndex + subdivisions - 1);

            //if (_sortMode == DrawSortMode.Immediate)
            //    FlushBuffer();
        }
示例#10
0
 /// <summary>
 /// Adds a filled ellipse path to the batch of figures to be rendered.
 /// </summary>
 /// <param name="brush">The brush to render the shape with.</param>
 /// <param name="bound">The bounding rectangle of the ellipse.</param>
 /// <param name="angle">The angle to rotate the ellipse by in radians.  Positive values rotate clockwise.</param>
 /// <param name="subdivisions">The number of subdivisions (sides) to render the ellipse with.</param>
 /// <exception cref="InvalidOperationException"><c>FillEllipse</c> was called, but <see cref="Begin()"/> has not yet been called.</exception>
 public void FillEllipse (Brush brush, Rectangle bound, float angle, int subdivisions)
 {
     FillEllipse(brush, new CCVector2(bound.Center.X, bound.Center.Y), bound.Width / 2f, bound.Height / 2f, angle, subdivisions);
 }
示例#11
0
 /// <summary>
 /// Adds a filled ellipse to the batch of figures to be rendered.
 /// </summary>
 /// <param name="brush">The brush to render the shape with.</param>
 /// <param name="center">The center coordinate of the ellipse.</param>
 /// <param name="xRadius">The radius of the ellipse along the x-axis.</param>
 /// <param name="yRadius">The radius of the llipse along the y-axis.</param>
 /// <exception cref="InvalidOperationException"><c>FillEllipse</c> was called, but <see cref="Begin()"/> has not yet been called.</exception>
 /// <remarks>The number of subdivisions in the ellipse is computed as max(xRadius, yRadius) / 1.5.</remarks>
 public void FillEllipse (Brush brush, CCVector2 center, float xRadius, float yRadius)
 {
     FillEllipse(brush, center, xRadius, yRadius, 0);
 }
示例#12
0
 /// <summary>
 /// Adds a filled ellipse path to the batch of figures to be rendered.
 /// </summary>
 /// <param name="brush">The brush to render the shape with.</param>
 /// <param name="bound">The bounding rectangle of the ellipse.</param>
 /// <exception cref="InvalidOperationException"><c>FillEllipse</c> was called, but <see cref="Begin()"/> has not yet been called.</exception>
 /// <remarks>The number of subdivisions in the ellipse is computed as max(width, height) / 3.0.</remarks>
 public void FillEllipse (Brush brush, Rectangle bound)
 {
     FillEllipse(brush, new CCVector2(bound.Center.X, bound.Center.Y), bound.Width / 2f, bound.Height / 2f, 0);
 }
示例#13
0
 /// <summary>
 /// Adds a filled circle to the batch of figures to be rendered.
 /// </summary>
 /// <param name="brush">The brush to render the shape with.</param>
 /// <param name="center">The center coordinate of the circle.</param>
 /// <param name="radius">The radius of the circle.</param>
 /// <exception cref="InvalidOperationException"><c>FillCircle</c> was called, but <see cref="Begin()"/> has not yet been called.</exception>
 /// <remarks>The number of subdivisions in the circle is computed as <c>(radius / 1.5)</c>.</remarks>
 public void FillCircle (Brush brush, CCVector2 center, float radius)
 {
     FillCircle(brush, center, radius, DefaultSubdivisions(radius));
 }
示例#14
0
        private void AddVertex(Vector2 position, Brush brush)
        {
            VertexPositionColorTexture vertex = new VertexPositionColorTexture();
            vertex.Position = new Vector3(position, 0);
            vertex.Color = brush.Color;

            if (brush != null && brush.Texture != null && brush.Texture.XNATexture != null)
            {
                Texture2D tex = brush.Texture.XNATexture;
                vertex.TextureCoordinate = new Vector2(position.X / tex.Width, position.Y / tex.Height);
                vertex.TextureCoordinate = Vector2.Transform(vertex.TextureCoordinate, brush.Transform);
                vertex.Color *= brush.Alpha;
            }
            else
            {
                vertex.TextureCoordinate = new Vector2(position.X, position.Y);
            }

            _vertexBuffer[_vertexBufferIndex++] = vertex;
        }
示例#15
0
        /// <summary>
        /// Adds a filled quadrilateral to the batch of figures to be rendered.
        /// </summary>
        /// <param name="brush">The brush to render the shape 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 around its weighted center in radians.  Positive values rotate clockwise.</param>
        /// <exception cref="InvalidOperationException"><c>FillQuad</c> was called, but <see cref="Begin()"/> has not yet been called.</exception>
        public void FillQuad (Brush brush, CCVector2[] points, int offset, float angle)
        {
            if (!_inDraw)
                throw new InvalidOperationException();
            if (brush == null)
                throw new ArgumentNullException("brush");
            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, 6);
            AddInfo(PrimitiveType.TriangleList, 4, 6, brush);

            //int baseVertexIndex = _vertexBufferIndex;

            //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;
            //    CCVector2 center = new CCVector2(centerX, centerY);

            //    Matrix transform = Matrix.CreateRotationZ(angle);
            //    transform.Translation = new Vector3(center, 0);

            //    for (int i = 0; i < 4; i++)
            //        _geometryBuffer[i] = CCVector2.Transform(_geometryBuffer[i] - center, transform);
            //}

            //for (int i = 0; i < 4; i++)
            //    AddVertex(_geometryBuffer[i], brush);

            //AddTriangle(baseVertexIndex + 0, baseVertexIndex + 1, baseVertexIndex + 3);
            //AddTriangle(baseVertexIndex + 1, baseVertexIndex + 2, baseVertexIndex + 3);

            //if (_sortMode == DrawSortMode.Immediate)
            //    FlushBuffer();
        }
示例#16
0
 /// <summary>
 /// Adds a filled arc to the batch of figures to be rendered.
 /// </summary>
 /// <param name="brush">The brush to render the shape with.</param>
 /// <param name="center">The center coordinate of the arc.</param>
 /// <param name="radius">The radius of the arc.</param>
 /// <param name="startAngle">The starting angle of the arc in radians, where 0 is 3 O'Clock.</param>
 /// <param name="arcAngle">The sweep of the arc in radians.  Positive values draw clockwise.</param>
 /// <param name="arcType">Whether the arc is drawn as a segment or a sector.</param>
 /// <exception cref="InvalidOperationException"><c>FillArc</c> was called, but <see cref="Begin()"/> has not yet been called.</exception>
 /// <remarks>The number of subdivisions in the arc is computed as <c>(radius / 1.5) * (arcAngle / 2PI)</c>.</remarks>
 public void FillArc (Brush brush, CCVector2 center, float radius, float startAngle, float arcAngle, ArcType arcType)
 {
     FillArc(brush, center, radius, startAngle, arcAngle, arcType, DefaultSubdivisions(radius));
 }
示例#17
0
 /// <summary>
 /// Adds a filled region enclosed by the given multisegment path to the batch of figures to be rendered.
 /// </summary>
 /// <param name="brush">The brush to render the shape with.</param>
 /// <param name="points">The list of points that make up the multisegment path enclosing the region.</param>
 /// <exception cref="InvalidOperationException"><c>FillPath</c> was called, but <see cref="Begin()"/> has not yet been called.</exception>
 /// <remarks>Paths should be created with a clockwise winding order, or the resulting geometry will be backface-culled.</remarks>
 public void FillPath (Brush brush, IList<CCVector2> points)
 {
     FillPath(brush, points, 0, points.Count);
 }
示例#18
0
        /// <summary>
        /// Adds a filled arc to the batch of figures to be rendered using up to the given number of subdivisions.
        /// </summary>
        /// <param name="brush">The brush to render the shape with.</param>
        /// <param name="center">The center coordinate of the arc.</param>
        /// <param name="radius">The radius of the arc.</param>
        /// <param name="startAngle">The starting angle of the arc in radians, where 0 is 3 O'Clock.</param>
        /// <param name="arcAngle">The sweep of the arc in radians.  Positive values draw clockwise.</param>
        /// <param name="arcType">Whether the arc is drawn as a segment or a sector.</param>
        /// <param name="subdivisions">The number of subdivisions in the circle with the same radius as the arc.</param>
        /// <exception cref="InvalidOperationException"><c>FillArc</c> was called, but <see cref="Begin()"/> has not yet been called.</exception>
        /// <remarks>The number of subdivisions in the arc is computed as <c>subdivisions * (arcAngle / 2PI)</c>.</remarks>
        public void FillArc (Brush brush, CCVector2 center, float radius, float startAngle, float arcAngle, ArcType arcType, int subdivisions)
        {
            if (!_inDraw)
                throw new InvalidOperationException();
            if (brush == null)
                throw new ArgumentNullException("brush");

            int vertexCount = BuildArcGeometryBuffer(center, radius, subdivisions, startAngle, arcAngle);

            RequestBufferSpace(vertexCount + 1, (vertexCount - 1) * 3);
            AddInfo(PrimitiveType.TriangleList, vertexCount + 1, (vertexCount - 1) * 3, brush);

            //int baseVertexIndex = _vertexBufferIndex;

            //for (int i = 0; i < vertexCount; i++)
            //    AddVertex(_geometryBuffer[i], brush);

            //switch (arcType) {
            //    case ArcType.Sector:
            //        AddVertex(new CCVector2(center.X, center.Y), brush);
            //        break;
            //    case ArcType.Segment:
            //        AddVertex(new CCVector2((_geometryBuffer[0].X + _geometryBuffer[vertexCount - 1].X) / 2, 
            //            (_geometryBuffer[0].Y + _geometryBuffer[vertexCount - 1].Y) / 2), brush); 
            //        break;
            //}

            //if (arcAngle < 0) {
            //    for (int i = 0; i < vertexCount - 1; i++)
            //        AddTriangle(baseVertexIndex + vertexCount, baseVertexIndex + i + 1, baseVertexIndex + i);
            //}
            //else {
            //    for (int i = vertexCount - 1; i > 0; i--)
            //        AddTriangle(baseVertexIndex + vertexCount, baseVertexIndex + i - 1, baseVertexIndex + i);
            //}

            //if (_sortMode == DrawSortMode.Immediate)
            //    FlushBuffer();
        }
示例#19
0
 private void AddInfo (PrimitiveType primitiveType, int vertexCount, int indexCount, Brush brush)
 {
     AddInfo(primitiveType, vertexCount, indexCount, brush != null ? brush.Texture : _defaultTexture);
 }
示例#20
0
 /// <summary>
 /// Adds a filled rectangle to the batch of figures to be rendered.
 /// </summary>
 /// <param name="brush">The brush to render the shape with.</param>
 /// <param name="rect">The rectangle to be rendered.</param>
 /// <exception cref="InvalidOperationException"><c>FillRectangle</c> was called, but <see cref="Begin()"/> has not yet been called.</exception>
 public void FillRectangle (Brush brush, Rectangle rect)
 {
     FillRectangle(brush, rect, 0);
 }
示例#21
0
 static Brush ()
 {
     Black = new SolidColorBrush(Color.Black);
     Blue = new SolidColorBrush(Color.Blue);
     Brown = new SolidColorBrush(Color.Brown);
     Cyan = new SolidColorBrush(Color.Cyan);
     DarkBlue = new SolidColorBrush(Color.DarkBlue);
     DarkCyan = new SolidColorBrush(Color.DarkCyan);
     DarkGoldenrod = new SolidColorBrush(Color.DarkGoldenrod);
     DarkGray = new SolidColorBrush(Color.DarkGray);
     DarkGreen = new SolidColorBrush(Color.DarkGreen);
     DarkMagenta = new SolidColorBrush(Color.DarkMagenta);
     DarkOrange = new SolidColorBrush(Color.DarkOrange);
     DarkRed = new SolidColorBrush(Color.DarkRed);
     Goldenrod = new SolidColorBrush(Color.Goldenrod);
     Gray = new SolidColorBrush(Color.Gray);
     Green = new SolidColorBrush(Color.Green);
     LightBlue = new SolidColorBrush(Color.LightBlue);
     LightCyan = new SolidColorBrush(Color.LightCyan);
     LightGray = new SolidColorBrush(Color.LightGray);
     LightGreen = new SolidColorBrush(Color.LightGreen);
     LightPink = new SolidColorBrush(Color.LightPink);
     LightYellow = new SolidColorBrush(Color.LightYellow);
     Lime = new SolidColorBrush(Color.Lime);
     Magenta = new SolidColorBrush(Color.Magenta);
     Orange = new SolidColorBrush(Color.Orange);
     Pink = new SolidColorBrush(Color.Pink);
     Purple = new SolidColorBrush(Color.Purple);
     Red = new SolidColorBrush(Color.Red);
     Teal = new SolidColorBrush(Color.Teal);
     White = new SolidColorBrush(Color.White);
     Yellow = new SolidColorBrush(Color.Yellow);
 }
示例#22
0
        /// <summary>
        /// Adds a filled rectangle to the batch of figures to be rendered.
        /// </summary>
        /// <param name="brush">The brush to render the shape with.</param>
        /// <param name="rect">The rectangle to be rendered.</param>
        /// <param name="angle">The angle to rotate the rectangle by around its center in radians.  Positive values rotate clockwise.</param>
        /// <exception cref="InvalidOperationException"><c>FillRectangle</c> was called, but <see cref="Begin()"/> has not yet been called.</exception>
        public void FillRectangle (Brush brush, Rectangle rect, float angle)
        {
            _geometryBuffer[0] = new CCVector2(rect.Left, rect.Top);
            _geometryBuffer[1] = new CCVector2(rect.Right, rect.Top);
            _geometryBuffer[2] = new CCVector2(rect.Right, rect.Bottom);
            _geometryBuffer[3] = new CCVector2(rect.Left, rect.Bottom);

            FillQuad(brush, _geometryBuffer, 0, angle);
        }
 private void HandleFillInvalidated(object sender, EventArgs e)
 {
     if (_fillBrush != null) {
         _fillBrush.Dispose();
         _fillBrush = null;
     }
 }
示例#24
0
 /// <summary>
 /// Adds a filled rectangle to the batch of figures to be rendered.
 /// </summary>
 /// <param name="brush">The brush to render the shape with.</param>
 /// <param name="location">The top-left corner of the rectangle.</param>
 /// <param name="width">The width of the rectangle.</param>
 /// <param name="height">The height of the rectangle.</param>
 /// <exception cref="InvalidOperationException"><c>FillRectangle</c> was called, but <see cref="Begin()"/> has not yet been called.</exception>
 public void FillRectangle (Brush brush, CCVector2 location, float width, float height)
 {
     FillRectangle(brush, location, width, height, 0);
 }
 protected virtual void InitializeResources(GraphicsDevice device)
 {
     if (_fillBrush == null && _data.Fill != null)
         _fillBrush = BrushFactory.Create(device, _data.Fill);
     if (_fillGlowBrush == null && _data.FillGlow != null)
         _fillGlowBrush = BrushFactory.Create(device, _data.FillGlow);
     if (_outlinePen == null && _data.Outline != null)
         _outlinePen = PenFactory.Create(device, _data.Outline);
     if (_outlineGlowPen == null && _data.OutlineGlow != null)
         _outlineGlowPen = PenFactory.Create(device, _data.OutlineGlow);
 }
示例#26
0
        /// <summary>
        /// Adds a filled rectangle to the batch of figures to be rendered.
        /// </summary>
        /// <param name="brush">The brush to render the shape with.</param>
        /// <param name="location">The top-left corner of the rectangle.</param>
        /// <param name="width">The width of the rectangle.</param>
        /// <param name="height">The height of the rectangle.</param>
        /// <param name="angle">The angle to rotate the rectangle by around its center in radians.  Positive values rotate clockwise.</param>
        /// <exception cref="InvalidOperationException"><c>FillRectangle</c> was called, but <see cref="Begin()"/> has not yet been called.</exception>
        public void FillRectangle (Brush brush, CCVector2 location, float width, float height, float angle)
        {
            _geometryBuffer[0] = location;
            _geometryBuffer[1] = new CCVector2(location.X + width, location.Y);
            _geometryBuffer[2] = new CCVector2(location.X + width, location.Y + height);
            _geometryBuffer[3] = new CCVector2(location.X, location.Y + height);

            FillQuad(brush, _geometryBuffer, 0, angle);
        }
示例#27
0
 /// <summary>
 /// Creates a new <see cref="Pen"/> with the given brush and width.
 /// </summary>
 /// <param name="brush">The <see cref="Brush"/> used to stroke the pen.</param>
 /// <param name="width">The width of the paths drawn by the pen.</param>
 /// <remarks>By default, the pen will not take resposibility for disposing the <see cref="Brush"/>.</remarks>
 public Pen (Brush brush, float width)
     : this(brush, width, false)
 { }
示例#28
0
 /// <summary>
 /// Adds a filled quadrilateral to the batch of figures to be rendered.
 /// </summary>
 /// <param name="brush">The brush to render the shape with.</param>
 /// <param name="points">An array containing the coordinates of the quad.</param>
 /// <param name="offset">The offset into the points array.</param>
 /// <exception cref="InvalidOperationException"><c>FillQuad</c> was called, but <see cref="Begin()"/> has not yet been called.</exception>
 public void FillQuad (Brush brush, CCVector2[] points, int offset)
 {
     FillQuad(brush, points, offset, 0);
 }
示例#29
0
 /// <summary>
 /// Creates a new <see cref="Pen"/> with the given brush and a width of 1.
 /// </summary>
 /// <param name="brush">The <see cref="Brush"/> used to stroke the pen.</param>
 /// <param name="ownsBrush"><c>true</c> if the pen should be responsible for disposing the <see cref="Brush"/>, <c>false</c> otherwise.</param>
 public Pen (Brush brush, bool ownsBrush)
     : this(brush, 1, ownsBrush)
 {
 }
示例#30
0
 /// <summary>
 /// Adds a filled ellipse path to the batch of figures to be rendered.
 /// </summary>
 /// <param name="brush">The brush to render the shape with.</param>
 /// <param name="bound">The bounding rectangle of the ellipse.</param>
 /// <param name="angle">The angle to rotate the ellipse by in radians.  Positive values rotate clockwise.</param>
 /// <exception cref="InvalidOperationException"><c>FillEllipse</c> was called, but <see cref="Begin()"/> has not yet been called.</exception>
 /// <remarks>The number of subdivisions in the ellipse is computed as max(width, height) / 3.0.</remarks>
 public void FillEllipse (Brush brush, CCRect bound, float angle)
 {
     FillEllipse(brush, new CCVector2(bound.Center.X, bound.Center.Y), bound.Size.Width / 2f, bound.Size.Height / 2f, angle);
 }