Exemplo n.º 1
0
 /// <summary>
 /// Paints the interior of the specified rectangle</summary>
 /// <param name="rect">Rectangle to paint, in pixels</param>
 /// <param name="brush">The brush used to paint the rectangle's interior</param>
 public void FillRectangle(RectangleF rect, D2dBrush brush)
 {
     m_renderTarget.FillRectangle(rect.ToSharpDX(), brush.NativeBrush);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Paints the interior of the specified rectangle with a smooth color gradient</summary>
 /// <param name="rect">Rectangle to paint, in pixels</param>
 /// <param name="pt1">The point, in pixels, that color1 gets mapped to</param>
 /// <param name="pt2">The point, in pixels, that color2 gets mapped to</param>
 /// <param name="color1">The color to use at the first point</param>
 /// <param name="color2">The color to use at the second point</param>
 /// <remarks>Note that each color combination is used to create a brush that
 /// is cached, so you cannot use an unlimited number of color combinations.</remarks>
 public void FillRectangle(RectangleF rect, PointF pt1, PointF pt2, Color color1, Color color2)
 {
     var brush = GetCachedLinearGradientBrush(color1, color2);
     brush.StartPoint = pt1.ToSharpDX();
     brush.EndPoint = pt2.ToSharpDX();
     m_renderTarget.FillRectangle(rect.ToSharpDX(), brush);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Draws a solid rectangle with the specified brush while using the alpha channel of the given
 /// bitmap to control the opacity of each pixel.</summary>
 /// <param name="opacityMask">The opacity mask to apply to the brush. The alpha value of
 /// each pixel in the region specified by sourceRectangle is multiplied with the alpha value
 /// of the brush after the brush has been mapped to the area defined by destinationRectangle.</param>
 /// <param name="brush">The brush used to paint the region of the render target specified by destinationRectangle.</param>
 /// <param name="destRect">The region of the render target to paint, in device-independent pixels.</param>
 /// <param name="sourceRect">The region of the bitmap to use as the opacity mask, in device-independent pixels.</param>
 public void FillOpacityMask(D2dBitmap opacityMask, D2dBrush brush, RectangleF destRect, RectangleF sourceRect)
 {
     m_renderTarget.FillOpacityMask(opacityMask.NativeBitmap, brush.NativeBrush,
                                    OpacityMaskContent.Graphics,
                                    destRect.ToSharpDX(), sourceRect.ToSharpDX());
 }
Exemplo n.º 4
0
 /// <summary>
 /// Draws the outline of a rectangle that has the specified dimensions and stroke style</summary>
 /// <param name="rect">The dimensions of the rectangle to draw, in pixels</param>
 /// <param name="brush">The brush used to paint the rectangle's stroke</param>
 /// <param name="strokeWidth">A value greater than or equal to 0.0f that specifies the width 
 /// of the rectangle's stroke. The stroke is centered on the rectangle's outline.</param>
 /// <param name="strokeStyle">The style of stroke to paint or null to draw a solid line</param>
 public void DrawRectangle(RectangleF rect, D2dBrush brush, float strokeWidth = 1.0f, D2dStrokeStyle strokeStyle = null)
 {
     m_renderTarget.DrawRectangle(rect.ToSharpDX(), brush.NativeBrush, strokeWidth,
         strokeStyle != null ? strokeStyle.NativeStrokeStyle : null);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Draws the specified bitmap after scaling it to the size of the specified rectangle</summary>
 /// <param name="bmp">The bitmap to render</param>
 /// <param name="destRect">The size and position, in pixels, in the D2dGraphics's coordinate
 /// space, of the area in which the bitmap is drawn. If the rectangle is not well-ordered,
 /// nothing is drawn, but the D2dGraphics does not enter an error state.</param>
 /// <param name="opacity">A value between 0.0f and 1.0f, inclusive, that specifies an opacity value        
 /// to apply to the bitmap. This value is multiplied against the alpha values
 /// of the bitmap's contents.</param>
 /// <param name="interpolationMode">The interpolation mode to use if the bitmap is scaled or rotated 
 /// by the drawing operation</param>
 /// <param name="sourceRect">The size and position, in pixels in the bitmap's coordinate space, of the area
 /// within the bitmap to draw</param>
 public void DrawBitmap(D2dBitmap bmp, RectangleF destRect, float opacity,
     D2dBitmapInterpolationMode interpolationMode, RectangleF sourceRect)
 {
     m_renderTarget.DrawBitmap(bmp.NativeBitmap, destRect.ToSharpDX(), opacity,
         (BitmapInterpolationMode)interpolationMode, sourceRect.ToSharpDX());
 }
Exemplo n.º 6
0
 /// <summary>
 /// Draws the specified bitmap after scaling it to the size of the specifiedrectangle</summary>
 /// <param name="bmp">The bitmap to render</param>
 /// <param name="destRect">The size and position, in pixels, in the D2dGraphics's coordinate
 /// space, of the area in which the bitmap is drawn. If the rectangle is not well-ordered,
 /// nothing is drawn, but the D2dGraphics does not enter an error state.</param>
 /// <param name="opacity">A value between 0.0f and 1.0f, inclusive, that specifies an opacity value        
 /// to apply to the bitmap. This value is multiplied against the alpha values
 /// of the bitmap's contents.</param>
 /// <param name="interpolationMode">The interpolation mode to use if the bitmap is scaled or rotated 
 /// by the drawing operation</param>
 public void DrawBitmap(D2dBitmap bmp, RectangleF destRect, float opacity = 1.0f, D2dBitmapInterpolationMode interpolationMode = D2dBitmapInterpolationMode.Linear)
 {
     m_renderTarget.DrawBitmap(bmp.NativeBitmap, destRect.ToSharpDX(), opacity, (BitmapInterpolationMode)interpolationMode, null);
 }
Exemplo n.º 7
0
 /// <summary>    
 /// Specifies a rectangle to which all subsequent drawing operations are clipped</summary>
 /// <remarks>The clipRect is transformed by the current world transform set on the render target.
 /// After the transform is applied to the clipRect that is passed in, the axis-aligned 
 /// bounding box for the clipRect is computed. For efficiency, the contents are clipped 
 /// to this axis-aligned bounding box and not to the original clipRect that is passed in.</remarks>    
 /// <param name="clipRect">The size and position of the clipping area, in pixels</param>
 /// <param name="antialiasMode">The antialiasing mode that is used to draw the edges of clip rects that have subpixel 
 /// boundaries, and to blend the clip with the scene contents. The blending is performed 
 /// once when the PopAxisAlignedClip method is called, and does not apply to each 
 /// primitive within the layer.</param>        
 public void PushAxisAlignedClip(RectangleF clipRect, D2dAntialiasMode antialiasMode)
 {
     m_clipStack.Push(clipRect);
     m_renderTarget.PushAxisAlignedClip(clipRect.ToSharpDX(), (AntialiasMode)antialiasMode);
 }