mars-0.1.0.0: Graphics/Mars/Example.hs
{-|
Module : Graphics.Mars.Example
Description : Provides code examples which can be studied or executed.
Copyright : (c) Christopher Howard, 2016
License : GPL-3
Maintainer : ch.howard@zoho.com
Run an example function to view an image, or study the function source code for
to see how the library can be used.
-}
module Graphics.Mars.Example where
import Graphics.Gloss
import Data.Array.Unboxed
import Graphics.Mars.Paint
import Graphics.Mars.Graph
import Graphics.Mars.Display2D
import Graphics.Mars.Ply
-- |Generates an example random walk array and displays it as a 2-dimensional
-- intensity graph
--
-- @
-- example2D :: IO()
-- example2D = do a <- graph height width radius walkfactor seed iterations scalefactor
-- displayWindow (width, height) black \"Mars\"
-- (toImage a (lightnessInt hue (minMax (elems a))))
-- where (width, height) = (300, 300)
-- radius = 30
-- walkfactor = 30
-- seed = 9484
-- hue = 272
-- iterations = 200
-- scalefactor = 1
-- @
example2D :: IO()
example2D = do a <- graph height width radius walkfactor seed iterations scalefactor
displayWindow (width, height) black "Mars"
(toImage a (lightnessInt hue (minMax (elems a))))
where (width, height) = (300, 300)
radius = 30
walkfactor = 30
seed = 9484
hue = 272
iterations = 200
scalefactor = 1
-- |Generates a random walk array, converts it PLY ascii format, and output the
-- PLY to a file called \"out.ply\".
--
-- @
-- examplePly = do a <- graph height width radius walkfactor seed iterations scalefactor
-- writeFile \"out.ply\" $ (toPly . surface) a
-- where (width, height) = (400, 400)
-- radius = 10
-- walkfactor = 10
-- seed = 4748830300
-- iterations = 400
-- scalefactor = 1
-- @
examplePly :: IO ()
examplePly = do a <- graph height width radius walkfactor seed iterations scalefactor
writeFile "out.ply" $ (toPly . surface) a
where (width, height) = (400, 400)
radius = 10
walkfactor = 10
seed = 4748830300
iterations = 400
scalefactor = 1
examplePly2 :: IO ()
examplePly2 = do a <- graph height width radius walkfactor seed iterations scalefactor
writeFile "out2.ply" $ (toPly . surface) a
where (width, height) = (400, 400)
radius = 10
walkfactor = 10
seed = 84934
iterations = 400
scalefactor = 1
examplePly3 :: IO ()
examplePly3 = do a <- graph height width radius walkfactor seed iterations scalefactor
writeFile "out3.ply" $ (toPly . surface) a
where (width, height) = (400, 400)
radius = 10
walkfactor = 10
seed = 49409484
iterations = 2000
scalefactor = 1
examplePly4 :: IO ()
examplePly4 = do a <- graph height width radius walkfactor seed iterations scalefactor
writeFile "out4.ply" $ (toPly . surface) a
where (width, height) = (600, 600)
radius = 10
walkfactor = 20
seed = 1829384
iterations = 4000
scalefactor = 1
-- |Warning: Large output file with 1 million vertices! May take a
-- while to complete, with 40000 iterations.
examplePly5 :: IO ()
examplePly5 = do a <- graph height width radius walkfactor seed iterations scalefactor
writeFile "out5.ply" $ (toPly . surface) a
where (width, height) = (1000, 1000)
radius = 15
walkfactor = 15
seed = 74830949937
iterations = 40000
scalefactor = 0.5