Support non-integer harmonics

This commit is contained in:
Dominik Moritz Roth 2023-06-26 16:26:14 +02:00
parent 1516cb765d
commit 17dec720f1

View File

@ -114,8 +114,11 @@ class Harmonic_Perlin_Noise():
def __init__(self, known_shape=None, scale=0.1, octaves=8): def __init__(self, known_shape=None, scale=0.1, octaves=8):
self.known_shape = known_shape self.known_shape = known_shape
self.scale = scale self.scale = scale
if type(octaves) == int: if type(octaves) in [int, float]:
octaves = [1/(i+1) for i in range(octaves)] int_octaves = int(octaves)
octaves = [1/(i+1) for i in range(int_octaves)]
if type(octaves) == float:
octaves += [1/(int_octaves+2)*(octaves-int_octaves)]
octaves = np.array(octaves) octaves = np.array(octaves)
self.octaves = octaves / np.linalg.norm(octaves) self.octaves = octaves / np.linalg.norm(octaves)
self.reset() self.reset()