Perlin Noise Marble
noiseモジュールをインストールしてPerlin Noiseを使ってみた。
Python
# conding: utf-8 from PIL import Image import math import noise w = 128 h = 128 pn_freq_u = 10.0 pn_freq_v = 10.0 pn_octave = 3 wv_freq_x = 3.1416 * 2.0 * 10.0 wv_noise_scale = 0.1 img = Image.new('L', (w, h)) p = img.load() for y in range(h): for x in range(w): fx = x / w; fy = y / w; n = noise.pnoise2(fx * pn_freq_u, fy * pn_freq_v, pn_octave) l = (1.0 + math.sin((fx + n * wv_noise_scale) * wv_freq_x)) * 0.5 p[ x, y ] = int(l * 255.0) img.show()
割と好き。