diff --git a/script.js b/script.js index b476b1b..69ea160 100644 --- a/script.js +++ b/script.js @@ -21,25 +21,22 @@ this.persist = persist; this.octave = octave; - - this.#init(); - console.log("p5d: " + this.p5d); - console.log("p6d: " + this.p6d); - console.log("p10d: " + this.p10d); console.log("points:"); console.log(this.points); } #init() { this.points = []; - for(let i = 0; i < this.#NUM_POINTS; i++) { - this.points[i] = this.#perlin1D(this.persist, this.octave, 0.1 * i); - } this.p5d = this.#PRIME5[Math.floor(Math.random() * 5)]; this.p6d = this.#PRIME6[Math.floor(Math.random() * 5)]; this.p10d = this.#PRIME10[Math.floor(Math.random() * 5)]; + + for(let i = 0; i < this.#NUM_POINTS; i++) { + this.points[i] = this.#perlin1D(this.persist, this.octave, 0.1 * i); + } + } #perlin1D(persist, octave, x) { @@ -49,11 +46,8 @@ for(let i = 0; i < octave; i++) { freq = Math.pow(2,i); - console.log("freq: " + freq); amp = Math.pow(persist, i); - console.log("amp: " + amp); total += this.#interpolateNoise(x * freq) * amp; - console.log("total: " + total); } return total; @@ -66,16 +60,11 @@ * x: float value to be smoothed. */ #interpolateNoise(x) { - console.log("interpolateNoise: " + x); let intX = Math.floor(x); - console.log("intX: " + intX); let fractionX = x - intX; - console.log("fractionX: " + fractionX); let v1 = this.#smoothedNoise(intX); - console.log("v1: " + v1); let v2 = this.#smoothedNoise(intX + 1); - console.log("v2: " + v2); return this.#cosineInterpolation(v1, v2, fractionX); } @@ -97,10 +86,7 @@ #cosineInterpolation(a, b, x) { let ft = (x * Math.PI); - console.log("ft: " + ft); let f = (1 - Math.cos(ft)) * 0.5; - console.log("f: " + f); - console.log("#cosineInterp: " + (a * (1 - f) + (b * f))); return a * (1 - f) + (b * f); } @@ -120,19 +106,17 @@ * http://freespace.virgin.net/hugo.elias/models/m_perlin.htm */ #findNoise(x) { - console.log("findNoise: " + x); let z = (x << 13) ^ x; - console.log("z: " + z); - let y = 1.0 - ( z * (z * z * this.p5d + this.p6d) + this.p10d); - console.log("y: " + y); + let y = (1.0 - (( z * (z * z * this.p5d + this.p6d) + this.p10d) + & 0x7fffffff ) / 1073741824.0); return y; } } let perlin1 = new Perlin(0.3, 4); - //let perlin2 = new Perlin(0.3, 0.4); + let perlin2 = new Perlin(0.3, 0.4); }); diff --git a/style.css b/style.css index 7e82327..e7173d3 100644 --- a/style.css +++ b/style.css @@ -11,6 +11,6 @@ left: 50%; transform: translate(-50%, -50%); background: #4d79bc; - max-width: 100%; + max-width: 80%; max-height: 100%; } \ No newline at end of file