日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

一些常规形几何形状的绘制和效果填充(二)

發布時間:2025/3/12 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 一些常规形几何形状的绘制和效果填充(二) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?源程序下載

(續)?????????visualsan@yahoo.cn?

?

我封裝了這兩個函數,使它的使用更容易:

1.繪制顏色漸變三角形,P1, P2, P3為三角形三個點,cP1, cP2, cP3為三角形三點所指定的顏色。

void ?DrawTriangle(CDC *pDC,POINT P1,POINT P2,POINT P3,

????????????? COLORREF cP1,COLORREF cP2,COLORREF cP3)

{

?????? TRIVERTEX??????? vert [4] ;

?????? vert [0] .x?????? =? P1.x;

?????? vert [0] .y?????? =? P1.y;

?????? vert [0].Red=GetRValue(cP1)<<8;

?????? vert [0].Green=GetGValue(cP1)<<8;

?????? vert [0].Blue=GetBValue(cP1)<<8;

?????? vert [0] .Alpha?? =? 0;

??????

?????? vert [1] .x?????? =? P2.x;

?????? vert [1] .y?????? =? P2.y;

?????? vert [1].Red=GetRValue(cP2)<<8;

?????? vert [1].Green=GetGValue(cP2)<<8;

?????? vert [1].Blue=GetBValue(cP2)<<8;

?????? vert [1] .Alpha?? = ?0;

??????

?????? vert [2] .x????? =? P3.x;

?????? vert [2] .y?????? =? P3.y;

?????? vert [2].Red=GetRValue(cP3)<<8;

?????? vert [2].Green=GetGValue(cP3)<<8;

?????? vert [2].Blue=GetBValue(cP3)<<8;

?????? vert [2] .Alpha?? =? 0;

??????

?????? _GRADIENT_TRIANGLE? gTRi[1];

??????

?????? gTRi[0].Vertex1?? = 0;

?????? gTRi[0].Vertex2?? = 1;

?????? gTRi[0].Vertex3?? = 2;

?????? handle_GradientFill(pDC->GetSafeHdc(),vert,4,&gTRi,1,GRADIENT_FILL_TRIANGLE);

}

2.繪制矩形,顏色漸變,其中falg指定漸變形式:

??????????? 0:左右漸變。

??????? ??? 1:上下漸變

??????????? 3:中心到左右兩邊漸變

??????????? 4:中心到上下漸變

????????????5:中心到四周實現漸變

void_DrawRect(CDC *pDC,CRect rect,COLORREF

??????????????????? nShadowBeginColor,COLORREF nShadowEndColor,int falg )

{

?????? TRIVERTEX rcVertex[2];

?????? rcVertex[0].x=rect.left;

?????? rcVertex[0].y=rect.top;

?????? rcVertex[0].Red=GetRValue(nShadowBeginColor)<<8;??????

????? rcVertex[0].Green=GetGValue(nShadowBeginColor)<<8;

?????? rcVertex[0].Blue=GetBValue(nShadowBeginColor)<<8;

?????? rcVertex[0].Alpha=0x0000;

?????? rcVertex[1].x=rect.right;

?????? rcVertex[1].y=rect.bottom;

?????? rcVertex[1].Red=GetRValue(nShadowEndColor)<<8;

?????? rcVertex[1].Green=GetGValue(nShadowEndColor)<<8;

?????? rcVertex[1].Blue=GetBValue(nShadowEndColor)<<8;

????? rcVertex[1].Alpha=0;

?

?????? GRADIENT_RECT rect1;

?????? rect1.UpperLeft=0;

????? rect1.LowerRight=1;

?????? if (falg==0)

????????????? handle_GradientFill( pDC->GetSafeHdc(),rcVertex,2,&rect1,1,??

???????????? GRADIENT_FILL_RECT_H);

?????? if (falg==1)

????????????? handle_GradientFill( pDC->GetSafeHdc(),rcVertex,2,&rect1,1,

???????????? GRADIENT_FILL_RECT_V );

?????? if (falg==3)

?????? {

????????????? rcVertex[0].x=rect.left;

????????????? rcVertex[0].y=rect.top;

????????????? rcVertex[0].Red=GetRValue(nShadowBeginColor)<<8;???

?? ????????? rcVertex[0].Green=GetGValue(nShadowBeginColor)<<8;

????????????? rcVertex[0].Blue=GetBValue(nShadowBeginColor)<<8;

????????????? rcVertex[0].Alpha=0x0000;

????????????? rcVertex[1].x=rect.right-rect.Width()/2;

????????????? rcVertex[1].y=rect.bottom;

????????????? rcVertex[1].Red=GetRValue(nShadowEndColor)<<8;

????????????? rcVertex[1].Green=GetGValue(nShadowEndColor)<<8;

????????????? rcVertex[1].Blue=GetBValue(nShadowEndColor)<<8;

????????? ?? rcVertex[1].Alpha=0;

????????????? handle_GradientFill(pDC->GetSafeHdc(),rcVertex,2,&rect1,1,?

????????????? GRADIENT_FILL_RECT_H);

????????????? rcVertex[0].x=rect.left+rect.Width()/2-1;

????????????? rcVertex[0].y=rect.top;

????????????? rcVertex[0].Red=GetRValue(nShadowEndColor)<<8;?????

???????? ???? rcVertex[0].Green=GetGValue(nShadowEndColor)<<8;

????????????? rcVertex[0].Blue=GetBValue(nShadowEndColor)<<8;

????????????? rcVertex[0].Alpha=0x0000;

????????????? rcVertex[1].x=rect.right;

????????????? rcVertex[1].y=rect.bottom;

????????????? rcVertex[1].Red=GetRValue(nShadowBeginColor)<<8;

????????????? rcVertex[1].Green=GetGValue(nShadowBeginColor)<<8;

????????????? rcVertex[1].Blue=GetBValue(nShadowBeginColor)<<8;

??????? ???? rcVertex[1].Alpha=0;

????????????? handle_GradientFill( pDC->GetSafeHdc(),rcVertex,2,&rect1,1,?

????????????? GRADIENT_FILL_RECT_H);

?????? }

?????? if (falg==4)

?????? {

????????????? rcVertex[0].x=rect.left;

????????????? rcVertex[0].y=rect.top;

??????????????rcVertex[0].Red=GetRValue(nShadowBeginColor)<<8;??????????????????????

???????????? ?rcVertex[0].Green=GetGValue(nShadowBeginColor)<<8;

????????????? rcVertex[0].Blue=GetBValue(nShadowBeginColor)<<8;

????????????? rcVertex[0].Alpha=0x0000;

????????????? rcVertex[1].x=rect.right;

????????????? rcVertex[1].y=rect.bottom-rect.Height()/2;

????????????? rcVertex[1].Red=GetRValue(nShadowEndColor)<<8;

????????????? rcVertex[1].Green=GetGValue(nShadowEndColor)<<8;

????????????? rcVertex[1].Blue=GetBValue(nShadowEndColor)<<8;

?????????? ?? rcVertex[1].Alpha=0;

????????????? handle_GradientFill(pDC->GetSafeHdc(),rcVertex,2,&rect1,1,?

???????????? ?GRADIENT_FILL_RECT_V);

????????????? rcVertex[0].x=rect.left;

????????????? rcVertex[0].y=rect.top-1+rect.Height()/2;

????????????? rcVertex[0].Red=GetRValue(nShadowEndColor)<<8;

????????????? rcVertex[0].Green=GetGValue(nShadowEndColor)<<8;

????????????? rcVertex[0].Blue=GetBValue(nShadowEndColor)<<8;

????????????? rcVertex[0].Alpha=0x0000;

????????????? rcVertex[1].x=rect.right;

????????????? rcVertex[1].y=rect.bottom;

????????????? rcVertex[1].Red=GetRValue(nShadowBeginColor)<<8;

????????????? rcVertex[1].Green=GetGValue(nShadowBeginColor)<<8;

????????????? rcVertex[1].Blue=GetBValue(nShadowBeginColor)<<8;

???????????? ?rcVertex[1].Alpha=0;

????????????? handle_GradientFill( pDC->GetSafeHdc(),rcVertex,2,&rect1,1,?

???????????? GRADIENT_FILL_RECT_V);

?????? }

?????? if (falg==MIDDLE_TO_SIDE)

?

?????? {

????????????? POINT p1,p2,p3,p4,p;

????????????? p1.x=rect.left;p1.y=rect.bottom;

????????????? p2.x=rect.right;p2.y=rect.bottom;

?

????????????? p3.x=rect.right;p3.y=rect.top;

????????????? p4.x=rect.left;p4.y=rect.top;

????????????? p=rect.CenterPoint();

????????????? _DrawTriangle (pDC,p1,p2,p,nShadowEndColor,nShadowEndColor,nShadowBeginColor);

????????????? DrawTriangle(pDC,p2,p3,p,nShadowEndColor,nShadowEndColor,nShadowBeginColor);

????????????? DrawTriangle(pDC,p3,p4,p,nShadowEndColor,nShadowEndColor,nShadowBeginColor);

????????????? DrawTriangle(pDC,p4,p1,p,nShadowEndColor,nShadowEndColor,nShadowBeginColor);

?????? }

??????

}

填充效果如下:

?

總結

以上是生活随笔為你收集整理的一些常规形几何形状的绘制和效果填充(二)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。