Wind!
authorJoachim Breitner <mail@joachim-breitner.de>
Sat, 27 Jun 2009 10:46:22 +0000 (12:46 +0200)
committerJoachim Breitner <mail@joachim-breitner.de>
Sat, 27 Jun 2009 10:46:22 +0000 (12:46 +0200)
src/Lseed/Geometry.hs
src/Lseed/Renderer/Cairo.hs

index e0dc890..347e1bc 100644 (file)
@@ -189,3 +189,13 @@ mapLine process init combine garden = runST $ do
        -- Undo the STRefs
        mapM (mapM (\(d,stRef) -> (,) d <$> readSTRef stRef)) gardenWithPointers
 
+-- | Slightly shifts angles 
+windy angle = mapGarden (mapPlanted go)
+  where go p = p{
+               pAngle = pAngle p +
+                        windFactor * offset * pLength p * cos (siDirection (pData p)),
+               pBranches = map go (pBranches p)
+       }
+        offset = sin (windChangeFrequency * angle)
+       windFactor = 0.2
+       windChangeFrequency = 10
index 91e7dc0..c16b0c0 100644 (file)
@@ -95,7 +95,7 @@ cairoObserver = do
                                        translate 0 groundLevel
                                        setLineWidth stipeWidth
 
-                                       render angle garden
+                                       render angle (windy angle garden)
                                        renderTimeInfo timeInfo
                                        renderStats (fromIntegral h/fromIntegral w) garden
                                  return True