-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
64 lines (56 loc) · 1.8 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# main.py
# todo: auto bump versions in [package.json, __init__.py, pyproject.toml, README.md]
from nPerlinNoise import *
noise = Noise(
seed=None,
frequency=8,
waveLength=128,
warp=None,
_range=None,
octaves=8,
persistence=0.5,
lacunarity=2
)
def main():
plot = 1
mul, res = 1, 2
colorMap = (
"#000",
"#b7410e",
)
gradients = Gradient.scope()
colorGradient = LinearColorGradient(*colorMap, grad='s') and LinearColorGradient.earth(grad='s')
h, coordsMesh = perlinGenerator(noise,
(0, noise.waveLength[0] * mul, noise.waveLength[0] * res),
(0, noise.waveLength[1] * mul, noise.waveLength[1] * res),
# (0, noise.waveLength[2] * mul, 3),
)
g = applyGrads(h, gradients)
c = colorGradient(g)
# c = g
if plot == -1:
from matplotlib import image
image.imsave(f'snaps/img_{noise.seed}.png', c)
elif plot == 1:
from matplotlib import pyplot
# ---matplotlib---
fig, ax = pyplot.subplots()
ax.imshow(c, cmap="gray")
pyplot.show()
elif plot == 2:
import plotly.graph_objects as go
from plotly.offline import offline
# -----plotly-----
marker_data = go.Surface(x=coordsMesh[0], y=coordsMesh[1], z=g)
fig = go.Figure(data=marker_data)
fig.update_layout(
scene=dict(zaxis=dict(nticks=4, range=[0, 2])),
width=700,
margin=dict(r=20, l=10, b=10, t=10))
fig.update_traces(contours_z=dict(
show=True, usecolormap=True,
highlightcolor='limegreen',
project_z=True))
offline.plot(fig)
if __name__ == '__main__':
main()