April 19, 2024, 09:26:38 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Cool Graphic

Started by redea30591, April 11, 2006, 03:29:54 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

redea30591

DECLARE IMPORT,GetSystemMetrics(nIndex as INT),INT;

class DrawWnd : CWindow
{
int sx, sy;
float ang;
int r,g,b;

declare OnCreate(),int;
declare OnClose(),int;
declare OnLButtonDown(int x,int y,int flags),int;
declare OnTimer(int nIDEvent),int;
}

int run;

global sub main()
{
run = 1;
DrawWnd win;

win.Create(0,0,640,480,AWS_CAPTION|AWS_SYSMENU|AWS_BORDER|AWS_SIZE|AWS_MINIMIZEBOX|
AWS_MAXIMIZEBOX|AWS_MAXIMIZE|AWS_AUTODRAW,0,"Simple Paint",0);

do {wait(); }until run = 0;
return 0;

}

//our windows message handlers
DrawWnd::OnCreate(),int
{
sx = (sin(0) * 30) + 100;
sy = (cos(0) * 30) + 100;
r = 20;
g = 60;
b = 20;
ang = 0;
StartTimer(10);
return true;
}

DrawWnd::OnClose(),int
{
StopTimer();
run = 0;
return true;
}

DrawWnd::OnLButtonDown(int x, int y, int flags), int
{
line(sx, sy, x,y);
sx = x;
sy = y;
return 0;
}

DrawWnd::OnTimer(int nIDEvent),int
{
int x,y;
int w,h;

g = g + rnd(50);
        b = b + rnd(50);
r = r + 1;
if (g > 255) g = 20;
    if (b > 255) b = 20;
    if (r > 255) r = 20;
x = (sin(ang) * (30 + rnd(20))) + 100;
y = (cos(ang) * (30 + rnd(20))) + 100;

w = GetSystemMetrics(0);
h = GetSystemMetrics(1);

line(sx,sy,x,y,RGB(r,g,b));
sx = x;
sy = y;
ang = ang + 0.01;

if (ang > 359) ang = 0;

return true;
}


Nothing Fancy, just a 37k Program that draws a cute graphic to demonstrate Aurora Compiler....