Skip to content

Commit

Permalink
Preparing for hackage release
Browse files Browse the repository at this point in the history
  • Loading branch information
colinhect committed May 3, 2011
1 parent ddc78b3 commit d931c45
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 6 deletions.
35 changes: 35 additions & 0 deletions examples/Perlin.hs
@@ -0,0 +1,35 @@
module Perlin where

import Noise.Perlin

import Codec.PPM.Binary
import Data.Word

main = do
-- The size of the resulting image.
let size = 200

-- Parameters for the noise function.
let seed = 1
let octaves = 5
let scale = 0.05
let persistance = 0.5

-- Create the perlin function.
let perlin = Perlin seed octaves scale persistance

-- Compute the noise value for each pixel in the image.
let coords = [1.0..fromInteger size]
let xs = [noiseValue perlin (x, y, 0) | y <- coords, x <- coords]

-- Convert the noise values to grayscale colors.
let ps = map noiseToColor xs

-- Write the image.
writePPM "Noise.ppm" (size, size) ps
return ()

-- Converts a value from -1 to 1 to a gray 24-bit color value from 0 to 255.
noiseToColor :: Double -> (Word8, Word8, Word8)
noiseToColor n = (n', n', n')
where n' = fromInteger (floor ((n * 0.5 + 0.5) * 255)) :: Word8
21 changes: 15 additions & 6 deletions hsnoise.cabal
Expand Up @@ -6,25 +6,34 @@ build-type: Simple


license: BSD3 license: BSD3
license-file: LICENSE license-file: LICENSE
copyright: Copyright 2011, Colin Hill copyright: Copyright (c) 2011, Colin Hill
author: Colin Hill <colin.james.hill@gmail.com> author: Colin Hill <colin.james.hill@gmail.com>
maintainer: Colin Hill <colin.james.hill@gmail.com> maintainer: Colin Hill <colin.james.hill@gmail.com>


stability: Experimental stability: Experimental


homepage: homepage: <https://github.com/colinhect/hsnoise>


synopsis: A coherent 3d noise library. synopsis: A coherent 3d noise library.
description: .

description: A coherent 3d noise library loosely based on libnoise. Currently has an
implementation of perlin noise. Will eventually support other noise
types as well as noise function combinations.
.
Code examples included in package.
.
Example of Perlin noise output image: <http://i.imgur.com/cPOZ2.png>
.

category: Noise category: Noise


extra-source-files: examples/Perlin.hs

library library
exposed-modules: exposed-modules:
Noise Noise
Noise.Perlin Noise.Perlin
Noise.Random Noise.Random
build-depends: AC-PPM -any, base -any, vector -any build-depends: AC-PPM -any, base >= 2 && < 4, vector -any
ghc-options: -O2 ghc-options: -O2
hs-source-dirs: src hs-source-dirs: src

0 comments on commit d931c45

Please sign in to comment.