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),那么渐变的起始颜色,是从三分之一处开始的

    如下图

  • 相关阅读:
    golang访问数据库
    dynamic与泛型
    新的published和$M+对比
    插入窗体到别的程序里
    淺談怎么样运用Delphi 2009地泛型容器類別
    Delphi随记
    查找文件
    Delphi操作xml
    Delphi图像编程学习笔记
    Ext.net中如何上传文件
  • 原文地址:https://www.cnblogs.com/chucklu/p/6382025.html
Copyright © 2011-2022 走看看