-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Generates mountainous terrain using a random walk algorithm. -- -- Provides functions for generating mountain-like terrain structure -- using a random walk algorithm. Inspired by Pickover's 1998 article -- "Vacation on Mars". The data can be output as an ascii-format PLY -- file, or viewed "overhead" as an intensity graph. The PLY file can be -- loaded into a 3D modeling program such as Blender. @package mars @version 0.2.0.0 -- | Provides functions to convert an array of floats into a Surface -- structure containing vertices and faces, and then into PLY format -- text, which can be loaded into a modeling program like Blender. module Graphics.Mars.Ply -- | Converts a 2D array of floats into a sheet of polygons, which can be -- processed by toPly. surface :: UArray (Int, Int) Float -> Surface Array data Surface a -- | Converts a Surface data structure, which is a sheet of polygons, into -- an ascii-format PLY file. toPly :: Surface Array -> String -- | Use the graph function here to generate the raw graph array -- data based on various parameters. module Graphics.Mars.Graph -- | Beginning in the center, follows a random walk path, and stamps a -- circle shape onto the array at each step. Internally uses a mutable -- unboxed array for efficiency, but returns the results in a frozen -- array. graph :: Int -> Int -> Float -> Float -> Int -> Int -> Float -> (Float, Float) -> IO (UArray (Int, Int) Float) module Graphics.Mars.Paint -- | A type of function converting a floating point data value into a -- color's ByteString type Interpretation = Float -> ByteString -- | Determines the minimum and maximum values in a data structure minMax :: (Num a, Ord a, Foldable t) => t a -> (a, a) -- | Color interpretation of data as a variation of on the lightness of a -- single hue lightnessInt :: Float -> (Float, Float) -> Interpretation -- | Converts an array of floating point values into a Gloss Picture, using -- a color Interpretation toImage :: UArray (Int, Int) Float -> Interpretation -> Picture module Graphics.Mars.Display2D -- | Displays a Picture in a window on the screen. displayWindow :: (Int, Int) -> Color -> String -> Picture -> IO () -- | Display a Picture on the screen, in full-screen mode displayFullscreen :: (Int, Int) -> Color -> Picture -> IO () -- | 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 -- | Generates an example random walk array and displays it as a -- 2-dimensional intensity graph -- --
-- example2D = do a <- graph height width radius walkfactor -- seed iterations scalefactor startingpoint -- 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 -- startingpoint = (0, 0) --example2D :: IO () -- | 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 startingpoint -- writeFile out.ply $ (toPly . surface) a -- where (width, height) = (400, 400) -- radius = 10 -- walkfactor = 10 -- seed = 4748830300 -- iterations = 400 -- scalefactor = 1 -- startingpoint = (0, 0) --examplePly :: IO () examplePly2 :: IO () examplePly3 :: IO () examplePly4 :: IO () -- | Warning: Large output file with 1 million vertices! May take a while -- to complete, with 40000 iterations. examplePly5 :: IO ()