zoukankan      html  css  js  c++  java
  • C++语言 线条的渐变

    void CSelRectDlg::OnPaint() 
    {
        if (IsIconic())
        {
            CPaintDC dc(this); // device context for painting
    
            SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
    
            // Center icon in client rectangle
            int cxIcon = GetSystemMetrics(SM_CXICON);
            int cyIcon = GetSystemMetrics(SM_CYICON);
            CRect rect;
            GetClientRect(&rect);
            int x = (rect.Width() - cxIcon + 1) / 2;
            int y = (rect.Height() - cyIcon + 1) / 2;
    
            // Draw the icon
            dc.DrawIcon(x, y, m_hIcon);
        }
        else
        {
            CPaintDC dc(this);
            CRect rc;
            this->GetWindowRect(rc);
            int y = rc.Height()/4;
            CPen pen, *oldpen;
            oldpen = dc.SelectObject(&pen);
            dc.MoveTo(0, y);
            dc.LineTo(0, y);
            for(int i=1;i<255;i++)
            {
                pen.DeleteObject();
                pen.CreatePen(PS_SOLID, 2, RGB(255, i, 0));
                dc.SelectObject(&pen);
                dc.LineTo(i, y);
            }
            dc.MoveTo(0, y*2);
            dc.LineTo(0, y*2);
            for(int m=1;m<255;m++)
            {
                pen.DeleteObject();
                pen.CreatePen(PS_SOLID, 2, RGB(0, 255,m));
                dc.SelectObject(&pen);
                dc.LineTo(m, y*2);
    
            }
            dc.MoveTo(0, y*3);
            dc.LineTo(0, y*3);
            for(int n=1;n<255;n++)
            {
                pen.DeleteObject();
                pen.CreatePen(PS_SOLID, 2, RGB(n, 0, 255));
                dc.SelectObject(&pen);
                dc.LineTo(n, y*3);
    
            }
            pen.DeleteObject();
            dc.SelectObject(oldpen);
    
            CDialog::OnPaint();
        }
    }
  • 相关阅读:
    1040 最大公约数之和(欧拉函数)
    1028 大数乘法 V2(FFT or py)
    1020 逆序排列(DP)
    1837 砝码称重
    1070 Bash游戏 V4
    1280 前缀后缀集合(map)
    1390 游戏得分(贪心)
    1179 最大的最大公约数
    1400 序列分解(dfs)
    1420 数袋鼠好有趣(贪心二分)
  • 原文地址:https://www.cnblogs.com/pythonschool/p/2781126.html
Copyright © 2011-2022 走看看