perlin_noise

Ruby-implementation of N-dimension Perlin noise.

Installation

gem install perlin_noise
require 'perlin_noise'

Basic

One-dimension

n1d = Perlin::Noise.new 1
0.step(100, 0.01) do |x|
  puts n1d[x]
end

Two-dimension, three-dimension, or even more dimensions

n2d = Perlin::Noise.new 2
0.step(100, 0.01) do |x|
  0.step(100, 0.01) do |y|
    puts n2d[x, y]
  end
end

n3d = Perlin::Noise.new 3
n3d[rand, rand, rand]

n5d = Perlin::Noise.new 5
n5d[rand, rand, rand, rand, rand]

Options

:interval

A gradient noise repeats itself at certain interval. (Default interval is 256) You can change the interval of the noise generator but keep in mind that longer interval requires more pseudo-random gradient vectors to be maintained in memory.

n3d = Perlin::Noise.new 3, :interval => 100
n3d[0.1, 0.2, 0.3]
n3d[0.1, 0.2, 100.3]

:seed

You can optionally specify a seed value for the random number generator. (Caveat: seed value is set globally in Ruby 1.8)

noises = Perlin::Noise.new 1, :seed => 12345

Range of noise function

While the original algorithm outputs a number between -1.0 and 1.0, Perlin::Noise#[] manipulates this output and returns a number between 0.0 and 1.0 for ease of use. Thus, noise values at all of the integer lattice points should be 0.5, not 0.

Increasing the contrast

Even though the range of the noise function is from 0 to 1, you'll rarely see a noise value close to either end, as most of the values are distributed around the center. You might want to apply S-shaped curve functions defined in Perlin::Curve module one or more times to push away those "grey" values to either end, achiving more contrasted output.

noise = Perlin::Noise.new 1

n = noise[0.1]

3.times do
  n = Perlin::Curve::CUBIC.call n
end

There's a shortcut for this specific process.

contrast = Perlin::Curve.contrast(Perlin::Curve::CUBIC, 3)
n = contrast.call n

1D noise

noise = Perlin::Noise.new 1, :interval => 200
0.step(300, 0.1).each do |x|
  puts '#' * (noise[x] * 60).floor
end
##############################
################################
##################################
##################################
################################
##############################
###########################
#########################
#########################
###########################
##############################
#################################
#####################################
########################################
###########################################
#############################################
###########################################
########################################
#####################################
#################################
##############################
###########################
#########################
#########################
###########################
##############################
################################
##################################
##################################
################################
##############################
##########################
######################
###################
################
###############
################
###################
######################
##########################
##############################
#################################
#####################################
########################################
###########################################
#############################################
###########################################
########################################
#####################################
#################################
##############################
##########################
######################
###################
################
###############
################
###################
######################
##########################
##############################
#################################
#####################################
########################################
###########################################
#############################################
###########################################
########################################
#####################################
#################################
##############################
##########################
######################
###################
################
###############
################
###################
######################
##########################
##############################
################################
##################################
##################################
################################
##############################
###########################
#########################
#########################
###########################
##############################
#################################
#####################################
########################################
###########################################
#############################################
###########################################
########################################
#####################################
#################################
##############################
###########################
#########################
#########################
###########################
##############################
################################
##################################
##################################
################################
##############################
##########################
######################
###################
################
###############
################
###################
######################
##########################
##############################
#################################
#####################################
########################################
###########################################
#############################################
###########################################
########################################
#####################################
#################################
##############################
##########################
######################
###################
################

2D noise

noises = Perlin::Noise.new(2)
contrast = Perlin::Curve.contrast(Perlin::Curve::CUBIC, 2)

bars = " ▁▂▃▄▅▆▇█".each_char.to_a
bar = lambda { |n| 
  bars[ (bars.length * n).floor ]
}

100.times do |i|
  70.times do |y|
    n = noises[i * 0.1, y * 0.1]
    n = contrast.call n

    print bar.call(n)
  end
  puts
end
▃▃▂▂▁▁▁▁▂▃▃▄▅▅▆▆▆▅▅▅▅▅▅▄▄▃▃▂▂▃▃▄▄▄▄▄▄▄▄▄▅▅▆▇▇▇▇▇▆▅▄▃▂▁   ▁▂▃▄▅▆▆▇▇▆▆▅▅
▂▂▁▁▁▁▁▁▂▂▃▄▄▅▆▆▆▆▆▆▆▆▆▅▅▄▃▂▂▂▃▃▄▄▄▄▄▅▅▅▆▆▇▇██▇▇▆▅▄▃▂▁   ▁▂▃▄▅▆▆▇▇▇▇▆▆
▁▁▁▁▁▁▁▁▂▃▃▄▄▅▅▆▆▆▇▇▇▇▇▆▆▅▄▃▃▃▃▃▄▄▄▅▅▆▆▆▇▇▇███▇▇▆▅▄▃▂▁   ▁▁▂▃▄▅▆▇▇▇▇▇▇
  ▁▁▁▂▂▃▃▃▄▄▅▅▆▆▇▇▇▇▇▇▇▇▆▅▄▃▃▃▄▄▄▅▆▆▇▇▇▇▇████▇▇▆▆▅▄▃▂▁  ▁▁▂▂▃▄▅▆▇████
  ▁▁▁▂▃▃▄▄▄▄▄▄▅▅▆▆▇▇▇███▇▇▆▅▄▄▄▄▄▅▅▆▇▇▇▇▇▇████▇▇▇▆▅▅▄▂▁▁▁▁▁▁▂▃▄▅▆▇████
▁▁▁▂▃▄▄▅▅▅▅▄▄▄▄▄▅▅▆▇▇▇███▇▇▆▅▅▅▅▅▅▆▆▇▇▇▇▇▇▇▇▇▇▇▇▇▆▆▅▄▃▂▁▁▁▁▁▂▂▃▄▆▇▇███
▁▁▂▃▄▅▆▆▆▅▅▅▄▃▃▃▃▄▅▆▇▇▇███▇▇▆▆▅▅▅▅▆▆▇▇▇▇▇▆▆▆▆▆▇▇▆▆▆▅▅▄▃▂▁▁▁▁▂▂▃▄▅▆▇▇▇▇
▂▃▃▄▅▆▇▆▆▆▅▄▄▃▂▂▂▃▄▅▆▆▇▇██▇▇▆▆▅▅▅▅▅▆▆▆▇▆▆▅▅▅▅▅▆▆▆▆▆▅▄▄▃▂▂▂▂▂▂▃▃▄▅▆▆▇▇▆
▃▄▅▅▆▇▇▇▆▅▅▄▃▂▁▁▁▂▃▄▅▅▆▇▇▇▇▇▆▅▅▄▄▄▅▅▆▆▆▅▅▄▄▄▄▄▅▅▅▅▅▄▄▃▃▂▂▂▂▃▃▃▄▅▅▆▆▆▆▅
▄▅▅▆▇▇▇▆▆▅▄▃▂▂▁▁▁▁▂▃▄▅▆▆▇▇▇▆▅▅▄▄▃▄▄▄▅▅▅▅▄▃▃▃▃▃▄▄▄▄▄▄▃▃▂▂▂▃▃▄▄▄▅▅▅▆▅▅▅▄
▅▅▆▇▇▇▆▆▅▄▃▃▂▁▁ ▁▁▂▃▃▄▅▆▆▆▆▅▄▄▃▃▂▃▃▃▄▄▄▄▃▃▂▂▂▃▃▃▃▃▃▃▂▂▂▂▃▃▄▅▅▅▆▆▆▆▅▅▄▃
▅▆▆▇▇▇▆▅▄▃▂▂▁▁   ▁▂▂▃▄▅▅▆▆▅▄▃▂▂▂▂▂▂▃▃▄▄▃▃▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▃▄▅▅▆▆▆▆▆▆▅▄▄▃
▅▆▆▆▆▆▅▄▃▂▁▁▁    ▁▂▃▃▄▅▅▅▅▄▃▂▁▁▁▁▁▂▂▃▄▄▃▃▂▂▂▁▁▁▁▁▁▁▁▁▁▂▃▄▅▆▆▆▆▆▆▆▅▅▄▄▃
▅▅▆▆▆▅▄▃▂▁▁▁    ▁▁▂▃▄▄▅▅▅▄▃▂▁▁   ▁▁▂▃▄▄▄▃▃▂▂▁▁▁▁▁▁  ▁▁▂▃▄▅▆▆▆▆▆▆▆▅▅▄▄▄
▄▅▅▅▅▄▃▂▁▁▁▁▁ ▁▁▁▂▃▄▄▅▅▅▅▄▃▁▁    ▁▂▃▄▅▅▅▄▄▃▂▁▁      ▁▁▂▄▅▆▆▆▆▆▅▅▅▅▅▅▅▄
▄▄▄▄▄▃▂▁▁▁▁▁▁▁▁▁▂▃▃▄▅▆▆▆▅▄▃▁▁   ▁▁▂▄▅▅▅▅▅▄▃▂▂▁     ▁▁▂▃▅▆▆▆▆▅▅▄▄▄▄▅▅▅▅
▃▄▄▄▃▃▂▁▁▁▁▂▂▂▂▂▃▃▄▅▅▆▆▆▅▄▃▂▁▁▁▁▁▂▃▅▅▆▆▆▅▅▄▃▂▁▁▁▁▁▁▁▂▃▄▅▆▆▆▆▅▄▃▃▃▄▄▅▅▆
▃▄▄▄▄▃▂▂▂▂▂▃▃▃▃▃▃▄▄▅▅▆▆▆▅▅▄▃▂▂▂▂▃▃▄▅▆▆▆▆▅▅▄▃▂▁▁▁▁▂▂▂▃▄▅▆▇▆▆▅▄▃▃▂▃▃▄▅▅▆
▃▄▄▄▄▃▃▃▂▃▃▄▄▄▄▄▃▃▄▄▅▅▆▆▅▅▄▃▃▃▃▃▄▄▅▆▆▆▆▅▅▄▃▃▂▂▂▂▂▃▃▄▄▅▆▇▇▇▆▅▄▃▂▂▂▃▄▄▅▅
▄▅▅▅▅▄▄▃▃▃▄▅▅▅▄▄▃▃▃▃▄▅▅▅▅▅▅▄▄▄▄▄▅▅▆▆▆▆▅▅▄▃▃▂▂▂▂▂▃▄▄▅▅▆▇▇▇▇▆▅▄▃▂▂▂▂▃▄▄▄
▅▅▆▆▅▅▅▄▄▄▅▅▅▅▅▄▃▂▂▃▃▄▄▅▅▅▅▅▅▅▅▅▆▆▆▆▆▅▄▄▃▃▂▂▂▂▂▃▄▄▅▅▆▇▇▇▇▇▆▅▄▃▂▂▂▂▂▃▃▃
▆▆▆▆▆▆▅▅▅▅▆▆▆▆▅▄▃▂▂▂▂▃▃▄▅▅▆▆▆▆▆▆▆▇▆▆▅▄▃▃▂▂▁▁▁▂▂▃▄▅▅▆▆▇▇██▇▇▆▅▄▃▂▂▂▂▂▃▃
▆▇▇▇▇▆▆▆▆▆▆▇▇▆▅▄▃▂▁▁▁▂▂▃▄▅▆▆▇▇▇▇▇▇▇▆▅▄▃▂▁▁▁▁▁▁▂▃▄▅▅▆▆▇▇██▇▇▆▅▄▄▃▂▂▂▂▂▂
▆▇▇▇▇▇▆▆▆▆▇▇▇▇▆▄▃▁▁▁▁▁▁▂▄▅▆▇▇████▇▇▆▅▃▂▁▁▁  ▁▁▂▃▄▅▅▅▆▆▇▇▇▇▇▇▆▅▄▃▃▂▂▂▂▂
▆▇▇▇▇▇▆▆▆▆▇▇▇▇▆▅▃▁▁  ▁▁▂▃▅▆▇█████▇▇▆▅▃▂▁▁   ▁▁▂▃▄▄▄▄▅▅▆▇▇▇▇▇▆▆▅▄▃▂▂▂▂▃
▆▇▇▇▇▆▆▅▅▆▆▇▇▇▇▅▄▂▁▁▁▁▁▂▃▅▆▇███▇▇▇▆▆▅▄▃▂▁▁  ▁▁▂▃▄▄▄▃▄▄▅▆▇▇▇▇▇▆▅▄▃▃▂▂▃▃
▅▆▇▇▆▆▅▅▅▅▆▇▇▇▇▆▄▃▂▁▁▁▁▂▃▅▆▇▇▇▇▇▇▆▆▆▅▄▃▂▂▁▁▁▁▂▃▃▄▄▃▃▃▃▄▅▆▆▇▇▆▆▅▄▃▂▂▂▃▃
▅▆▆▆▆▅▄▄▄▄▅▆▇▇▇▆▅▄▃▂▂▂▂▂▃▄▅▆▆▆▆▆▅▅▅▅▅▅▄▃▃▂▁▁▂▂▃▄▄▄▃▂▂▂▃▄▅▆▆▆▆▅▅▄▃▂▂▂▃▄
▄▅▆▆▅▄▄▃▃▄▄▅▆▇▇▇▆▅▄▃▃▃▃▃▄▄▅▅▆▅▅▅▄▅▅▅▅▅▅▄▃▃▂▂▂▃▄▄▄▄▃▃▂▂▃▃▄▅▅▅▅▄▄▃▂▂▂▂▃▄
▄▅▅▅▅▄▃▃▃▃▄▅▆▇▇▇▆▆▅▄▄▄▄▄▄▄▅▅▅▄▄▄▄▄▄▅▅▆▅▅▄▃▃▃▃▄▄▅▅▅▄▃▃▃▃▃▄▄▄▄▄▄▃▂▁▁▁▂▂▃
▄▅▅▅▅▄▃▃▂▃▄▅▆▆▇▇▇▆▆▅▅▅▄▄▄▄▄▄▄▄▃▃▃▃▄▅▆▆▆▅▅▄▃▃▄▄▅▅▆▅▅▄▄▃▃▃▃▃▄▃▃▃▂▁▁▁▁▁▂▃
▃▄▅▅▄▄▃▃▃▃▄▅▆▆▇▇▇▇▆▆▅▅▅▅▅▄▄▄▄▃▃▂▂▃▄▅▆▆▆▆▅▄▄▄▄▅▆▆▆▆▆▅▅▄▃▃▃▃▂▂▂▂▁▁▁ ▁▁▂▃
▃▃▄▄▄▄▃▃▃▄▄▅▆▇▇▇▇▇▆▆▆▅▅▅▅▄▄▄▄▃▃▃▃▃▄▅▆▇▇▆▆▅▅▄▅▅▆▇▇▇▆▆▆▅▄▃▂▂▁▁▁▁▁   ▁▁▂▃
▂▃▃▄▄▄▄▄▄▄▅▆▆▇▇▇▇▇▆▆▅▅▅▄▄▄▄▄▄▄▃▃▃▄▅▆▇▇▇▇▆▅▅▅▅▅▆▇▇▇▇▇▆▆▄▃▂▁▁▁▁    ▁▁▂▃▃
▁▂▃▃▄▄▄▄▅▅▆▆▇▇▇▇▇▇▆▅▅▄▄▄▄▄▄▅▅▅▄▄▄▅▆▇▇▇▇▇▆▆▅▄▄▅▅▆▇▇▇▇▇▆▅▃▂▁▁    ▁▁▁▂▂▃▄
▁▂▃▃▄▄▅▅▅▆▆▆▇▇▇▇▇▆▅▅▄▃▃▃▃▄▄▅▅▅▅▅▅▅▆▇▇▇▇▇▆▅▄▄▄▄▄▅▆▇▇▇▇▆▅▄▂▁▁ ▁▁▁▁▁▂▂▃▄▅
▂▂▃▃▄▅▅▅▆▆▆▆▆▇▇▇▆▆▅▄▃▃▂▂▃▃▄▅▅▆▅▅▅▆▆▇▇▇▇▆▆▅▄▃▃▃▃▄▅▆▆▇▇▆▅▄▃▂▁▁▁▁▂▂▂▃▃▄▄▅
▂▃▃▄▅▅▅▅▆▆▆▆▆▆▆▆▆▅▅▄▃▃▂▂▂▃▄▅▅▆▅▅▅▆▆▇▇▇▆▆▅▄▃▂▂▂▂▃▄▅▆▆▆▆▅▄▃▂▂▂▂▃▃▃▃▄▄▄▄▅
▃▄▄▅▅▅▅▅▅▅▅▅▅▆▆▆▆▆▅▄▃▃▂▂▂▃▄▄▅▅▅▅▅▅▆▆▇▆▆▅▄▃▂▂▁▁▁▂▃▄▅▅▆▆▅▄▃▃▃▃▃▄▄▄▄▄▄▄▄▄
▄▄▅▅▅▅▅▄▄▄▄▄▄▅▅▆▆▆▅▅▄▃▃▂▂▃▃▄▄▄▄▄▄▅▅▆▆▆▆▅▄▃▂▁▁▁▁▁▂▃▄▅▅▅▅▄▄▃▃▃▄▅▅▅▅▄▄▃▃▄
▅▅▆▆▅▅▄▄▃▃▃▃▄▄▅▆▆▆▆▅▅▄▃▃▃▃▃▃▃▃▃▃▃▄▄▅▆▆▅▅▄▃▂▁   ▁▂▂▃▄▄▅▅▄▄▄▄▄▅▅▅▅▅▄▃▃▃▃
▆▆▆▆▆▅▄▃▃▂▂▃▃▄▅▆▆▆▆▆▅▅▄▃▃▂▂▂▂▂▂▂▂▂▃▄▅▅▅▄▃▃▂▁   ▁▁▂▂▃▃▄▄▄▄▄▄▅▅▆▆▆▅▄▃▃▂▂
▆▇▇▇▆▅▄▃▂▂▂▂▃▄▅▅▆▆▆▆▆▅▅▄▃▃▂▂▁▁▁▁▁▁▂▃▄▄▄▄▃▃▂▁▁   ▁▁▁▂▂▃▃▃▃▄▄▅▅▆▆▆▅▅▄▃▃▃
▇▇▇▇▆▅▄▃▂▂▂▃▃▄▅▅▆▆▆▆▆▆▅▅▄▃▂▁▁▁   ▁▁▂▃▄▄▄▄▃▃▂▁▁▁  ▁▁▁▁▂▂▂▂▃▄▄▅▅▆▆▆▅▄▄▃▃
▇▇▇▇▇▆▄▃▃▂▃▃▄▄▅▅▅▅▆▆▆▆▆▅▅▄▃▂▁     ▁▁▂▃▄▄▄▄▄▃▃▂▁▁▁▁▁▁▁▁▁▁▂▂▃▄▄▅▅▆▆▆▅▅▄▄
▇▇▇▇▇▆▄▃▃▃▄▄▅▅▅▅▅▅▅▅▅▆▆▆▆▅▃▂▁▁     ▁▁▂▃▄▄▅▅▅▄▃▃▂▁▁▁▁▁  ▁▁▁▂▃▄▄▅▅▆▆▆▆▅▅
▆▇▇▇▆▅▄▄▃▄▄▅▅▅▅▅▄▄▄▄▅▆▆▆▆▆▅▃▂▁▁▁   ▁▁▂▃▄▄▅▆▆▆▅▄▃▂▂▁▁▁▁  ▁▁▂▂▃▄▅▅▆▆▆▆▆▆
▅▆▆▆▆▅▄▄▃▄▅▅▆▅▅▄▄▃▃▄▄▅▆▇▇▆▆▄▃▂▂▂▁▁▁▁▁▂▃▄▄▅▆▆▇▆▆▄▃▃▂▂▁▁▁ ▁▁▂▂▃▄▄▅▆▇▇▆▆▆
▄▅▆▆▅▅▄▃▃▄▄▅▆▅▅▄▃▃▃▃▄▅▆▇▇▇▆▅▄▄▃▃▂▁▁▁▁▁▂▃▄▅▆▇▇▇▆▆▅▄▃▃▂▁▁▁▁▁▂▃▃▄▅▆▆▇▇▆▆▅
▄▅▅▅▅▄▃▃▃▃▄▅▅▅▄▄▃▂▃▃▄▅▆▇▇▇▇▆▅▅▄▃▃▂▁▁▁▁▂▃▄▅▆▇▇▇▇▆▅▅▄▃▃▂▂▁▁▂▃▃▄▅▅▆▆▇▆▆▅▅
▄▄▅▅▅▄▃▃▂▃▄▄▅▅▄▃▃▂▃▃▄▅▆▇▇▇▇▇▆▅▅▄▄▃▂▁▁▁▂▃▄▅▆▇▇▇▇▇▆▅▅▄▄▃▂▂▂▃▃▄▅▅▆▆▇▆▆▅▄▄
▃▄▄▅▄▄▃▂▂▃▃▄▄▄▄▃▃▂▃▃▄▅▆▇███▇▇▆▆▆▅▄▃▂▁▂▂▃▄▄▅▆▇▇▇▇▆▆▅▅▄▃▃▃▃▃▄▅▆▆▇▇▇▆▅▄▃▂
▂▃▄▄▄▄▃▃▃▃▃▄▄▄▃▃▃▃▃▄▅▆▇▇█████▇▇▇▆▅▄▃▃▂▃▃▄▄▅▆▇▇▇▆▆▅▅▅▄▃▃▃▃▄▅▅▆▇▇▇▇▆▅▃▂▁
▂▃▃▄▄▄▄▃▃▃▃▄▄▃▃▃▃▃▄▄▅▆▇████████▇▇▆▆▅▄▄▄▄▄▅▅▅▆▆▆▆▅▅▄▄▄▃▃▃▃▄▅▆▆▇▇▇▇▆▄▂▁▁
▂▂▃▄▅▅▅▄▄▄▄▄▃▃▃▃▃▃▄▅▆▆▇██████████▇▇▆▆▅▅▅▅▅▅▅▅▅▅▄▄▄▄▃▃▃▃▃▃▄▅▆▆▇▇▇▆▅▃▂▁ 
▂▂▃▅▅▆▆▆▅▅▄▄▃▃▂▂▃▃▄▅▆▇▇▇██████████▇▇▇▆▆▅▅▅▄▄▄▃▃▃▃▃▃▃▃▂▂▂▃▃▄▅▆▇▇▇▆▅▃▂▁ 
▂▃▄▅▆▇▇▆▆▅▅▄▃▂▂▂▂▃▄▅▆▆▇▇▇▇▇▇▇▇▇▇▇██▇▇▇▆▆▅▅▄▃▃▂▂▂▂▂▃▃▂▂▂▂▂▃▃▄▅▆▇▇▆▅▃▂▁▁
▃▄▅▆▇▇▇▇▆▅▅▄▃▂▁▁▂▃▄▅▅▆▆▇▇▇▆▆▆▆▆▆▇▇▇▇▇▇▆▆▅▄▃▃▂▂▂▂▂▂▃▃▂▂▂▂▂▂▃▄▅▆▆▆▆▅▄▃▂▂
▃▄▅▆▇▇▇▇▆▅▄▃▂▂▁▁▁▂▃▄▅▅▆▆▆▆▅▅▅▅▅▅▆▇▇▇▇▇▆▅▅▄▃▂▂▂▂▂▃▃▃▃▃▃▂▂▂▂▂▃▄▅▆▆▆▅▅▄▃▃
▄▅▆▇▇█▇▇▆▅▄▃▂▁▁▁▁▁▂▃▄▅▅▅▅▅▄▄▄▄▄▄▅▆▆▇▇▆▆▅▄▃▂▂▂▂▂▃▃▄▄▄▄▃▃▂▂▂▂▃▄▅▆▆▆▆▅▅▄▄
▅▅▆▇██▇▇▆▅▄▃▂▁   ▁▂▃▃▄▄▅▅▄▄▃▃▃▃▄▄▅▆▆▆▆▅▄▃▃▂▂▁▂▂▃▄▅▅▅▅▄▃▂▂▂▂▃▄▅▆▆▆▆▆▅▅▅
▅▆▇▇██▇▆▅▄▃▂▁▁   ▁▁▂▃▄▄▄▄▄▃▃▂▂▃▃▄▄▅▅▅▅▄▃▃▂▁▁▁▂▃▄▅▅▅▅▅▄▃▂▂▂▂▂▃▄▅▆▆▆▆▆▆▆
▆▇▇███▇▆▅▃▂▂▁    ▁▁▂▃▄▄▄▄▄▃▃▃▂▃▃▃▄▄▄▄▄▃▂▂▁▁▁▁▁▂▃▅▅▅▅▅▄▃▂▁▁▁▂▃▃▄▅▆▇▇▇▇▇
▇▇████▇▆▄▃▂▁▁    ▁▂▃▃▄▅▅▅▅▄▄▃▃▃▃▃▄▄▄▃▃▂▂▁▁  ▁▁▂▃▄▅▅▅▄▄▃▂▁▁▁▁▂▃▄▅▆▇▇███
▇▇████▇▆▄▃▂▁▁    ▁▂▃▄▅▅▆▆▆▅▅▄▄▄▄▄▄▃▃▃▂▂▁▁    ▁▂▂▃▄▄▄▄▃▂▁▁▁▁▁▁▂▃▄▆▇▇███
▇▇████▇▆▄▃▂▁▁   ▁▂▃▄▅▅▆▆▇▇▆▆▅▅▄▄▄▄▃▃▃▂▂▁▁▁   ▁▁▂▃▃▃▃▃▂▂▁▁▁▁▁▁▂▃▄▆▇▇███
▆▇▇███▇▆▅▃▂▂▁   ▁▂▃▄▅▆▆▇▇▇▇▇▆▅▅▄▄▄▃▃▃▃▂▂▁▁▁▁▁▁▁▂▂▃▃▃▂▂▁▁▁▁▁▁▂▂▃▄▆▆▇▇▇▇
▅▆▇▇██▇▆▅▄▃▂▁▁ ▁▁▂▃▄▅▆▆▇▇█▇▇▆▆▅▅▄▄▄▃▃▃▃▃▂▂▁▁▁▁▂▂▂▃▃▃▂▂▂▁▁▁▁▂▂▃▄▅▆▆▇▇▇▆
▅▅▆▇██▇▇▆▅▄▃▂▁▁▁▁▂▃▄▅▅▆▇▇▇▇▇▆▅▅▄▄▃▃▄▄▄▄▄▃▃▂▂▂▂▂▃▃▃▃▃▃▃▂▂▂▂▂▃▃▄▄▅▆▆▆▆▆▅
▄▅▆▇▇█▇▇▆▅▄▃▂▁▁▁▁▁▂▃▄▅▆▆▇▇▇▆▅▅▄▃▃▃▃▄▄▄▅▄▄▄▃▃▃▃▃▄▄▄▄▄▄▃▃▃▃▃▃▄▄▄▅▆▆▆▆▆▅▄
▃▄▅▆▇▇▇▇▆▅▄▃▂▁▁▁▁▁▂▃▃▄▅▆▆▆▆▆▅▄▃▃▂▃▃▄▅▅▅▅▅▄▄▄▄▄▄▅▅▅▅▅▅▄▄▄▄▄▄▄▅▅▆▆▆▆▆▅▄▄
▃▄▅▆▇▇▇▇▇▆▅▄▃▂▁▁▁▁▂▂▃▄▄▅▆▆▅▅▄▃▃▂▂▂▃▄▅▆▆▆▆▆▅▅▅▅▅▆▆▆▆▆▆▆▅▅▅▅▅▅▆▆▇▇▇▆▆▅▄▃
▃▄▄▆▇▇▇▇▇▆▅▄▃▂▁▁▁▁▂▃▃▄▄▅▅▅▄▄▃▃▂▂▂▃▄▅▆▇▇▇▇▇▆▆▆▆▇▇▇▇▇▇▇▇▆▆▅▅▆▆▆▇▇▇▇▇▆▅▄▃
▃▃▄▅▆▇▇▇▇▆▅▄▃▂▂▁▂▂▃▃▃▄▄▄▄▄▄▃▃▃▂▂▃▄▅▆▇████▇▇▇▇▇▇██████▇▇▆▆▆▆▆▇▇███▇▇▆▅▄
▃▄▄▅▆▆▇▇▆▆▅▄▃▂▂▂▃▃▄▄▄▄▄▄▃▃▃▃▃▃▃▃▄▅▆▇▇█████▇▇▇▇███████▇▇▆▆▆▆▆▇▇████▇▆▅▅
▄▄▄▄▅▆▆▆▆▆▅▄▃▂▂▃▃▄▅▅▅▄▄▃▃▂▂▂▂▃▃▄▅▆▇▇█████▇▇▇▇▇▇█████▇▇▆▆▅▅▅▆▇▇████▇▇▆▅
▄▄▄▄▄▅▆▆▆▅▄▃▃▃▃▃▄▅▅▅▅▅▄▃▂▂▂▂▂▃▄▅▆▆▇███▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▆▅▄▄▄▄▅▆▇▇███▇▇▆▆
▄▄▃▄▄▅▅▆▆▅▄▃▃▂▃▄▄▅▆▆▅▄▃▂▂▁▁▂▂▃▄▅▆▇▇▇▇▇▇▆▆▆▆▆▆▆▆▆▆▆▆▆▆▅▄▃▃▃▃▄▅▆▇▇▇▇▇▇▆▆
▄▄▃▃▄▄▅▅▅▅▄▃▂▂▃▃▄▅▅▅▅▄▃▂▁▁▁▁▂▃▄▅▆▇▇▇▇▇▆▅▅▅▅▄▄▅▅▅▅▅▅▅▄▄▃▂▂▂▃▃▄▅▆▇▇▇▇▆▆▅
▄▃▃▃▃▄▅▅▅▅▄▃▂▂▃▃▄▅▅▅▄▃▂▁▁▁▁▁▂▃▄▅▆▇▇▇▆▆▅▄▄▄▃▃▃▃▄▄▄▄▄▄▃▃▂▂▁▂▂▃▄▅▆▆▇▇▆▆▅▄
▄▃▂▃▃▄▅▅▆▅▄▃▃▂▂▃▃▄▄▄▃▂▂▁   ▁▂▃▄▅▆▆▆▆▆▅▄▃▃▃▃▂▂▂▃▃▃▃▃▃▂▂▁▁▁▁▂▃▄▅▅▆▆▆▅▅▄▃
▃▃▂▃▃▄▅▆▆▅▅▄▃▃▃▃▃▃▃▃▂▂▁    ▁▂▃▃▄▅▆▆▆▅▄▄▃▃▂▂▂▂▂▂▂▂▂▂▂▂▁▁▁▁▁▁▂▃▄▅▅▆▅▄▄▃▂
▄▃▂▃▃▄▅▆▆▆▅▄▄▃▃▃▃▃▂▂▁▁     ▁▂▃▃▄▅▅▅▅▅▄▃▃▃▂▂▂▁▁▁▁▁▁▁▁▁▁   ▁▁▂▂▃▄▅▅▄▃▂▂▁
▄▃▃▃▄▅▆▆▇▇▆▅▅▄▄▃▃▂▂▁▁▁    ▁▁▂▃▃▄▄▅▅▅▅▄▄▃▃▃▂▁▁▁   ▁▁▁▁▁    ▁▁▂▃▃▄▄▄▃▂▁▁
▄▄▃▃▄▅▆▇▇▇▆▆▅▅▄▄▃▂▂▁▁    ▁▁▂▃▃▄▄▄▄▄▅▅▅▄▄▄▃▃▂▁▁    ▁▁▁▁▁   ▁▁▂▂▃▄▄▃▃▂▁ 
▅▄▄▄▄▅▆▆▇▇▇▆▆▅▅▄▃▃▂▁▁▁  ▁▂▂▃▄▄▄▃▃▃▄▄▅▅▅▅▄▄▃▂▁▁   ▁▁▁▁▁▁▁▁▁▁▁▂▂▃▄▄▄▃▂▁▁
▅▄▄▄▄▄▅▆▇▇▆▆▆▆▅▅▄▃▃▂▁▁▁▁▂▃▄▄▅▅▄▃▃▃▃▄▅▅▆▅▅▄▄▂▁▁  ▁▁▂▂▂▂▂▂▁▁▁▁▂▃▄▄▅▄▄▃▂▁
▅▄▄▃▃▄▅▅▆▆▆▆▆▅▅▅▅▄▄▃▂▂▂▂▃▄▅▅▅▅▄▃▃▃▃▄▅▅▆▆▅▅▄▂▂▁▁▁▁▂▂▃▃▃▃▂▂▂▂▂▃▃▄▅▅▅▅▄▃▂
▅▄▃▃▃▃▄▄▅▅▅▅▅▅▅▅▅▅▄▄▃▃▂▃▄▄▅▆▆▅▄▃▃▂▃▃▄▅▅▅▅▄▃▂▁▁▁▁▂▃▃▄▄▄▄▃▃▂▂▃▃▄▅▆▆▆▆▅▄▄
▄▃▃▂▂▂▃▄▄▄▄▄▄▄▅▅▅▅▅▅▄▃▃▄▄▅▅▆▆▅▄▃▂▂▂▃▄▄▅▄▄▃▃▂▁▁▁▂▂▃▄▅▅▅▅▄▃▃▃▃▄▅▆▆▇▇▇▆▅▅
▃▃▂▂▂▂▂▃▃▃▃▃▃▄▄▅▆▆▆▅▅▄▄▄▅▅▆▆▆▅▄▃▂▂▂▂▃▄▄▄▃▃▂▁▁▁▁▂▃▄▅▅▆▆▅▅▄▄▄▄▅▅▆▇▇▇▇▇▆▅
▃▂▂▁▁▁▁▂▂▂▂▂▂▃▄▅▆▆▇▆▆▅▅▅▅▆▆▆▅▅▄▃▂▂▂▂▃▃▃▃▃▂▂▁▁▁▂▂▃▄▅▆▆▆▆▅▅▄▄▅▅▆▇▇███▇▇▆
▃▂▂▁▁▁▁▁▁▁▁▁▁▂▃▅▆▇▇▇▇▆▆▆▆▆▆▆▅▅▄▃▂▂▂▂▃▃▃▃▃▂▂▁▁▂▂▃▄▅▆▆▆▆▆▅▅▅▅▆▆▇▇██████▇
▃▂▂▁▁▁▁▁▁    ▁▂▄▆▇██▇▇▇▇▇▇▇▆▅▄▃▃▂▂▂▂▃▄▄▄▃▃▂▂▂▃▃▄▅▆▆▆▆▆▅▅▅▅▅▆▇▇████████
▄▃▂▁▁▁▁      ▁▂▄▆▇████▇▇▇▇▇▆▅▄▃▂▂▂▂▃▃▄▅▄▄▃▃▃▃▄▄▅▆▆▆▆▅▅▅▄▄▅▅▆▇▇████████
▄▃▂▂▁▁▁▁▁▁   ▁▂▃▅▇▇██▇▇██▇▇▆▆▄▃▃▂▂▂▃▄▅▅▅▅▄▄▄▄▅▅▆▆▆▆▅▅▄▃▃▄▄▅▆▇▇████████
▄▄▃▂▂▁▁▁▁▁▁▁▁▁▂▃▅▆▇▇▇▇▇▇▇▇▇▆▆▅▄▃▂▂▂▃▄▅▆▆▅▅▄▄▅▅▆▆▆▆▅▄▄▃▂▂▂▃▄▅▆▇▇███▇▇▇▇
▅▄▃▂▂▂▂▂▂▂▂▂▁▂▂▃▄▅▆▆▆▆▆▇▇▇▇▆▆▅▄▃▂▂▃▃▄▅▆▆▅▅▄▅▅▆▆▆▆▅▅▄▃▂▁▁▂▂▄▅▅▆▇▇▇▇▆▆▆▆
▄▄▃▂▂▃▃▃▄▃▃▃▂▂▂▃▃▄▅▅▅▅▆▆▇▇▇▆▆▅▄▃▂▂▃▃▄▅▅▅▅▄▄▄▅▅▆▆▆▅▄▃▂▁▁▁▁▂▃▄▅▅▆▆▆▆▅▅▅▅
▄▃▃▂▂▃▃▄▄▄▄▄▃▃▃▃▃▃▄▄▄▄▅▅▆▇▇▆▆▅▄▃▂▂▂▃▄▄▅▅▄▃▃▄▄▅▆▆▆▅▄▃▂▁  ▁▁▂▃▄▅▅▆▅▅▅▄▄▄

Noise synthesis

Noise looks much more interesting when combined.

noises = Perlin::Noise.new(2)
contrast = Perlin::Curve.contrast(Perlin::Curve::QUINTIC, 3)

100.times do |x|
  n = 0
  [[0.02, 10], [0.04, 10], [0.1, 20], [0.2, 15]].each_with_index do |step_scale, idx|
    step, scale = step_scale
    n += contrast.call( noises[idx, x * step] ) * scale
  end
  puts '=' * n.floor
end
================================
=========================================
===============================================
===============================================
========================================
===========================
===================
=====================
========================
===========================
============================
=============================
==============================
==============================
==============================
===========================
=======================
======================
======================
========================
==========================
============================
===============================
=================================
==================================
=================================
================================
=================================
==================================
=====================================
======================================
=========================================
================================================
=========================================================
===========================================================
=====================================================
==============================================
===============================================
=====================================================
=================================================
=================================
==================
=============
=============
====================
============================
=====================================
==============================================
================================================
=============================================
================================
==================
============
===========
===========
==================
=========================
==========================
===========================
================================
================================
==================================
=========================================
==================================================
====================================================
===============================================
=========================================
==========================================
==============================================
============================================
===============================
================
==========
========
==========
=============
===================
==========================
===============================
================================
=========================
================
===========
=======
======
=============
====================
======================
========================
=============================
===============================
==================================
=======================================
========================================
=========================================
================================================
======================================================
======================================================
===============================================
======================================
================================

Contributors

References