Turn down the alpha right before the repeat to like 0.1 and you'll have really an underwater coral reef thingy! ;)
Yeah, that's the idea, Mortiis, in some regards. I want it to be a painting feature, just for fun. I'm just too lazy to always draw my trees. I'll give only very few parameters to keep it simple and instead make a few presets for different types of trees. I'll put in a way to let gesture affect the treegrowth so it keeps a personal touch, you know.
More than anything, you can have all the fun you can think of with it! It's my christmas present to all of you and it's hopefully one that keeps on giving! 8)))
THANK YOU, by the way, I'm happy you like it, too!
Here's a little underwater variation:
Yeah, that's the idea, Mortiis, in some regards. I want it to be a painting feature, just for fun. I'm just too lazy to always draw my trees. I'll give only very few parameters to keep it simple and instead make a few presets for different types of trees. I'll put in a way to let gesture affect the treegrowth so it keeps a personal touch, you know.
More than anything, you can have all the fun you can think of with it! It's my christmas present to all of you and it's hopefully one that keeps on giving! 8)))
THANK YOU, by the way, I'm happy you like it, too!
Here's a little underwater variation:
SuperStrict '=======================================================' 'magic procedural forest - www.Taron.de (christmas 2008)' '=======================================================' Framework brl.d3d7Max2D Import brl.random Import brl.eventqueue SetGraphicsDriver D3D7Max2DDriver() Graphics 800,600,0,60 SeedRnd MilliSecs() SetWindowTextA( pub.win32.GetActiveWindow(),"procedural corals" ) Global brush:TPixmap = CreatePixmap(100,100,PF_RGBA8888) For Local y:Float = 0 Until 100 For Local x:Float = 0 Until 100 Local a:Int = 0 Local ix:Float = x-50 Local iy:Float = y-50 Local dot:Float = ix*ix + iy*iy If dot Then dot = Sqr(dot) If dot >50.0 Then dot = 50 dot:*5.1 a = 255-dot ix = x-20 iy = y-40 dot = ix*ix + iy*iy If dot Then dot = Sqr(dot) If dot >100.0 Then dot = 100.0 If dot <0 Then dot = 0.0 Local col:Int = (100-dot)*2 brush.WritePixel(x,y,col|col Shl 8|col Shl 16|a Shl 24) Next Next Global bg:TPixmap = CreatePixmap(1,600,pf_rgba8888) For Local y:Float = 0 Until 600 Local r:Int = Int((1.0-y/600)*$5f) & $ff Local g:Int = Int((1.0-y/780)*$ff) & $ff Local b:Int = Int((1.0-y/800)*$ff) & $ff bg.WritePixel(0,y,b|g Shl 8|r Shl 16|255 Shl 24) Next Global bgi:timage = LoadImage(bg) Type branch Global list:TList = CreateList() Field x:Float Field y:Float Field dx:Float Field dy:Float Field size:Float Field img:TImage = LoadImage(brush) Method grow() SetScale size^2,size^2 DrawImage(img,x,y) x:+dx*size y:+dy*size size:*(0.97+Rnd(0,0.04)) dx:+Rnd(-0.85,0.85) dy:+Rnd(-0.5,0.5) If Rnd(0,10)<-0.1+(1.0-size) And size > 0.3 Then Create(list,x,y,Rnd(-1.0,1.0),dy,size) If size<0.1 Then list.Remove(Self) End Method Function Create:branch(list:TList, x:Int, y:Int, dx:Int, dy:Int, size:Float) Local b:branch = New branch b.x = x b.y = y b.dx = dx b.dy = dy b.size = size b.img = LoadImage(brush) ListAddLast list,b Return b End Function End Type Local r:Int = 255 Local g:Int = 255 Local b:Int = 255 SetBlend ALPHABLEND SetAlpha 1.0 SetColor 155,155,155 SetScale 1.0,1.0 DrawImageRect(bgi,0,0,800,600) Repeat Local Event:TEvent = CurrentEvent event.id = PollEvent() If event.id = 259 Then Exit SetAlpha 0.8 SetColor r,g*Rnd(0.8,0.99),b*Rnd(0.7,0.9) For Local tree:branch = EachIn branch.list; tree.grow();Next If branch.list.Count() = 0 branch.Create(branch.list,Rnd(0,800),Rnd(550,650),0,-4,0.7) SetAlpha 0.05 SetColor Rnd(0,155),155,155'30,60,90 SetScale 1,1 DrawImageRect(bgi,0,0,800,600) g = Rnd(150,255) b = Rnd(50,200) EndIf Flip 0 Until KeyHit(KEY_ESCAPE)