zoukankan      html  css  js  c++  java
  • System.Drawing.Drawing2D.LinearGradientBrush

    https://msdn.microsoft.com/en-us/library/system.drawing.drawing2d.lineargradientbrush(v=vs.110).aspx

    横向渐变

    LinearGradientBrush linGrBrush = new LinearGradientBrush(
          new Point(0, 10),
          new Point(200, 10),
          Color.FromArgb(255, 255, 0, 0),   // Opaque red
          Color.FromArgb(255, 0, 0, 255));  // Opaque blue
    
                Pen pen = new Pen(linGrBrush);
    
                //public void DrawLine(Pen pen, int x1, int y1, int x2, int y2);
                e.Graphics.DrawLine(pen, 0, 10, 200, 10);
    
                //public void FillEllipse(Brush brush, int x, int y, int width, int height);
                //x,y是矩形的左上角的点的坐标,然后是宽和高。在矩形内部画椭圆
                e.Graphics.FillEllipse(linGrBrush, 0, 30, 200, 100);
    
                //public void FillRectangle(Brush brush, int x, int y, int width, int height);
                e.Graphics.FillRectangle(linGrBrush, 0, 155, 500, 30);

     new Point(0, 10), new Point(200, 10),

    new Point(0, 10),  new Point(100, 10),

    纵向渐变

      LinearGradientBrush linGrBrush = new LinearGradientBrush(
          new Point(0, 0),
          new Point(0, 30),
          Color.FromArgb(255, 255, 0, 0),   // Opaque red
          Color.FromArgb(255, 0, 0, 255));  // Opaque blue
    
                Pen pen = new Pen(linGrBrush);
    
                //public void DrawLine(Pen pen, int x1, int y1, int x2, int y2);
                e.Graphics.DrawLine(pen, 100, 0, 100, 30);
    
                //public void FillEllipse(Brush brush, int x, int y, int width, int height);
                //x,y是矩形的左上角的点的坐标,然后是宽和高。在矩形内部画椭圆
                e.Graphics.FillEllipse(linGrBrush, 0, 60, 200, 120);
    
                //public void FillRectangle(Brush brush, int x, int y, int width, int height);
                e.Graphics.FillRectangle(linGrBrush, 0, 210, 500, 30);

    需要注意的是,纵向的渐变,是从坐标0开始的,而不是图形的0开始

    假如最后一个矩形,左上角坐标改为(0,190),那么渐变的起始颜色,是从三分之一处开始的

    如下图

  • 相关阅读:
    判断开始时间不能小于结束时间
    angular1.0使用echarts点刷新再次调用echarts方法
    解决angular4.0打包后不能再继续打包
    html拼接+layer按钮
    angular.js+echarts
    nginx配置
    NET_Framework_4.0installer.rar
    IIS6.0开启gzip压缩
    IIS的应用程序池优化方法
    远程桌面连接电脑后键盘失灵解决
  • 原文地址:https://www.cnblogs.com/chucklu/p/6382025.html
Copyright © 2011-2022 走看看