diff --git a/src/Lsystem/Generator.hs b/src/Lsystem/Generator.hs index 0819f0d..79acff4 100644 --- a/src/Lsystem/Generator.hs +++ b/src/Lsystem/Generator.hs @@ -1,3 +1,12 @@ +{-| +Module : Lsystem.Generator +Description : Generate the L-system +Copyright : (c) Zebulun Arendsee, 2018 +License : MIT +Maintainer : zbwrnz@gmail.com +Stability : experimental +-} + module Lsystem.Generator ( step @@ -40,9 +49,9 @@ applyRules g lc rc rs n = fromMaybe [n] . firstSuccess (applyRule p) $ rs applyRule :: Chance -> Rule -> Maybe [Node] applyRule _ (DeterministicRule cont cond match repl) = return (repl lc rc n) -- replace node if: - >>= match n -- * the node is of the correct form - >>= cont lc rc -- * it is in the required context - >>= cond lc rc n -- * all parametric restrictions are met + >>= match n -- the node is of the correct form + >>= cont lc rc -- it is in the required context + >>= cond lc rc n -- all parametric restrictions are met applyRule p (StochasticRule rs') = case (choose p rs') of -- p is rescaled by dividing by the selected rule's probability Just (cp', r) -> applyRule (p / cp') r diff --git a/src/Lsystem/Grammar.hs b/src/Lsystem/Grammar.hs index 257624e..e7fd856 100644 --- a/src/Lsystem/Grammar.hs +++ b/src/Lsystem/Grammar.hs @@ -1,3 +1,12 @@ +{-| +Module : Lsystem.Grammar +Description : Core types +Copyright : (c) Zebulun Arendsee, 2018 +License : MIT +Maintainer : zbwrnz@gmail.com +Stability : experimental +-} + module Lsystem.Grammar ( System(..) @@ -13,17 +22,17 @@ module Lsystem.Grammar , Chance ) where --- context-sensitive stochastic parameterized L-systems +-- -type Distance = Double -- x > 0 -type Yaw = Double -- -180 < x < 180 -type Pitch = Double -- -180 < x < 180 -type Roll = Double -- -180 < x < 180 +type Distance = Double -- ^ x > 0 +type Yaw = Double -- ^ -180 < x < 180 +type Pitch = Double -- ^ -180 < x < 180 +type Roll = Double -- ^ -180 < x < 180 type LeftContext = [Node] type RightContext = [Node] -type Chance = Double -- 0 <= x <= 1 +type Chance = Double -- ^ 0 <= x <= 1 data System = System { systemBasis :: [Node] diff --git a/src/Lsystem/Render.hs b/src/Lsystem/Render.hs index d0ed6ae..a05bcb9 100644 --- a/src/Lsystem/Render.hs +++ b/src/Lsystem/Render.hs @@ -2,6 +2,15 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE TypeFamilies #-} +{-| +Module : Lsystem.Render +Description : Render a generated L-system +Copyright : (c) Zebulun Arendsee, 2018 +License : MIT +Maintainer : zbwrnz@gmail.com +Stability : experimental +-} + module Lsystem.Render ( renderSystem diff --git a/src/Lsystem/Sugar.hs b/src/Lsystem/Sugar.hs index 6eaf91c..2fd690a 100644 --- a/src/Lsystem/Sugar.hs +++ b/src/Lsystem/Sugar.hs @@ -1,3 +1,12 @@ +{-| +Module : Lsystem.Sugar +Description : Functions for simplifying L-system specification +Copyright : (c) Zebulun Arendsee, 2018 +License : MIT +Maintainer : zbwrnz@gmail.com +Stability : experimental +-} + module Lsystem.Sugar ( transDol @@ -68,11 +77,11 @@ matchWidth _ _ = Nothing unconditional :: LeftContext -> RightContext -> Node -> a -> Maybe a unconditional _ _ _ x = Just x --- Check is A is a similar to B. For branches, A must be a subtree of B. +-- | Check is A is a similar to B. For branches, A must be a subtree of B. similar - :: Node -- A - -> Node -- B - -> Bool -- True is A is in B (where `in` is weirdly defined ...) + :: Node -- ^ A + -> Node -- ^ B + -> Bool -- ^ True if A is in B (where `in` is weirdly defined ...) similar (NodeDummy _ s) (NodeDummy _ t) = s == t similar (NodeDraw _ _ ) (NodeDraw _ _) = True similar (NodeRotate _ _ _ _) (NodeRotate _ _ _ _) = True @@ -92,11 +101,11 @@ similar (NodeBranch mss) (NodeBranch nss) = any id $ map (anyBranch nss) mss similar _ _ = False contextMatch - :: [Node] -- elements to ignore - -> [Node] -- left contextual pattern - -> [Node] -- right contextual pattern - -> [Node] -- left context - -> [Node] -- right context + :: [Node] -- ^ elements to ignore + -> [Node] -- ^ left contextual pattern + -> [Node] -- ^ right contextual pattern + -> [Node] -- ^ left context + -> [Node] -- ^ right context -> a -> Maybe a -- combinator kludge (I really should go to Bool) contextMatch ss lpat rpat lc rc x = return x