Skip to content

noise #

noise

This module aims to to implement noise algorithms.

It uses the rand module in vlib to generate random numbers, so you may seed the generator as you see fit.

fn Perlin.new #

fn Perlin.new() Perlin

new is a function that return a new Perlin struct

struct Perlin #

struct Perlin {
mut:
	perm []int = rand.shuffle_clone(noise.permutations) or { panic(err) }
}

Perlin is a struct that hold the permutation set for perlin noise

fn (Perlin) perlin2d #

fn (perlin Perlin) perlin2d(x f64, y f64) f64

perlin2d is a function that return a single value of perlin noise for a given 2d position

fn (Perlin) perlin3d #

fn (perlin Perlin) perlin3d(x f64, y f64, z f64) f64

perlin3d is a function that return a single value of perlin noise for a given 3d position

fn (Perlin) randomize #

fn (mut perlin Perlin) randomize()

randomize is a function that shuffle the permutation set inside the Perlin struct will not shuffle if rand.seed is not changed