#include <windows.h>
#define rnd(x) (double)((rand()/32767.0)*(double)x)
// winnow app
void line(HDC dc,int x,int y,int x2,int y2,COLORREF color)
{
MoveToEx(dc,x,y,0);
HPEN pen = (HPEN)SelectObject(dc, CreatePen(0,1,color));
LineTo(dc,x2,y2);
DeleteObject(SelectObject(dc,pen));
}
int WINAPI WinMain (HINSTANCE hThisInstance,HINSTANCE hPrevInstance,LPSTR lpszArgument,int nFunsterStil)
{
float rise, rad, frad, xshorten;
int left, top, width, height, bpx, bpy, tpx, tpy;
int x1, y1, x2, y2, aa;
RECT rc = {20, 5, 440, 460};
HDC dc = GetDC(0);
COLORREF brown = RGB(130, 100, 0);
COLORREF green = RGB(0, 80+(int)rnd(40), 0);
HBRUSH br = CreateSolidBrush(RGB(255,235,190));
FillRect(dc,&rc,br);
DeleteObject(br);
//== GROW ===================
bpx=220; bpy=410; tpx=bpx;
for (aa=-4; aa<=4; aa++)
{
line(dc, bpx+aa, bpy, bpx, bpy-390, brown);
}
rad=160; tpy=bpy-40;
for (int ht=1; ht<=40; ht++)
{
for (int xs=-100; xs<=100; xs+=40)
{
xshorten=xs/100.0;
rise=rnd(.3);
line(dc, tpx, tpy, (int)(tpx+(xshorten*rad)), (int)(tpy-rise*rad), RGB(0,80+(int)rnd(40),0));
for (aa=1; aa<=30; aa++)
{
frad = rnd(.9)*rad;
x1 = (int)(tpx+(xshorten*frad));
y1 = (int)(tpy-rise*frad);
x2 = (int)(tpx+xshorten*(frad+rad/5));
y2 = (int)(tpy-rise*frad+(-rise+(rnd(.8)-.4)) * (rad/5));
line(dc, x1, y1, x2, y2, RGB(0, 80+(int)rnd(40), 0));
}
}
rad-=4; tpy-=9;
}
ReleaseDC(0,dc);
return 0;
} |