diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2019-09-04 21:02:12 -0400 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2019-09-04 21:02:12 -0400 |
commit | cb9f77d9db0d8e7d5717be2995030e6b360a5ea2 (patch) | |
tree | 9f1c38452a5616712ccc9cc3afd05342b86ad276 | |
parent | 36e33b6e951ffdfd844c085908680597de57d42a (diff) | |
download | sethna.hs-cb9f77d9db0d8e7d5717be2995030e6b360a5ea2.tar.gz sethna.hs-cb9f77d9db0d8e7d5717be2995030e6b360a5ea2.tar.bz2 sethna.hs-cb9f77d9db0d8e7d5717be2995030e6b360a5ea2.zip |
small changes
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | 02.05.hs | 6 |
2 files changed, 4 insertions, 3 deletions
@@ -1,4 +1,5 @@ *.hi *.o *.svg +*.eps [0-9][0-9].[0-9][0-9] @@ -8,7 +8,7 @@ import Graphics.Rendering.Chart.Backend.Cairo import Data.Colour.Names import Diagrams.Prelude -import Diagrams.Backend.SVG.CmdLine +import Diagrams.Backend.Postscript randomWalk :: (RandomGen g) => Int -> Int -> State g [[Double]] randomWalk d n = get >>= (\g -> let (g1, g2) = split g in (put g1) >> (return $ take n $ scanl (\x y -> map (uncurry (+)) $ zip x y) (replicate d 0.0) $ chunksOf d $ randomRs (-0.5,0.5) g2)) @@ -21,10 +21,10 @@ main = do let (w10, g2) = runState (randomWalk 2 10) g let (w1000, g3) = runState (randomWalk 2 1000) g2 let (w100000, g4) = runState (randomWalk 2 100000) g3 --- mainWith $ foldr1 Diagrams.Prelude.atop [lc red $ drawWalk w10, lc blue $ drawWalk w1000, lc green $ drawWalk w100000] + renderDia Postscript (PostscriptOptions "02.05.01.eps" (dims2D 500 500) EPS) $ foldr1 Diagrams.Prelude.atop [lc red $ drawWalk w10, lc blue $ drawWalk w1000, lc green $ drawWalk w100000] let (e1, g5) = runState (sequence $ replicate 10000 $ randomWalk 2 2) g4 let (e10, g6) = runState (sequence $ replicate 10000 $ randomWalk 2 11) g5 - mainWith $ foldr1 Diagrams.Prelude.atop [mconcat $ map (place (lw Diagrams.Prelude.none $ fc yellow $ ((circle 0.01) :: Diagram B))) (map (\[x, y] -> p2 (x, y)) (map last e1)), mconcat $ map (place (lw Diagrams.Prelude.none $ fc black $ circle 0.01)) (map (\[x, y] -> p2 (x, y)) (map last e10))] + renderDia Postscript (PostscriptOptions "02.05.02.eps" (dims2D 500 500) EPS) $ foldr1 Diagrams.Prelude.atop [mconcat $ map (place (lw Diagrams.Prelude.none $ fc yellow $ ((circle 0.01) :: Diagram B))) (map (\[x, y] -> p2 (x, y)) (map last e1)), mconcat $ map (place (lw Diagrams.Prelude.none $ fc black $ circle 0.01)) (map (\[x, y] -> p2 (x, y)) (map last e10))] |