Skip to content

Instantly share code, notes, and snippets.

@Kakusakov
Kakusakov / Perlin.cs
Last active October 15, 2023 07:52 — forked from Flafla2/Perlin.cs
Improved Perlin Noise Implementation in C#
// Clone of https://gist.github.com/Flafla2/1a0b9ebef678bbce3215 with more dimensions and seed generation.
public class PerlinGen
{
private readonly int[] p; // Randomly shuffled array of values from 0 to 255.
// Values are repeated twice to get performance boost
// from avoiding the use of modulo operator.
public PerlinGen(int seed)
{
def simplifyExpr(target):
out = "" # output
brac = {} # dictionary matching ending positions of brackets to starting positions
bracStac = [] # stack containing positions of unclosed brackets
index = 0 # current position in target
outIndex = 0 # current position in out
skip = 0 # used to skip this many characters
for c in target:
app = ''
if(skip > 0):