This is a conversion of LarryA's christmas tree program. Hope he doesn't mind ;)
/*IBasic Professional example program
By LarryA
Compile as a WINDOWS target
Converted to Aurora by Paul.
*/
#autodefine "off"
class treewindow : window
{
declare OnClose(),int;
}
int run;
DEF cacheDC,brown,green as unsigned int;
DEF rise, rad, frad, xshorten as float;
DEF left, top, width, height, bpx, bpy, tpx, tpy as int;
DEF x1, y1, x2, y2, xs, aa, ht as int;
DEF rcClient as RECT;
global sub main()
{
DEF w as treewindow;
run = 1;
w.Create(20, 5, 440, 460, AWS_CAPTION | AWS_SYSMENU | AWS_AUTODRAW | AWS_VISIBLE | AWS_BORDER, 0, "Merry Christmas", 0);
w.setwindowcolor(rgb(255,235,190));
w.drawmode(1);
brown=rgb(130, 100, 0);
green=rgb(0, 80+rnd(40), 0) ;
//== GROW ===================
cacheDC = w.GetHDC();
bpx=220;
bpy=410;
tpx=bpx;
for( aa=-4 ;aa<= 4 ;aa++)
{
w.line(bpx+aa, bpy, bpx, bpy-390, brown);
}
rad=160; tpy=bpy-40;
for( ht=1; ht <= 40; ht++)
{
for( xs=-100; xs <= 100; xs+=40)
{
xshorten=xs/100.0;
rise=rnd(.3);
w.line(tpx, tpy, tpx+(xshorten*rad), tpy-rise*rad, rgb(0,80+rnd(40),0));
for( aa=1;aa<=30;aa++)
{
frad=rnd(.9)*rad ;
x1=tpx+(xshorten*frad);
y1=tpy-rise*frad;
x2=tpx+xshorten*(frad+rad/5);
y2=tpy-rise*frad + (-rise+(rnd(.8)-0.4f))*(rad/5);
w.line(x1, y1, x2, y2, rgb(0, 80+rnd(40), 0));
}
}
rad=rad-4 ; tpy=tpy-9 ;
}
w.ReleaseHDC(cacheDC);
//== DECORATE ======================
rad=160 ; tpy=bpy-50 ;
for( ht=1; ht <= 37; ht++)
{
w.circle(tpx+rnd(2*rad)-rad, tpy+rnd(6)-3, 5, rgb(255,0,0),rgb(255,0,0));
rad=rad-4 ; tpy=tpy-9;
}
//== DRAW BORDER ===========================
rcClient = w.getclientRect();
w.setlinestyle(lssolid, 3);
left = rcClient.left;
top = rcClient.top;
width = rcClient.right - rcClient.left;
height = rcClient.bottom - rcClient.top;
w.DrawRect(left+2, top+2, width-4, height-4, rgb(255,0,0));
w.DrawRect(left+5, top+5, width-10, height-10, rgb(0,120,0));
w.DrawRect(left+8, top+8, width-16, height-16, rgb(0,120,0));
w.DrawRect(left+11, top+11, width-22, height-22, rgb(255,0,0));
//== GREETING ==============================
w.setfont("times", 14, 700, 1);//1 = SFITALIC
w.frontpen(rgb(0,120,0));
w.WriteText(left+30, top+20, "Merry");
w.WriteText(left+20, top+50, "Christmas");
do{ wait(); }until run = 0;
w.Destroy();
return 0;
}
treewindow::OnClose(),int
{
run = 0;
RETURN true;
}
The original was written on IBasic Standard. Converted to Pro and now to Aurora. It compiles here fine, however, your mileage may vary. My libraries are always a step ahead of the last update, but I think I have it right ;)
Paul.
Don't mind at all... flattered. :)
The IBasic Standard version was kinda neat in that it was just slow enough (at least on the PC I had at the time) to see the individual branches and needles being drawn (always different... 37 trillion-gzillion to one odds of ever drawing the same tree).
IBasic Pro version was just... BAM... the picture appeared complete like a jpeg would. Guess it needs some kinda specific time delay in it between each line drawn.
Merry Christmas.
Welcome to our forums. And thanks ;)