Skip to content
A perlin noise shard written for Crystal. All credit goes to Spooner who wrote the original implementation.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


A Shard written for using Perlin Noise. Pretty much ripped word for word from (Spooner's perlin_noise)[] gem's C extension.


Add this to your application's shard.yml:

    github: redcodefinal/perlin_noise


require "perlin_noise"

p = #Seed the generator

#You can change the step, persistance, octave, offsets, etc
p.step = 0.4 #default is 0.123456
p.persistance = 0.4 # Default is 0.2
p.octave = 2.0 # Default is 1.0

#Generator can be used for a number of operations

#Simple Noise
p.noise(0)       #1d
p.noise(0, 1)    #2d
p.noise(0, 1, 2) #3d

p.height(0, 0, 10) #2d only, 3rd argument is maximum height

#  Gets a random integer that can be gotten again with the same parameters., 10, 20)       #1d, last two arguments are the lowest number and the highest number, 1, 10, 20)    #2d, 1, 2, 10, 20) #3d

#  Same as int but with floats instead.
p.float(0, 0.0, 1.0)
p.float(0, 1, 0.0, 5.0)
p.float(0, 1, 2, 1.0, 10.0)

#  Gets you a boolean with controllable chance for a true.
#  bool(x, y, z, chance, outof)
p.bool(0, 1, 2, 1, 100) #Give a 1 out of 100 chance of being true.

#  Grabs an item out of an array. If the array changes, the output of this function may change.
a = [1, 2, 3, 4, 5, 6, 7, 8, "Bacon", "Taco", "Cat"]
p.item(0, a)
p.item(0, 1, a)
p.item(0, 1, 2, a)


  1. Fork it ( )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request


  • redcodefinal Ian Rash - creator, maintainer
  • Spooner Bil Bas - Writter of the original rubygem, whose code he graciously let me rip off. Thanks man.
You can’t perform that action at this time.