|
Post by PeterMaria on May 19, 2016 10:26:00 GMT -5
Hello, a bodybuilder in action.
textmode(TEXT_BUFFERED) locate 2,0 : print "WAIT....." drawtext() glMatrixMode (GL_PROJECTION) glLoadIdentity() glOrtho(0,windowwidth(),windowheight(),0,-1,1) glMatrixMode (GL_MODELVIEW) glDisable(GL_DEPTH_TEST)
Sub Line(x0, y0, x1, y1, lsize#) glLinewidth(lsize#) glBegin(GL_LINES) glVertex2i(x0, y0) glVertex2i(x1, y1) glEnd() End Sub
Function Rand(min,max) Return rnd()% (max - min + 1) + min End Function
dim sa# = 35, sf# = 0.75 dim sizeH = windowwidth(), SizeV = windowheight(), depth, sf Sub DrawTree(x1#, y1#, s#, theta#, depth) dim x2#, y2# x2# = x1# + cos(theta#) * s# y2# = y1# + sin(theta#) * s# glcolor3ub(255, 255, 255) line(x2#, y2#, x1#, y1#, 1) line(x1#, y1#, x2#, y2#, 1) if depth <=0 then return: endif DrawTree(x2#, y2#, s# * sf#, theta# - sa#, depth - 1) DrawTree(x2#, y2#, s# * sf#, theta# + sa#, depth - 1) End Sub
Sub BodyTree(ax, ay, bx, by , rc) dim red,grn,blu dim cx=0,cy=0,dx=0,dy=0,ex=0,ey=0 cx = ax-ay+by cy = ax+ay-bx dx = bx+by-ay dy = ax-bx+by ex = 0.5*(cx-cy+dx+dy) ey = 0.5*(cx+cy-dx+dy) red = rand(0,200)+55: grn = rand(0,100)+155 : blu = rand(0,200)+55 glcolor3ub(red, grn, blu) line(cx, cy, ax, ay, 1) line(ax, ay, bx, by, 1) line(bx, by, dx, dy, 1) line(dx, dy, cx, cy, 1) line(cx, cy, ex, ey, 1) line(ex, ey, dx, dy, 1) if rc <22 then BodyTree(cx, cy, ex, ey, rc+rand(0,4)+sf) BodyTree(ex, ey, dx, dy, rc+rand(0,4)+sf) endif End Sub
BodyTree( sizeH/2 - sizeH/12, sizeV-40,sizeH /2 + sizeH/12, sizeV-40, 0) swapbuffers()
|
|
|
Post by matthew on Jun 14, 2016 14:20:15 GMT -5
Nice Pythagoras Tree, Peter. There's a version here which changes shape when you move your mouse.
|
|