• 绘图一


    1.定义点函数:

    SetPixel(hDC,x,y,crColor); hDC为句柄,x,y为点坐标,crColor为颜色。

    GetPixel(hDC,x,y)获取该点的像素点;

    COLORREF crColor = GetPixel(hDC,x,y);

    2.画直线:

    a.利用MoveToEx函数和LineTo函数:

    MoveToEx(hDC, x, y,NULL);//定义一个点,起点

    LineTo(hDC,xEnd,yEnd); //连线到终点

    b.利用Polyline函数:

    //产生个矩阵

    POINT apt[5]={100,100,200,100,200,200,100,200,100,100};

    MoveToEx(hDC,apt[0].x,apt[0].y,NULL);

    (1).for (int i=1;i<5;i++) LineTo(hDC,apt[i].x,apt[i].y);

    (2).Polyline(hDC,apt,5);

    (3).MoveToEx(hDC,apt[0].x,apt[0].y,NULL)'

          PolylineTo(hDC,apt+1,5);

    (4).Rectangle(hDC,xLeft,yTop,xRight,yBottom);

    //产生圆

    Ellipse(hDC,xLeft,yTop,xRight,yBottom);

    //圆角矩阵

    RoundRect(hDC,xLeft,yTop,xRight,yBottom,xCornerEllipse,yCornerEllipse);

    //弧形

    Arc(hDC,xLeft,yTop,xRight,yBottom,xStart,yStart,xEnd,yEnd);

    //椭圆弓形

    Chord(hDC,xLeft,yTop,xRight,yBottom,xStart,yStart,xEnd,yEnd);

    //扇形

    Pie(hDC,xLeft,yTop,xRight,yBottom,xStart,yStart,xEnd,yEnd);

    3.彩图:

    (1).创建画笔:CreatePen函数和CreatePenIndirect函数

            hPen = CreatePen(iPenStyle, iWidth, crColor);

      (2)选择画笔: SelectObject(hDc,hPen1);

     (3)删除画笔: DeleteObject(hPen1);    

    case WM_PAINT:

    HDC hDC;

    PAINTSTRUCT ps;

    HPEN hPen;//定义画笔

    hDC=BeginPaint(hwnd,&ps);

    LOGPEN logpen;//定义逻辑画笔

    logpen.lopnStyle = PS_SOLID;//设置线型为实线

    logpen.lopnWidth.x = 3; //设置画笔宽度

    logpen.lopnColor = RGB(255,0,0);//设置直线为红色

    hPen = CreatePenIndirect(&logpen);//

    SelectObject(hDC,hPen);//选择画笔

    Rectangle(hDC,100,100,300,300);//画矩阵

    EndPaint(hwnd,&ps);

    DeleteObject(hPen);//删除画笔

    break;

    4.颜色定义:

    a.COLORREF RGB{

    BYTEbyRed,

    BYTEbyGreen,

    BYTEbyBlue

    };

    调用方法为:COLORREF color = RGB(0,255,0)表示为绿色

    b. RGB_value struct{

    byte unused;

    byte blue;

    byte green;

    byte red;}

  • 相关阅读:
    源码安装mysql-5.7.13一周的冤枉路总结。满满的都是泪啊
    一键安装Apache服务脚本
    源码编译安装LAMP
    Vue侦听器 watch
    Vue计算属性 computed
    Vue表单的值绑定和修饰符
    js编码解码decodeURI(URIstring)与decodeURIComponent(URIstring)的区别
    常用的JS表单验证
    js正则表达式匹配手机号中间四位以及匹配姓名第一个字符,将其替换为*
    Vue按键修饰符,鼠标按钮修饰符
  • 原文地址:https://www.cnblogs.com/xy95/p/5742752.html
Copyright © 2020-2023  润新知