Пример #1
0
 /// <summary>
 /// 使用指定的渐变色和方向填充一个矩形 Fills the rectagle with gradient colors
 /// </summary>
 /// <param name="gx">Destination graphics</param>
 /// <param name="rc">Desctination rectangle</param>
 /// <param name="startColorValue">Starting color for gradient</param>
 /// <param name="endColorValue">End color for gradient</param>
 /// <param name="fillDirection">The direction of the gradient</param>
 public static void FillGradientRectangle(this Graphics gx, Rectangle rc, Color startColorValue, Color endColorValue, FillDirection fillDirection)
 {
     GradientFill.Fill(
         gx,
         rc,
         startColorValue,
         endColorValue,
         fillDirection);
 }
Пример #2
0
        /// <summary>
        /// 返回指定渐变色和方向的填充矩形
        /// </summary>
        /// <param name="rc">Destination rectangle</param>
        /// <param name="startColorValue">Starting color for gradient</param>
        /// <param name="endColorValue">End color for gradient</param>
        /// <param name="fillDirection">The direction of the gradient</param>
        /// <returns>Image of the rectanle</returns>
        public static Bitmap GetGradientRectangle(Rectangle rc, Color startColorValue, Color endColorValue, FillDirection fillDirection)
        {
            Bitmap outputImage = new Bitmap(rc.Width, rc.Height);
            // Create temporary graphics
            Graphics gx = Graphics.FromImage(outputImage);

            GradientFill.Fill(
                gx,
                rc,
                startColorValue,
                endColorValue,
                fillDirection);

            return(outputImage);
        }