画心形玫瑰算法

hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
Graphics graphicsDraw(hWnd);
int iWide = 0;
SYSTEMTIME st;
GetSystemTime(&st);
srand((unsigned int)st.wMilliseconds);
//graphicsDraw.DrawImage(g_FileImageC.m_pFileImageVector[rand()%g_FileImageC.m_pFileImageVector.size()],rand()%GetSystemMetrics(SM_CXSCREEN),rand()%GetSystemMetrics(SM_CYSCREEN),iWide = rand()%100+80,iWide*3/4);
//Image img(L"2.png");
//graphicsDraw.DrawImage(g_FileImageC.m_pFileImageVector[1], 100,100);
int iRand = rand();
iWide = iRand%50+80;

RECT rt;
GetClientRect(hWnd, &rt);
static Bitmap bmp(rt.right, rt.bottom);
static Graphics graphicsBmp(&bmp);
static Graphics graphics(hWnd);

static double a = 150;
int x;
int y;
static double t=0;

if (iRand & 1)
{
if (t < 1 || t+1 >2*3.1415926)
{
t += 0.2;
}
t < 2*3.1415926 ? t += 0.1 : (t = 0);
if (t != 0)
{
y = (int)(a * (2*cos(t) - cos(2*t)));
x = (int)(a * (2*sin(t) - sin(2*t)));
y = rt.bottom-y- rt.bottom/2-150;
x = rt.right/2 + x;
graphicsBmp.DrawImage(g_FileImageC.m_pFileImageVector[iRand%g_FileImageC.m_pFileImageVector.size()],
x,y,iWide,(iWide*3/4));
}else
{
SolidBrush blackBrush(Color(255, 255, 255, 255));
graphicsBmp.FillRectangle(&blackBrush, 0, 0, rt.right, rt.bottom);
}
}else
{
//graphicsBmp.DrawImage(g_FileImageC.m_pFileImageVector[iRand%g_FileImageC.m_pFileImageVector.size()],
//rand()%GetSystemMetrics(SM_CXSCREEN),rand()%GetSystemMetrics(SM_CYSCREEN),iWide,(iWide*3/4));
}
//SolidBrush blackBrush(Color(255, 255, 255, 0));
//graphicsDraw.FillRectangle(&blackBrush, 0, 0, 500, 500);
graphics.DrawImage(&bmp, 0, 0);
EndPaint(hWnd, &ps);
break;

你可能感兴趣的:(小技巧)