Fork me on GitHub 打赏

MFC绘图小实验(3)

1,使用默认的文本背景模式,在点(-200,20)处输出黄底红字“Computer Graphics Based on VC++”;在(50,20)处输出黄底红字“BoChuang Research Institute”;使用透明文本背景模式在(-200,-20)处输出黑色整数5和8;在(0,-20)处输出黑色双精度浮点数(5.2,8.3)。

    CRect rect;  //定义矩形
    GetClientRect(&rect);  //获得客户区矩形
    pDC->SetMapMode(MM_ANISOTROPIC);  //设置映射模式
    pDC->SetWindowExt(rect.Width(),rect.Height());  //设置窗口
    pDC->SetViewportExt(rect.Width(),-rect.Height());  //设置视区:x轴水平向右为正,y轴垂直向上为正
    pDC->SetViewportOrg(rect.Width()/2,rect.Height()/2);  //设置客户区中心为坐标系原点
    rect.OffsetRect(-rect.Width()/2,-rect.Height()/2);  //客户区矩形校正

    pDC->SetTextColor(RGB(255,0,0));  //字体颜色为红色
    pDC->SetBkColor(RGB(255,255,0));  //背景色:红+绿=黄
    pDC->TextOut(-200,20,"Computer Graphics Based on VC++");  //输出文本1
    CString data,str="BoChuang Research Institute";
    data.Format("%s",str);  //输出文本2
    pDC->TextOut(50,20,data);
    pDC->SetTextColor(RGB(0,0,0));
    pDC->SetBkMode(TRANSPARENT);  //设置背景模式,透明
    int i1=5,i2=8;
    double d1=5.2,d2=8.3;
    data.Format("%d,%d",i1,i2);  //输出整数
    pDC->TextOut(-200,-20,data);
    data.Format("%f,%f",d1,d2);  //输出小数
    pDC->TextOut(0,-20,data);

 

 

2,请使用同心椭圆和同心圆绘制一个图形。

    CRect rect;  //定义矩形
    GetClientRect(&rect);  //获得客户区矩形
    pDC->SetMapMode(MM_ANISOTROPIC);  //设置映射模式
    pDC->SetWindowExt(rect.Width(),rect.Height());  //设置窗口
    pDC->SetViewportExt(rect.Width(),-rect.Height());  //设置视区:x轴水平向右为正,y轴垂直向上为正
    pDC->SetViewportOrg(rect.Width()/2,rect.Height()/2);  //设置客户区中心为坐标系原点
    rect.OffsetRect(-rect.Width()/2,-rect.Height()/2);  //客户区矩形校正

    CPoint ld,rt;  //定义椭圆形外接矩形的左下角点与右上角点坐标
    /*绘制外部黑色椭圆*/
    ld=CPoint(-200,-150),rt=CPoint(200,150);
    CBrush NewBrush,*pOldBrush;
    NewBrush.CreateSolidBrush(RGB(0,0,0));
    pOldBrush=pDC->SelectObject(&NewBrush);
    pDC->Ellipse(CRect(ld,rt));
    pDC->SelectObject(pOldBrush);
    NewBrush.DeleteObject();
    /*绘制外部白色圆*/
    ld=CPoint(-147,-147),rt=CPoint(147,147);
    pDC->Ellipse(CRect(ld,rt));
    /*绘制内部黑色圆*/
    ld=CPoint(-140,-90),rt=CPoint(140,90);
    NewBrush.CreateSolidBrush(RGB(0,0,0));
    pOldBrush=pDC->SelectObject(&NewBrush);
    pDC->Ellipse(CRect(ld,rt));
    pDC->SelectObject(pOldBrush);
    NewBrush.DeleteObject();
    /*绘制内部白色圆*/
    ld=CPoint(-88,-88),rt=CPoint(88,88);
    pDC->Ellipse(CRect(ld,rt));

 

 

posted @ 2017-04-17 18:36  Zoctopus_Zhang  阅读(...)  评论(...编辑  收藏
// function btn_donateClick() { var DivPopup = document.getElementById('Div_popup'); var DivMasklayer = document.getElementById('div_masklayer'); DivMasklayer.style.display = 'block'; DivPopup.style.display = 'block'; var h = Div_popup.clientHeight; with (Div_popup.style) { marginTop = -h / 2 + 'px'; } } function MasklayerClick() { var masklayer = document.getElementById('div_masklayer'); var divImg = document.getElementById("Div_popup"); masklayer.style.display = "none"; divImg.style.display = "none"; } setTimeout( function () { document.getElementById('div_masklayer').onclick = MasklayerClick; document.getElementById('btn_donate').onclick = btn_donateClick; var a_gzw = document.getElementById("guanzhuwo"); a_gzw.href = "javascript:void(0);"; $("#guanzhuwo").attr("onclick","follow('33513f9f-ba13-e011-ac81-842b2b196315');"); }, 900);