|
Post by PeterMaria on Dec 14, 2015 8:46:19 GMT -5
Hello, TextMode(TEXT_BUFFERED) ResizeSpriteArea(512,512)
declare Function Rand(min,max) declare Sub Text(id(),x1,y1,txt$,w1,h1)
dim f(58)= LoadImageStrip("fonts/charstrip.png") dim w=512, h=512, x#, y#, c dim bx#, by#, gx#, gy#, zx#, zy#, nzx# dim sx#=-2.2, sy#=-1.7, sw#=3.4, sh#=3.4
while scankeydown(27)=0 cls for x#=0 to h step 8 for y#=0 to w step 8 gx# = x#/w*sw#+sx# gy# = y#/h*sh#+sy# zx# = gx# zy# = gy# for c=0 to 256 nzx# = zx#*zx# - zy#*zy# + gx# zy# = 2*zx#*zy#+gy# zx# = nzx# if zx#*zx# + zy#*zy# >8 then text(f,x#,y#,chr$(42),8,8) goto n end if next n: next next drawtext() waittimer(20) clearsprites() wend Function Rand(min,max) Return rnd()% (max - min + 1) + min End Function
Sub Text(id(),x1,y1,txt$,w1,h1) dim sx, jx, px sx = Len(txt$) for jx=1 to sx px = Asc(Mid$(txt$,jx,1)) if px >=32 and px <=127 then px = px-32 NewSprite(id) SprSetxCentre(0) SprSetyCentre(0) SprSetZOrder (1) SprSetSize (w1,h1) SprSetPos (x1,y1) SprSetFrame (px) x1 = x1 + w1 end if next End Sub
Attachments:black_mandel.zip (587.67 KB)
|
|
|
Post by matthew on Dec 16, 2015 3:30:57 GMT -5
Hi Peter, nice Mandelbrot. Here is a different type of fractal called a H tree.
' open a 2d screen ' glmatrixmode(gl_projection) glloadidentity() glortho(0, windowwidth(), windowheight(), 0, 0, 1) gldisable(gl_depth_test) gldrawbuffer(gl_back) glmatrixmode(gl_modelview) glloadidentity()
' draw using smooth lines ' glenable(gl_line_smooth)
dim theta#, third# = windowheight() / 3
sub branch(branchsize#)
' future branches will be 2/3rds smaller than the previous one ' branchsize# = branchsize# * 0.66 if (branchsize# > 2) then ' draw the branches on the right-hand side ' glpushmatrix() glrotatef(theta#, 0.0, 0.0, 1.0) glbegin(gl_lines) glvertex2f(0, 0) glvertex2f(0, -branchsize#) glend() gltranslatef(0, -branchsize#, 0) branch(branchsize#) glpopmatrix() ' now draw the left branches ' glpushmatrix() glrotatef(-theta#, 0.0, 0.0, 1.0) glbegin(gl_lines) glvertex2f(0, 0) glvertex2f(0, -branchsize#) glend() gltranslatef(0, -branchsize#, 0) branch(branchsize#) glpopmatrix() endif
end sub
while true
' clear the screen to white ' glclearcolor(1.0, 1.0, 1.0, 0.0) glclear(gl_color_buffer_bit) glloadidentity() ' draw in black ' glcolor3f(0.0, 0.0, 0.0) ' start drawing at the bottom of the screen in the centre ' gltranslatef(windowwidth() / 2, windowheight(), 0) ' draw a line upwards ' glbegin(gl_lines) glvertex2f(0, 0) glvertex2f(0, -third#) glend() ' the next line will be drawn at the end of the previous one ' gltranslatef(0, -third#, 0) branch(third#) swapbuffers()
while synctimer(10) theta# = theta# + 0.1 ' theta# = mouse_x() * 180 wend
wend
|
|
|
Post by PeterMaria on Dec 16, 2015 4:09:06 GMT -5
Cool tree, Matthew! some light and we get a Christmas tree.
|
|