# Sunflower

by NightElfik

Short link: http://malsys.cz/g/8NgebrCP

Loading 3D model

of Sunflower

### Comments

comments powered by Disqus### Source code

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | lsystem Sunflower(seedCount = 300, altSeedCount = 50, greenLeafCount = 15, yellowLeafCount = 35) extends Branches { set symbols axiom = A(0); set randomSeed = 0; set iterations = seedCount + altSeedCount + greenLeafCount + yellowLeafCount ; set cameraPosition = {180, 792, 249}; set cameraUpVector = {-0.96, 0.26, 0.12}; set cameraTarget = {31, 17, 28}; interpret f as MoveForward; interpret Seed as DrawForward(24, 18, #332211); interpret AltSeed as DrawForward(24, 18, #24180C); interpret GreenLeaf as lsystem Leaf(lighten(#00AA00, random(0, 0.1))); interpret YellowLeaf as lsystem Leaf(lighten(#E5C500, random(0, 0.1))); interpret + as Yaw(137.515); interpret / as Roll(45); interpret ^ as Pitch(90); interpret & as Pitch(-90); let altSeedTreshold = seedCount; let greenLeafTreshold = seedCount + altSeedCount; let yellowLeafTreshold = seedCount + altSeedCount + greenLeafCount; rewrite A(n) where n > yellowLeafTreshold to + [ f(n^0.5 * 10 - 20) ^(random(5, 15)) YellowLeaf ] A(n+1); rewrite A(n) where n > greenLeafTreshold to + [ f(n^0.5 * 10 - 20) & f(10) ^ ^(random(0, 5)) GreenLeaf ] A(n+1); rewrite A(n) where n > altSeedTreshold to + [ f(n^0.5 * 10) ^ f(-12) /(random(-20, 20)) AltSeed ] A(n+1); rewrite A(n) to + [ f(n^0.5 * 10 - 10) / Seed ] A(n+1); } abstract lsystem Leaf(color = #E5C500) extends Polygons { let la = 5; let ra = 1.1; let lb = 1; let rb = 1.2; let pd = 1; let angle = 60; set symbols axiom = [ [ +(angle) ^ B(0) <(color) . ] A(1, angle) . > ] [ [ +(-angle) ^ B(0) <(color) . ] A(1, -angle) . > ]; set iterations = random(18, 20); interpret G as MoveForward; interpret + as Yaw(60); interpret - as Yaw(-60); interpret ^ as Pitch(10); rewrite A(t, angle) to . G(la, ra) . [ +(angle) ^ B(t) . > ] [ +(angle) ^ B(t) <(color) . ] A(t+1, angle); rewrite B(t) where t > 0 to G(lb, rb) B(t - pd); rewrite G(s, r) to G(s*r, r); } process all with ThreeJsRenderer; |

### Thumbnail extension

1 | process Sunflower(200, 20, 5, 20) with ThreeJsRenderer; |