如何用渐变的颜色填充?有一系列的矩形,每个矩形用一个变量z代表该点处的高度,希望根据z的最大值设定一种颜色,最小值设定另一种颜色,根据矩形的z值填充过渡色,有没有什么函数能够直接实现,那有这样的例子?

解决方案 »

  1.   

    根据z画不同颜色的n条线
    CreatePen(RGB(z,z,z))
    SelectObject()
    MoveTo()
    LineTo()
    DeleteObject()
      

  2.   

    Need 98/2000/xp or laterBOOL GradientFill(
      HDC hdc,                   // handle to DC
      PTRIVERTEX pVertex,        // array of vertices
      ULONG dwNumVertex,         // number of vertices
      PVOID pMesh,               // array of gradients
      ULONG dwNumMesh,           // size of gradient array
      ULONG dwMode               // gradient fill mode
    ); Turn to MSDN for more help