Пример #1
0
 /// <summary>
 /// 使用渐变色渲染一个图形区域
 /// </summary>
 /// <param name="g">The g.</param>
 /// <param name="path">The path.</param>
 /// <param name="rect">The rect.</param>
 /// <param name="color">The color.</param>
 /// User:Ryan  CreateTime:2012-8-6 21:27.
 public static void FillPath(Graphics g, GraphicsPath path, Rectangle rect, GradientColor color)
 {
     using (LinearGradientBrush brush = new LinearGradientBrush(rect, color.First, color.Second, LinearGradientMode.Vertical))
     {
         brush.Blend.Factors   = color.Factors;
         brush.Blend.Positions = color.Positions;
         g.FillPath(brush, path);
     }
 }
Пример #2
0
        /// <summary>
        /// 渲染一个矩形区域(渐变色)
        /// Fills the rectangle.
        /// </summary>
        /// <param name="g">The g.</param>
        /// <param name="rect">The rect.</param>
        /// <param name="color">The color.</param>
        /// User:Ryan  CreateTime:2012-8-3 21:25.
        public static void FillRectangle(Graphics g, Rectangle rect, GradientColor color)
        {
            if (rect.Width <= 0 || rect.Height <= 0 || g == null)
            {
                return;
            }

            using (LinearGradientBrush brush = new LinearGradientBrush(rect, color.First, color.Second, LinearGradientMode.Vertical))
            {
                brush.Blend.Factors   = color.Factors;
                brush.Blend.Positions = color.Positions;
                g.FillRectangle(brush, rect);
            }
        }
Пример #3
0
        /// <summary>
        /// 渲染一个圆角矩形区域(渐变色)
        /// Fills the rectangle.
        /// </summary>
        /// <param name="g">The g.</param>
        /// <param name="roundRect">The round rect.</param>
        /// <param name="color">The color.</param>
        /// User:Ryan  CreateTime:2012-8-3 21:45.
        public static void FillRectangle(Graphics g, RoundRectangle roundRect, GradientColor color)
        {
            if (roundRect.Rect.Width <= 0 || roundRect.Rect.Height <= 0)
            {
                return;
            }

            using (GraphicsPath path = roundRect.ToGraphicsBezierPath())
            {
                using (LinearGradientBrush brush = new LinearGradientBrush(roundRect.Rect, color.First, color.Second, LinearGradientMode.Vertical))
                {
                    brush.Blend.Factors   = color.Factors;
                    brush.Blend.Positions = color.Positions;
                    g.FillPath(brush, path);
                }
            }
        }
Пример #4
0
        /// <summary>
        /// 渲染圆角矩形区域(级渲染)
        /// </summary>
        /// <param name="g">The Graphics.</param>
        /// <param name="roundRect">The RoundRectangle.</param>
        /// <param name="color1">The color1.</param>
        /// <param name="color2">The color2.</param>
        /// <param name="blend">色彩混合渲染方案</param>
        /// User:K.Anding  CreateTime:2011-7-20 23:27.
        public static void FillPath(Graphics g, RoundRectangle roundRect, Color color1, Color color2, Blend blend)
        {
            GradientColor color = new GradientColor(color1, color2, blend.Factors, blend.Positions);

            GDIHelper.FillRectangle(g, roundRect, color);
        }