diff --git a/1/index.html b/1/index.html index 49c2083..742fe45 100644 --- a/1/index.html +++ b/1/index.html @@ -19,7 +19,8 @@ - + + diff --git a/2/index.html b/2/index.html index d846c3f..d50e81a 100644 --- a/2/index.html +++ b/2/index.html @@ -19,7 +19,8 @@ - + + diff --git a/3/index.html b/3/index.html index f38ce9c..5215b26 100644 --- a/3/index.html +++ b/3/index.html @@ -19,7 +19,8 @@ - + + diff --git a/4/index.html b/4/index.html index 849c32c..bc69b37 100644 --- a/4/index.html +++ b/4/index.html @@ -19,7 +19,8 @@ - + + diff --git a/5/index.html b/5/index.html index 701462b..865081e 100644 --- a/5/index.html +++ b/5/index.html @@ -19,7 +19,8 @@ - + + diff --git a/6/index.html b/6/index.html index 2e710d0..ca2089d 100644 --- a/6/index.html +++ b/6/index.html @@ -19,7 +19,8 @@ - + + diff --git a/7/index.html b/7/index.html index a420e92..6db0ea2 100644 --- a/7/index.html +++ b/7/index.html @@ -19,7 +19,8 @@ - + + diff --git a/8/brush-100x30.png b/8/brush-100x30.png new file mode 100644 index 0000000..18da591 Binary files /dev/null and b/8/brush-100x30.png differ diff --git a/8/brush-911x185.png b/8/brush-911x185.png new file mode 100644 index 0000000..26aede4 Binary files /dev/null and b/8/brush-911x185.png differ diff --git a/8/example.jpg b/8/example.jpg new file mode 100644 index 0000000..e3e9dbe Binary files /dev/null and b/8/example.jpg differ diff --git a/8/index.html b/8/index.html new file mode 100644 index 0000000..453f453 --- /dev/null +++ b/8/index.html @@ -0,0 +1,26 @@ + + + + + + Terra Firma - Generative Art - seigler.github.io + + + + + + + + + + + + + + + + + + + + diff --git a/app-a3c72e86.js b/app-a3c72e86.js new file mode 100644 index 0000000..5459181 --- /dev/null +++ b/app-a3c72e86.js @@ -0,0 +1 @@ +!function(){"use strict";var e="undefined"==typeof global?self:global;if("function"!=typeof e.require){var r={},o={},n={},a={}.hasOwnProperty,t=/^\.\.?(\/|$)/,i=function(e,r){for(var o,n=[],a=(t.test(r)?e+"/"+r:r).split("/"),i=0,s=a.length;i.5){c.fill("#000");var W=e.random(2*Math.PI),H=e.random(.1,1.5)*N/2,j=H*e.random(-.7,.3);c.circle((i+(j+N)*Math.cos(W))/2,(i+(j+N)*Math.sin(W))/2,2*H)}do{var B=e.random(2*Math.PI),T=e.random(2*Math.PI);c.stroke(0),c.strokeWeight(1+N*Math.pow(e.random(.7368),3)),c.line(i*(Math.sin(B)+.5),i*(Math.cos(B)+.5),i*(Math.sin(T)+.5),i*(Math.cos(T)+.5))}while(e.random()<.5+.45*I);var C=e.random(0,2*Math.PI),R=e.random(p),q=a/(g-1)*y+R*Math.cos(C),D=t/(v-1)*L+R*Math.sin(C);e.image(c,q-i/2,D-i/2)}m.shader(b),b.setUniform("u_resolution",[a,t]),b.setUniform("u_alpha",.05),m.rect(0,0,a,t),e.blendMode(e.OVERLAY),e.image(m,0,0)}function o(r){var o=0,n=0,a=null;for(o=r.length-1;o>0;o-=1)n=Math.floor(e.random()*(o+1)),a=r[o],r[o]=r[n],r[n]=a}e.disableFriendlyErrors=!0;var n,a,t,i,s,d,l,h,c,u,f,m,w,M,b;e.preload=function(){w=e.loadShader("../shaders/base.vert","../shaders/blur-two-pass.frag"),M=e.loadShader("../shaders/base.vert","../shaders/blur-two-pass.frag"),b=e.loadShader("../shaders/base.vert","../shaders/white-noise.frag")},e.setup=function(){d=2,l=2,s=70,window.onhashchange=function(){n=window.location.hash.substr(1),r()},n=window.location.hash.substr(1),e.noStroke(),e.colorMode(e.HSB,100),a=e.windowWidth,t=e.windowHeight,h=e.createCanvas(a,t),i=1.75*(a+t)/Math.sqrt(s),c=e.createGraphics(i,i),u=e.createGraphics(i,i,e.WEBGL),f=e.createGraphics(i,i,e.WEBGL),m=e.createGraphics(a,t,e.WEBGL),c.noStroke(),u.noStroke(),f.noStroke(),m.noStroke(),r()},e.draw=function(){},e.keyPressed=function(){" "==e.key?(n=null,r()):"s"==e.key&&e.saveCanvas("seigler-p5-1-gradient_burst-"+n+".jpg","jpg")},e.doubleClicked=function(){n=null,r()};var p;e.windowResized=function(){clearTimeout(p),p=setTimeout(function(){window.location.reload()},100)}})}),require.register("1/index.static.hbs",function(e,r,o){}),require.register("2/index.js",function(e,r,o){new p5(function(e){function r(){if(n)e.randomSeed(n);else{var r=Math.floor(e.random(1e12));window.location.hash=r,e.randomSeed(r)}e.noiseSeed(e.random()),e.blendMode(e.BLEND),e.background("#000"),e.blendMode(e.ADD);for(var c=a*t/s,x=Math.sqrt(c),S=Math.max(1,Math.round(t/x))+1,k=Math.max(1,Math.round(a/x))+1,E=e.random(0,1e3*d),y=[],L=0;L.5){m.fill("#000");var W=e.random(2*Math.PI),H=e.random(.1,1.5)*_/2,j=H*e.random(-.7,.3);m.circle((i+(j+_)*Math.cos(W))/2,(i+(j+_)*Math.sin(W))/2,2*H)}for(var B=i/100,T=0;T.3?u:f,0,0,V,D),m.resetMatrix()}while(e.random()<.8);var F=e.random(0,2*Math.PI),z=e.random(x),O=a/(k-1)*N+z*Math.cos(F),Y=t/(S-1)*P+z*Math.sin(F);e.image(m,O-i/2,Y-i/2)}b.shader(g),g.setUniform("u_resolution",[a,t]),g.setUniform("u_alpha",.05),b.rect(0,0,a,t),e.blendMode(e.OVERLAY),e.image(b,0,0)}function o(r){var o=0,n=0,a=null;for(o=r.length-1;o>0;o-=1)n=Math.floor(e.random()*(o+1)),a=r[o],r[o]=r[n],r[n]=a}e.disableFriendlyErrors=!0;var n,a,t,i,s,d,l,h,c,u,f,m,w,M,b,p,v,g;e.preload=function(){p=e.loadShader("../shaders/base.vert","../shaders/blur-two-pass.frag"),v=e.loadShader("../shaders/base.vert","../shaders/blur-two-pass.frag"),g=e.loadShader("../shaders/base.vert","../shaders/white-noise.frag"),u=e.loadImage("palm-leaf-1.jpg"),f=e.loadImage("palm-leaf-2.jpg")},e.setup=function(){d=2,l=6,h=2,s=80,c="seigler-p5-2-gradient_jungle-",window.onhashchange=function(){n=window.location.hash.substr(1),r()},n=window.location.hash.substr(1),e.noStroke(),e.colorMode(e.HSB,100),a=e.windowWidth,t=e.windowHeight,e.createCanvas(a,t),i=2*(a+t)/Math.sqrt(s),m=e.createGraphics(i,i),w=e.createGraphics(i,i,e.WEBGL),M=e.createGraphics(i,i,e.WEBGL),b=e.createGraphics(a,t,e.WEBGL),m.noStroke(),w.noStroke(),M.noStroke(),b.noStroke(),r()},e.draw=function(){},e.keyPressed=function(){" "==e.key?(n=null,r()):"s"==e.key&&e.saveCanvas(c+n+".jpg","jpg")},e.doubleClicked=function(){n=null,r()};var x;e.windowResized=function(){clearTimeout(x),x=setTimeout(function(){window.location.reload()},100)}})}),require.register("2/index.static.hbs",function(e,r,o){}),require.register("3/index.js",function(e,r,o){new p5(function(e){function r(){if(a)e.randomSeed(a);else{var r=Math.floor(e.random(1e12));window.location.hash=r,e.randomSeed(r)}e.noiseSeed(e.random(0,1e9)),e.blendMode(e.BLEND),e.background(291/360,.3,.25);var h=e.random(0,Math.PI),c=Math.min(t,i)/e.random(10,80),u=Math.max(t,i)*Math.SQRT2,f=Math.ceil(Math.SQRT2*u/c),m=t/2,w=i/2,M=Math.cos(h)*u/2,b=Math.sin(h)*u/2;e.strokeCap(e.SQUARE);for(var p=Math.ceil(f/2);p>0;p--)e.stroke(291/360,.3,.2+.1*(p%2)),e.strokeWeight((2*p-1)*c),e.line(m-M,w-b,m+M,w+b);d.shader(l),l.setUniform("u_resolution",[t,i]),l.setUniform("u_alpha",.05),d.rect(0,0,t,i),e.blendMode(e.OVERLAY),e.image(d,0,0),e.blendMode(e.BLEND),e.strokeCap(e.ROUND);for(var v=5,g=Math.max(1,Math.round(i/v))+1,x=Math.max(1,Math.round(t/v))+1,S=1000.37,k=[],E=function(r){var o=r%x,n=Math.floor(r/x),a=s.map(function(r,a){var t=r/Math.min(g,x);return e.noise(S*a+n*t,S*a+o*t)});k.push({row:n,col:o,noise:a})},y=0;y1.75*l-.5)){var f=t/(x-1)*s-v/2,m=i/(g-1)*a-v/2,w=2*Math.PI*n(c)+L,M=(8*u*u+1)*v;e.stroke(.075,.5,h-.2*(o/k.length)+.1),e.strokeWeight(v*(1+2*u*u*u)),e.line(f-M*Math.cos(w),m-M*Math.sin(w),f+M*Math.cos(w),m+M*Math.sin(w))}})}function o(r){var o=0,n=0,a=null;for(o=r.length-1;o>0;o-=1)n=Math.floor(e.random()*(o+1)),a=r[o],r[o]=r[n],r[n]=a}function n(e){return 23.8615*Math.pow(e,5)-59.6041*Math.pow(e,4)+47.2472*Math.pow(e,3)-11.3053*Math.pow(e,2)+.806219*e-.00259101}e.disableFriendlyErrors=!0;var a,t,i,s,d,l;e.preload=function(){l=e.loadShader("../shaders/base.vert","../shaders/white-noise.frag")},e.setup=function(){filenamePrefix="seigler-p5-3-peanut_butter_and_jelly-",t=e.windowWidth,i=e.windowHeight,s=[2,2,2,2],window.onhashchange=function(){a=window.location.hash.substr(1),r()},a=window.location.hash.substr(1),e.noStroke(),e.colorMode(e.HSL,1),e.createCanvas(t,i),d=e.createGraphics(t,i,e.WEBGL),d.noStroke(),r()},e.draw=function(){},e.keyPressed=function(){" "==e.key?(a=null,r()):"s"==e.key&&e.saveCanvas(filenamePrefix+a+".jpg","jpg")},e.doubleClicked=function(){a=null,r()};var h;e.windowResized=function(){clearTimeout(h),h=setTimeout(function(){window.location.reload()},100)}})}),require.register("3/index.static.hbs",function(e,r,o){}),require.register("4/index.js",function(e,r,o){new p5(function(e){function r(){if(n)e.randomSeed(n);else{var r=Math.floor(e.random(1e12));window.location.hash=r,e.randomSeed(r)}e.noiseSeed(e.random(0,1e9)),e.blendMode(e.BLEND);var u=e.random(0,Math.PI),f=Math.min(a,t)/e.random(10,80),m=Math.max(a,t)*Math.SQRT2,w=Math.ceil(Math.SQRT2*m/f),M=e.random(),b=a/2,p=t/2,v=Math.cos(u)*m/2,g=Math.sin(u)*m/2;l.buffer.strokeCap(e.SQUARE);for(var x=Math.ceil(w/2);x>0;x--)l.buffer.stroke(M,.5,.2+.1*(x%2)),l.buffer.strokeWeight((2*x-1)*f),l.buffer.line(b-v,p-g,b+v,p+g);e.blendMode(e.BLEND);for(var S=Math.min(a,t)/Math.round(e.random(3,10)),k=Math.max(1,Math.round(t/S/Math.sin(Math.PI/3)))+1,E=Math.max(1,Math.round(a/S))+1,y=200*S+Math.SQRT2,L=[],I=function(r){var o=r%E,n=Math.floor(r/E),a=i.map(function(r,a){return e.noise(y*(a+1)+(n-k/2)*r,y*(a+1)+(o-E/2)*r)});L.push({row:n,col:o,noise:a})},N=0;N=3){l.cells.fill(r.site.noise[2]),l.cells.beginShape();for(var o=0;o.5?n.y=e.random()>.5?t*s*.4:t*(1-.4*s):n.x=e.random()>.5?a*s*.4:a*(1-.4*s);var i=e.random(Math.PI/8,Math.PI),d=Math.atan2(t/2-n.y,a/2-n.x);d+=e.random(-.25,.25)*i,r.beginShape(),r.vertex(n.x,n.y);var l=0;do{var h=n.x,u=n.y,f=n.x+c/2*Math.cos(d),m=n.y+c/2*Math.sin(d);d+=e.random(-1,1)*i,r.quadraticVertex(h,u,e.lerp(h,f,.5),e.lerp(u,m,.5)),n={x:f,y:m},l++}while(l<80||n.x>-c/2&&n.x-c/2&&n.y1)for(var S=0,k=0===f?1:Math.ceil(.8+e.random(1.2));S1?c*e.map(S,0,k-1,-.5,.5):0);t(r,o,{x:g,y:x},E,.9*i,s,e.map(Math.cos(E-a),0,1,0,d*(1-(m+i)/h)),l,h,c,u,f+1,m+i)}else{var y=s*e.random(.7,1.8);o.circle(g,x,y);for(var L=1;Ll&&(l=e[r][0]),e[r][1]h&&(h=e[r][1]);return o=l-s,n=h-d,a=Math.max(o,n),t=s+.5*o,i=d+.5*n,[[t-20*a,i-a],[t,i+20*a],[t+20*a,i-a]]}function r(e,r,o,n){var a,i,s,d,l,h,c,u,f,m,w=e[r][0],M=e[r][1],b=e[o][0],p=e[o][1],v=e[n][0],g=e[n][1],x=Math.abs(M-p),S=Math.abs(p-g);if(xS?s*(a-l)+c:d*(a-h)+u),f=b-a,m=p-i,{i:r,j:o,k:n,x:a,y:i,r:f*f+m*m}}function a(e){var r,o,n,a,t,i;for(o=e.length;o;)for(a=e[--o],n=e[--o],r=o;r;)if(i=e[--r],t=e[--r],n===t&&a===i||n===i&&a===t){e.splice(o,2),e.splice(r,2);break}}var t=1/1048576;n={triangulate:function(o,n){var i,s,d,l,h,c,u,f,m,w,M,b,p=o.length;if(p<3)return[];if(o=o.slice(0),n)for(i=p;i--;)o[i]=o[i][n];for(d=new Array(p),i=p;i--;)d[i]=i;for(d.sort(function(e,r){var n=o[r][0]-o[e][0];return 0!==n?n:e-r}),l=e(o),o.push(l[0],l[1],l[2]),h=[r(o,p+0,p+1,p+2)],c=[],u=[],i=d.length;i--;u.length=0){for(b=d[i],s=h.length;s--;)f=o[b][0]-h[s].x,f>0&&f*f>h[s].r?(c.push(h[s]),h.splice(s,1)):(m=o[b][1]-h[s].y,f*f+m*m-h[s].r>t||(u.push(h[s].i,h[s].j,h[s].j,h[s].k,h[s].k,h[s].i),h.splice(s,1)));for(a(u),s=u.length;s;)M=u[--s],w=u[--s],h.push(r(o,w,M,b))}for(i=h.length;i--;)c.push(h[i]);for(h.length=0,i=c.length;i--;)c[i].ie[0][0]&&r[0]>e[1][0]&&r[0]>e[2][0]||r[1]e[0][1]&&r[1]>e[1][1]&&r[1]>e[2][1])return null;var o=e[1][0]-e[0][0],n=e[2][0]-e[0][0],a=e[1][1]-e[0][1],t=e[2][1]-e[0][1],i=o*t-n*a;if(0===i)return null;var s=(t*(r[0]-e[0][0])-n*(r[1]-e[0][1]))/i,d=(o*(r[1]-e[0][1])-a*(r[0]-e[0][0]))/i;return s<0||d<0||s+d>1?null:[s,d]}},"undefined"!=typeof o&&(o.exports=n)}()}),require.register("7/index.js",function(e,r,o){var n=r("./delaunay.js");new p5(function(e){function r(){if(a)e.randomSeed(a);else{var r=Math.floor(e.random(1e12));window.location.hash=r,e.randomSeed(r)}e.noiseSeed(e.random(0,1e9)),h.stars.clear(),h.stars.fill(1),h.stars.noStroke(),o(h.stars),e.blendMode(e.BLEND),e.background(0),h.noise.shader(c.whiteNoise),c.whiteNoise.setUniform("u_resolution",[t,i]),c.whiteNoise.setUniform("u_alpha",.05),h.noise.rect(0,0,t,i),e.image(h.stars,Math.round(-t*d/2),Math.round(-i*d/2)),e.blendMode(e.OVERLAY),e.image(h.noise,0,0)}function o(r){for(var o=new Array(Math.round(t*i/2e3)),a=new Array(Math.round(t*i/200)),s=0;s.85&&r.triangle(o[l[h]][0],o[l[h]][1],o[l[h+1]][0],o[l[h+1]][1],o[l[h+2]][0],o[l[h+2]][1]);r.noStroke(),r.fill(1),o.forEach(function(o){r.circle(o[0],o[1],e.random(.75,2))})}e.disableFriendlyErrors=!0;var a,t,i,s,d,l,h={},c={};e.preload=function(){c.whiteNoise=e.loadShader("../shaders/base.vert","../shaders/white-noise.frag")},e.setup=function(){filenamePrefix="seigler-p5-7-estrellas-",d=.1,t=Math.floor(e.windowWidth*(1+d)),i=Math.floor(e.windowHeight*(1+d)),s=[.2,.1,.05,2],l=2,window.onhashchange=function(){a=window.location.hash.substr(1),r()},a=window.location.hash.substr(1),e.colorMode(e.HSL,1),e.createCanvas(e.windowWidth,e.windowHeight),h.stars=e.createGraphics(t,i),h.stars.colorMode(e.HSL,1),h.noise=e.createGraphics(t,i,e.WEBGL),r()},e.draw=function(){},e.keyReleased=function(){" "==e.key?(a=null,r()):"s"==e.key&&e.saveCanvas(filenamePrefix+a+".jpg","jpg")},e.doubleClicked=function(){a=null,r()};var u;e.windowResized=function(){clearTimeout(u),u=setTimeout(function(){window.location.reload()},100)}})}),require.register("7/index.static.hbs",function(e,r,o){}),require.register("8/index.js",function(e,r,o){new p5(function(e){function r(){if(i)e.randomSeed(i);else{var r=Math.floor(e.random(1e12));window.location.hash=r,e.randomSeed(r)}e.noiseSeed(e.random(0,1e9)),m.simplex=new SimplexNoise(e.random(0,1e9)),u.contours.clear(),o(u.contours),e.blendMode(e.BLEND),e.background(0),u.noise.shader(f.whiteNoise),f.whiteNoise.setUniform("u_resolution",[s,d]),f.whiteNoise.setUniform("u_alpha",.05),u.noise.rect(0,0,s,d),e.image(u.contours,Math.round(-s*h/2),Math.round(-d*h/2)),e.blendMode(e.OVERLAY),e.image(u.noise,0,0)}function o(r){var o=3/(s+d),i=Math.round(Math.sqrt(s*d)/1440*100);u.contours.imageMode(e.CENTER);var l=n(0,0,s,d,15*i);r.noStroke(),l.forEach(function(n){var t=n.x,i=n.y,s=a(t,i,o),d=s.noise,l=s.angle;d<.5?r.tint(218/360,.8,.1+e.random(.05)+2*d*.2):r.tint(119/360,.8,.1+e.random(.05)+2*(d-.5)*.2);var h=200;r.translate(t,i),r.rotate(l+(d<.5?e.HALF_PI:0)),r.image(w.stroke,0,0,h,h/3),r.resetMatrix()});var h=n(0,0,s,d,5*i);r.noTint(),r.strokeCap(e.SQUARE),h.forEach(function(n){for(var s=n.x+e.random(-50,50),d=n.y+e.random(-50,50),l=t(s,d,o),h=0,c=i/2,u=s,f=d;h.5?r.stroke(0,.8):r.stroke(1,.5),r.strokeWeight(Math.sin(h/c*Math.PI)),r.line(u,f,u+M,f+b),u+=M,f+=b}})}function n(e,r,o,n,a){for(var t=o-e,i=n-r,s=Math.sqrt(t*i/Math.sin(Math.PI/3)/a),d=Math.max(1,Math.round(i/s/Math.sin(Math.PI/3)))+1,l=Math.max(1,Math.round(t/s))+1,h=[],c=0;c1&&r(e[e.length-2]+"/index")})}),require.register("___globals___",function(e,r,o){})}(),require("___globals___"),require("initialize"); \ No newline at end of file diff --git a/app-f9cd5a4f.js b/app-f9cd5a4f.js deleted file mode 100644 index efdbfcb..0000000 --- a/app-f9cd5a4f.js +++ /dev/null @@ -1 +0,0 @@ -!function(){"use strict";var e="undefined"==typeof global?self:global;if("function"!=typeof e.require){var r={},o={},a={},n={}.hasOwnProperty,t=/^\.\.?(\/|$)/,i=function(e,r){for(var o,a=[],n=(t.test(r)?e+"/"+r:r).split("/"),i=0,s=n.length;i.5){c.fill("#000");var W=e.random(2*Math.PI),j=e.random(.1,1.5)*N/2,H=j*e.random(-.7,.3);c.circle((i+(H+N)*Math.cos(W))/2,(i+(H+N)*Math.sin(W))/2,2*j)}do{var B=e.random(2*Math.PI),T=e.random(2*Math.PI);c.stroke(0),c.strokeWeight(1+N*Math.pow(e.random(.7368),3)),c.line(i*(Math.sin(B)+.5),i*(Math.cos(B)+.5),i*(Math.sin(T)+.5),i*(Math.cos(T)+.5))}while(e.random()<.5+.45*I);var q=e.random(0,2*Math.PI),C=e.random(p),R=n/(g-1)*y+C*Math.cos(q),V=t/(v-1)*L+C*Math.sin(q);e.image(c,R-i/2,V-i/2)}m.shader(b),b.setUniform("u_resolution",[n,t]),b.setUniform("u_alpha",.05),m.rect(0,0,n,t),e.blendMode(e.OVERLAY),e.image(m,0,0)}function o(r){var o=0,a=0,n=null;for(o=r.length-1;o>0;o-=1)a=Math.floor(e.random()*(o+1)),n=r[o],r[o]=r[a],r[a]=n}e.disableFriendlyErrors=!0;var a,n,t,i,s,d,l,h,c,u,f,m,w,M,b;e.preload=function(){w=e.loadShader("../shaders/base.vert","../shaders/blur-two-pass.frag"),M=e.loadShader("../shaders/base.vert","../shaders/blur-two-pass.frag"),b=e.loadShader("../shaders/base.vert","../shaders/white-noise.frag")},e.setup=function(){d=2,l=2,s=70,window.onhashchange=function(){a=window.location.hash.substr(1),r()},a=window.location.hash.substr(1),e.noStroke(),e.colorMode(e.HSB,100),n=e.windowWidth,t=e.windowHeight,h=e.createCanvas(n,t),i=1.75*(n+t)/Math.sqrt(s),c=e.createGraphics(i,i),u=e.createGraphics(i,i,e.WEBGL),f=e.createGraphics(i,i,e.WEBGL),m=e.createGraphics(n,t,e.WEBGL),c.noStroke(),u.noStroke(),f.noStroke(),m.noStroke(),r()},e.draw=function(){},e.keyPressed=function(){" "==e.key?(a=null,r()):"s"==e.key&&e.saveCanvas("seigler-p5-1-gradient_burst-"+a+".jpg","jpg")},e.doubleClicked=function(){a=null,r()};var p;e.windowResized=function(){clearTimeout(p),p=setTimeout(function(){window.location.reload()},100)}})}),require.register("1/index.static.hbs",function(e,r,o){}),require.register("2/index.js",function(e,r,o){new p5(function(e){function r(){if(a)e.randomSeed(a);else{var r=Math.floor(e.random(1e12));window.location.hash=r,e.randomSeed(r)}e.noiseSeed(e.random()),e.blendMode(e.BLEND),e.background("#000"),e.blendMode(e.ADD);for(var c=n*t/s,S=Math.sqrt(c),k=Math.max(1,Math.round(t/S))+1,x=Math.max(1,Math.round(n/S))+1,E=e.random(0,1e3*d),y=[],L=0;L.5){m.fill("#000");var W=e.random(2*Math.PI),j=e.random(.1,1.5)*_/2,H=j*e.random(-.7,.3);m.circle((i+(H+_)*Math.cos(W))/2,(i+(H+_)*Math.sin(W))/2,2*j)}for(var B=i/100,T=0;T.3?u:f,0,0,D,V),m.resetMatrix()}while(e.random()<.8);var A=e.random(0,2*Math.PI),O=e.random(S),F=n/(x-1)*N+O*Math.cos(A),Y=t/(k-1)*U+O*Math.sin(A);e.image(m,F-i/2,Y-i/2)}b.shader(g),g.setUniform("u_resolution",[n,t]),g.setUniform("u_alpha",.05),b.rect(0,0,n,t),e.blendMode(e.OVERLAY),e.image(b,0,0)}function o(r){var o=0,a=0,n=null;for(o=r.length-1;o>0;o-=1)a=Math.floor(e.random()*(o+1)),n=r[o],r[o]=r[a],r[a]=n}e.disableFriendlyErrors=!0;var a,n,t,i,s,d,l,h,c,u,f,m,w,M,b,p,v,g;e.preload=function(){p=e.loadShader("../shaders/base.vert","../shaders/blur-two-pass.frag"),v=e.loadShader("../shaders/base.vert","../shaders/blur-two-pass.frag"),g=e.loadShader("../shaders/base.vert","../shaders/white-noise.frag"),u=e.loadImage("palm-leaf-1.jpg"),f=e.loadImage("palm-leaf-2.jpg")},e.setup=function(){d=2,l=6,h=2,s=80,c="seigler-p5-2-gradient_jungle-",window.onhashchange=function(){a=window.location.hash.substr(1),r()},a=window.location.hash.substr(1),e.noStroke(),e.colorMode(e.HSB,100),n=e.windowWidth,t=e.windowHeight,e.createCanvas(n,t),i=2*(n+t)/Math.sqrt(s),m=e.createGraphics(i,i),w=e.createGraphics(i,i,e.WEBGL),M=e.createGraphics(i,i,e.WEBGL),b=e.createGraphics(n,t,e.WEBGL),m.noStroke(),w.noStroke(),M.noStroke(),b.noStroke(),r()},e.draw=function(){},e.keyPressed=function(){" "==e.key?(a=null,r()):"s"==e.key&&e.saveCanvas(c+a+".jpg","jpg")},e.doubleClicked=function(){a=null,r()};var S;e.windowResized=function(){clearTimeout(S),S=setTimeout(function(){window.location.reload()},100)}})}),require.register("2/index.static.hbs",function(e,r,o){}),require.register("3/index.js",function(e,r,o){new p5(function(e){function r(){if(n)e.randomSeed(n);else{var r=Math.floor(e.random(1e12));window.location.hash=r,e.randomSeed(r)}e.noiseSeed(e.random(0,1e9)),e.blendMode(e.BLEND),e.background(291/360,.3,.25);var h=e.random(0,Math.PI),c=Math.min(t,i)/e.random(10,80),u=Math.max(t,i)*Math.SQRT2,f=Math.ceil(Math.SQRT2*u/c),m=t/2,w=i/2,M=Math.cos(h)*u/2,b=Math.sin(h)*u/2;e.strokeCap(e.SQUARE);for(var p=Math.ceil(f/2);p>0;p--)e.stroke(291/360,.3,.2+.1*(p%2)),e.strokeWeight((2*p-1)*c),e.line(m-M,w-b,m+M,w+b);d.shader(l),l.setUniform("u_resolution",[t,i]),l.setUniform("u_alpha",.05),d.rect(0,0,t,i),e.blendMode(e.OVERLAY),e.image(d,0,0),e.blendMode(e.BLEND),e.strokeCap(e.ROUND);for(var v=5,g=Math.max(1,Math.round(i/v))+1,S=Math.max(1,Math.round(t/v))+1,k=1000.37,x=[],E=function(r){var o=r%S,a=Math.floor(r/S),n=s.map(function(r,n){var t=r/Math.min(g,S);return e.noise(k*n+a*t,k*n+o*t)});x.push({row:a,col:o,noise:n})},y=0;y1.75*l-.5)){var f=t/(S-1)*s-v/2,m=i/(g-1)*n-v/2,w=2*Math.PI*a(c)+L,M=(8*u*u+1)*v;e.stroke(.075,.5,h-.2*(o/x.length)+.1),e.strokeWeight(v*(1+2*u*u*u)),e.line(f-M*Math.cos(w),m-M*Math.sin(w),f+M*Math.cos(w),m+M*Math.sin(w))}})}function o(r){var o=0,a=0,n=null;for(o=r.length-1;o>0;o-=1)a=Math.floor(e.random()*(o+1)),n=r[o],r[o]=r[a],r[a]=n}function a(e){return 23.8615*Math.pow(e,5)-59.6041*Math.pow(e,4)+47.2472*Math.pow(e,3)-11.3053*Math.pow(e,2)+.806219*e-.00259101}e.disableFriendlyErrors=!0;var n,t,i,s,d,l;e.preload=function(){l=e.loadShader("../shaders/base.vert","../shaders/white-noise.frag")},e.setup=function(){filenamePrefix="seigler-p5-3-peanut_butter_and_jelly-",t=e.windowWidth,i=e.windowHeight,s=[2,2,2,2],window.onhashchange=function(){n=window.location.hash.substr(1),r()},n=window.location.hash.substr(1),e.noStroke(),e.colorMode(e.HSL,1),e.createCanvas(t,i),d=e.createGraphics(t,i,e.WEBGL),d.noStroke(),r()},e.draw=function(){},e.keyPressed=function(){" "==e.key?(n=null,r()):"s"==e.key&&e.saveCanvas(filenamePrefix+n+".jpg","jpg")},e.doubleClicked=function(){n=null,r()};var h;e.windowResized=function(){clearTimeout(h),h=setTimeout(function(){window.location.reload()},100)}})}),require.register("3/index.static.hbs",function(e,r,o){}),require.register("4/index.js",function(e,r,o){new p5(function(e){function r(){if(a)e.randomSeed(a);else{var r=Math.floor(e.random(1e12));window.location.hash=r,e.randomSeed(r)}e.noiseSeed(e.random(0,1e9)),e.blendMode(e.BLEND);var u=e.random(0,Math.PI),f=Math.min(n,t)/e.random(10,80),m=Math.max(n,t)*Math.SQRT2,w=Math.ceil(Math.SQRT2*m/f),M=e.random(),b=n/2,p=t/2,v=Math.cos(u)*m/2,g=Math.sin(u)*m/2;l.buffer.strokeCap(e.SQUARE);for(var S=Math.ceil(w/2);S>0;S--)l.buffer.stroke(M,.5,.2+.1*(S%2)),l.buffer.strokeWeight((2*S-1)*f),l.buffer.line(b-v,p-g,b+v,p+g);e.blendMode(e.BLEND);for(var k=Math.min(n,t)/Math.round(e.random(3,10)),x=Math.max(1,Math.round(t/k/Math.sin(Math.PI/3)))+1,E=Math.max(1,Math.round(n/k))+1,y=200*k+Math.SQRT2,L=[],I=function(r){var o=r%E,a=Math.floor(r/E),n=i.map(function(r,n){return e.noise(y*(n+1)+(a-x/2)*r,y*(n+1)+(o-E/2)*r)});L.push({row:a,col:o,noise:n})},N=0;N=3){l.cells.fill(r.site.noise[2]),l.cells.beginShape();for(var o=0;o.5?a.y=e.random()>.5?t*s*.4:t*(1-.4*s):a.x=e.random()>.5?n*s*.4:n*(1-.4*s);var i=e.random(Math.PI/8,Math.PI),d=Math.atan2(t/2-a.y,n/2-a.x);d+=e.random(-.25,.25)*i,r.beginShape(),r.vertex(a.x,a.y);var l=0;do{var h=a.x,u=a.y,f=a.x+c/2*Math.cos(d),m=a.y+c/2*Math.sin(d);d+=e.random(-1,1)*i,r.quadraticVertex(h,u,e.lerp(h,f,.5),e.lerp(u,m,.5)),a={x:f,y:m},l++}while(l<80||a.x>-c/2&&a.x-c/2&&a.y1)for(var k=0,x=0===f?1:Math.ceil(.8+e.random(1.2));k1?c*e.map(k,0,x-1,-.5,.5):0);t(r,o,{x:g,y:S},E,.9*i,s,e.map(Math.cos(E-n),0,1,0,d*(1-(m+i)/h)),l,h,c,u,f+1,m+i)}else{var y=s*e.random(.7,1.8);o.circle(g,S,y);for(var L=1;Ll&&(l=e[r][0]),e[r][1]h&&(h=e[r][1]);return o=l-s,a=h-d,n=Math.max(o,a),t=s+.5*o,i=d+.5*a,[[t-20*n,i-n],[t,i+20*n],[t+20*n,i-n]]}function r(e,r,o,a){var n,i,s,d,l,h,c,u,f,m,w=e[r][0],M=e[r][1],b=e[o][0],p=e[o][1],v=e[a][0],g=e[a][1],S=Math.abs(M-p),k=Math.abs(p-g);if(Sk?s*(n-l)+c:d*(n-h)+u),f=b-n,m=p-i,{i:r,j:o,k:a,x:n,y:i,r:f*f+m*m}}function n(e){var r,o,a,n,t,i;for(o=e.length;o;)for(n=e[--o],a=e[--o],r=o;r;)if(i=e[--r],t=e[--r],a===t&&n===i||a===i&&n===t){e.splice(o,2),e.splice(r,2);break}}var t=1/1048576;a={triangulate:function(o,a){var i,s,d,l,h,c,u,f,m,w,M,b,p=o.length;if(p<3)return[];if(o=o.slice(0),a)for(i=p;i--;)o[i]=o[i][a];for(d=new Array(p),i=p;i--;)d[i]=i;for(d.sort(function(e,r){var a=o[r][0]-o[e][0];return 0!==a?a:e-r}),l=e(o),o.push(l[0],l[1],l[2]),h=[r(o,p+0,p+1,p+2)],c=[],u=[],i=d.length;i--;u.length=0){for(b=d[i],s=h.length;s--;)f=o[b][0]-h[s].x,f>0&&f*f>h[s].r?(c.push(h[s]),h.splice(s,1)):(m=o[b][1]-h[s].y,f*f+m*m-h[s].r>t||(u.push(h[s].i,h[s].j,h[s].j,h[s].k,h[s].k,h[s].i),h.splice(s,1)));for(n(u),s=u.length;s;)M=u[--s],w=u[--s],h.push(r(o,w,M,b))}for(i=h.length;i--;)c.push(h[i]);for(h.length=0,i=c.length;i--;)c[i].ie[0][0]&&r[0]>e[1][0]&&r[0]>e[2][0]||r[1]e[0][1]&&r[1]>e[1][1]&&r[1]>e[2][1])return null;var o=e[1][0]-e[0][0],a=e[2][0]-e[0][0],n=e[1][1]-e[0][1],t=e[2][1]-e[0][1],i=o*t-a*n;if(0===i)return null;var s=(t*(r[0]-e[0][0])-a*(r[1]-e[0][1]))/i,d=(o*(r[1]-e[0][1])-n*(r[0]-e[0][0]))/i;return s<0||d<0||s+d>1?null:[s,d]}},"undefined"!=typeof o&&(o.exports=a)}()}),require.register("7/index.js",function(e,r,o){var a=r("./delaunay.js");new p5(function(e){function r(){if(n)e.randomSeed(n);else{var r=Math.floor(e.random(1e12));window.location.hash=r,e.randomSeed(r)}e.noiseSeed(e.random(0,1e9)),h.stars.clear(),h.stars.fill(1),h.stars.noStroke(),o(h.stars),e.blendMode(e.BLEND),e.background(0),h.noise.shader(c.whiteNoise),c.whiteNoise.setUniform("u_resolution",[t,i]),c.whiteNoise.setUniform("u_alpha",.05),h.noise.rect(0,0,t,i),e.image(h.stars,Math.round(-t*d/2),Math.round(-i*d/2)),e.blendMode(e.OVERLAY),e.image(h.noise,0,0)}function o(r){for(var o=new Array(Math.round(t*i/2e3)),n=new Array(Math.round(t*i/200)),s=0;s.85&&r.triangle(o[l[h]][0],o[l[h]][1],o[l[h+1]][0],o[l[h+1]][1],o[l[h+2]][0],o[l[h+2]][1]);r.noStroke(),r.fill(1),o.forEach(function(o){r.circle(o[0],o[1],e.random(.75,2))})}e.disableFriendlyErrors=!1;var n,t,i,s,d,l,h={},c={};e.preload=function(){c.whiteNoise=e.loadShader("../shaders/base.vert","../shaders/white-noise.frag")},e.setup=function(){filenamePrefix="seigler-p5-7-estrellas-",d=.1,t=Math.floor(e.windowWidth*(1+d)),i=Math.floor(e.windowHeight*(1+d)),s=[.2,.1,.05,2],l=2,window.onhashchange=function(){n=window.location.hash.substr(1),r()},n=window.location.hash.substr(1),e.colorMode(e.HSL,1),e.createCanvas(e.windowWidth,e.windowHeight),h.stars=e.createGraphics(t,i),h.stars.colorMode(e.HSL,1),h.noise=e.createGraphics(t,i,e.WEBGL),r()},e.draw=function(){},e.keyReleased=function(){" "==e.key?(n=null,r()):"s"==e.key&&e.saveCanvas(filenamePrefix+n+".jpg","jpg")},e.doubleClicked=function(){n=null,r()};var u;e.windowResized=function(){clearTimeout(u),u=setTimeout(function(){window.location.reload()},100)}})}),require.register("7/index.static.hbs",function(e,r,o){}),require.register("index.static.hbs",function(e,r,o){}),require.register("initialize.js",function(e,r,o){document.addEventListener("DOMContentLoaded",function(){var e=document.location.pathname.split("/");e.length>1&&r(e[e.length-2]+"/index")})}),require.register("___globals___",function(e,r,o){})}(),require("___globals___"),require("initialize"); \ No newline at end of file diff --git a/index.html b/index.html index 66eef64..5e1da0e 100644 --- a/index.html +++ b/index.html @@ -10,6 +10,13 @@

P5.js generative art

+
+ a brush stroked map of sea and land, with breezy black and white contour lines marking the elevation +
+
Terra Firma
+
2019-11-18
+
+
a field of stars with triangular blue constellations highlighted
diff --git a/modules/simplex-noise.js b/modules/simplex-noise.js new file mode 100644 index 0000000..eac2929 --- /dev/null +++ b/modules/simplex-noise.js @@ -0,0 +1,473 @@ +/* + * A fast javascript implementation of simplex noise by Jonas Wagner + +Based on a speed-improved simplex noise algorithm for 2D, 3D and 4D in Java. +Which is based on example code by Stefan Gustavson (stegu@itn.liu.se). +With Optimisations by Peter Eastman (peastman@drizzle.stanford.edu). +Better rank ordering method by Stefan Gustavson in 2012. + + + Copyright (c) 2018 Jonas Wagner + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + */ +(function() { + 'use strict'; + + var F2 = 0.5 * (Math.sqrt(3.0) - 1.0); + var G2 = (3.0 - Math.sqrt(3.0)) / 6.0; + var F3 = 1.0 / 3.0; + var G3 = 1.0 / 6.0; + var F4 = (Math.sqrt(5.0) - 1.0) / 4.0; + var G4 = (5.0 - Math.sqrt(5.0)) / 20.0; + + function SimplexNoise(randomOrSeed) { + var random; + if (typeof randomOrSeed == 'function') { + random = randomOrSeed; + } + else if (randomOrSeed) { + random = alea(randomOrSeed); + } else { + random = Math.random; + } + this.p = buildPermutationTable(random); + this.perm = new Uint8Array(512); + this.permMod12 = new Uint8Array(512); + for (var i = 0; i < 512; i++) { + this.perm[i] = this.p[i & 255]; + this.permMod12[i] = this.perm[i] % 12; + } + + } + SimplexNoise.prototype = { + grad3: new Float32Array([1, 1, 0, + -1, 1, 0, + 1, -1, 0, + + -1, -1, 0, + 1, 0, 1, + -1, 0, 1, + + 1, 0, -1, + -1, 0, -1, + 0, 1, 1, + + 0, -1, 1, + 0, 1, -1, + 0, -1, -1]), + grad4: new Float32Array([0, 1, 1, 1, 0, 1, 1, -1, 0, 1, -1, 1, 0, 1, -1, -1, + 0, -1, 1, 1, 0, -1, 1, -1, 0, -1, -1, 1, 0, -1, -1, -1, + 1, 0, 1, 1, 1, 0, 1, -1, 1, 0, -1, 1, 1, 0, -1, -1, + -1, 0, 1, 1, -1, 0, 1, -1, -1, 0, -1, 1, -1, 0, -1, -1, + 1, 1, 0, 1, 1, 1, 0, -1, 1, -1, 0, 1, 1, -1, 0, -1, + -1, 1, 0, 1, -1, 1, 0, -1, -1, -1, 0, 1, -1, -1, 0, -1, + 1, 1, 1, 0, 1, 1, -1, 0, 1, -1, 1, 0, 1, -1, -1, 0, + -1, 1, 1, 0, -1, 1, -1, 0, -1, -1, 1, 0, -1, -1, -1, 0]), + noise2D: function(xin, yin) { + var permMod12 = this.permMod12; + var perm = this.perm; + var grad3 = this.grad3; + var n0 = 0; // Noise contributions from the three corners + var n1 = 0; + var n2 = 0; + // Skew the input space to determine which simplex cell we're in + var s = (xin + yin) * F2; // Hairy factor for 2D + var i = Math.floor(xin + s); + var j = Math.floor(yin + s); + var t = (i + j) * G2; + var X0 = i - t; // Unskew the cell origin back to (x,y) space + var Y0 = j - t; + var x0 = xin - X0; // The x,y distances from the cell origin + var y0 = yin - Y0; + // For the 2D case, the simplex shape is an equilateral triangle. + // Determine which simplex we are in. + var i1, j1; // Offsets for second (middle) corner of simplex in (i,j) coords + if (x0 > y0) { + i1 = 1; + j1 = 0; + } // lower triangle, XY order: (0,0)->(1,0)->(1,1) + else { + i1 = 0; + j1 = 1; + } // upper triangle, YX order: (0,0)->(0,1)->(1,1) + // A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and + // a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where + // c = (3-sqrt(3))/6 + var x1 = x0 - i1 + G2; // Offsets for middle corner in (x,y) unskewed coords + var y1 = y0 - j1 + G2; + var x2 = x0 - 1.0 + 2.0 * G2; // Offsets for last corner in (x,y) unskewed coords + var y2 = y0 - 1.0 + 2.0 * G2; + // Work out the hashed gradient indices of the three simplex corners + var ii = i & 255; + var jj = j & 255; + // Calculate the contribution from the three corners + var t0 = 0.5 - x0 * x0 - y0 * y0; + if (t0 >= 0) { + var gi0 = permMod12[ii + perm[jj]] * 3; + t0 *= t0; + n0 = t0 * t0 * (grad3[gi0] * x0 + grad3[gi0 + 1] * y0); // (x,y) of grad3 used for 2D gradient + } + var t1 = 0.5 - x1 * x1 - y1 * y1; + if (t1 >= 0) { + var gi1 = permMod12[ii + i1 + perm[jj + j1]] * 3; + t1 *= t1; + n1 = t1 * t1 * (grad3[gi1] * x1 + grad3[gi1 + 1] * y1); + } + var t2 = 0.5 - x2 * x2 - y2 * y2; + if (t2 >= 0) { + var gi2 = permMod12[ii + 1 + perm[jj + 1]] * 3; + t2 *= t2; + n2 = t2 * t2 * (grad3[gi2] * x2 + grad3[gi2 + 1] * y2); + } + // Add contributions from each corner to get the final noise value. + // The result is scaled to return values in the interval [-1,1]. + return 70.0 * (n0 + n1 + n2); + }, + // 3D simplex noise + noise3D: function(xin, yin, zin) { + var permMod12 = this.permMod12; + var perm = this.perm; + var grad3 = this.grad3; + var n0, n1, n2, n3; // Noise contributions from the four corners + // Skew the input space to determine which simplex cell we're in + var s = (xin + yin + zin) * F3; // Very nice and simple skew factor for 3D + var i = Math.floor(xin + s); + var j = Math.floor(yin + s); + var k = Math.floor(zin + s); + var t = (i + j + k) * G3; + var X0 = i - t; // Unskew the cell origin back to (x,y,z) space + var Y0 = j - t; + var Z0 = k - t; + var x0 = xin - X0; // The x,y,z distances from the cell origin + var y0 = yin - Y0; + var z0 = zin - Z0; + // For the 3D case, the simplex shape is a slightly irregular tetrahedron. + // Determine which simplex we are in. + var i1, j1, k1; // Offsets for second corner of simplex in (i,j,k) coords + var i2, j2, k2; // Offsets for third corner of simplex in (i,j,k) coords + if (x0 >= y0) { + if (y0 >= z0) { + i1 = 1; + j1 = 0; + k1 = 0; + i2 = 1; + j2 = 1; + k2 = 0; + } // X Y Z order + else if (x0 >= z0) { + i1 = 1; + j1 = 0; + k1 = 0; + i2 = 1; + j2 = 0; + k2 = 1; + } // X Z Y order + else { + i1 = 0; + j1 = 0; + k1 = 1; + i2 = 1; + j2 = 0; + k2 = 1; + } // Z X Y order + } + else { // x0 y0) rankx++; + else ranky++; + if (x0 > z0) rankx++; + else rankz++; + if (x0 > w0) rankx++; + else rankw++; + if (y0 > z0) ranky++; + else rankz++; + if (y0 > w0) ranky++; + else rankw++; + if (z0 > w0) rankz++; + else rankw++; + var i1, j1, k1, l1; // The integer offsets for the second simplex corner + var i2, j2, k2, l2; // The integer offsets for the third simplex corner + var i3, j3, k3, l3; // The integer offsets for the fourth simplex corner + // simplex[c] is a 4-vector with the numbers 0, 1, 2 and 3 in some order. + // Many values of c will never occur, since e.g. x>y>z>w makes x= 3 ? 1 : 0; + j1 = ranky >= 3 ? 1 : 0; + k1 = rankz >= 3 ? 1 : 0; + l1 = rankw >= 3 ? 1 : 0; + // Rank 2 denotes the second largest coordinate. + i2 = rankx >= 2 ? 1 : 0; + j2 = ranky >= 2 ? 1 : 0; + k2 = rankz >= 2 ? 1 : 0; + l2 = rankw >= 2 ? 1 : 0; + // Rank 1 denotes the second smallest coordinate. + i3 = rankx >= 1 ? 1 : 0; + j3 = ranky >= 1 ? 1 : 0; + k3 = rankz >= 1 ? 1 : 0; + l3 = rankw >= 1 ? 1 : 0; + // The fifth corner has all coordinate offsets = 1, so no need to compute that. + var x1 = x0 - i1 + G4; // Offsets for second corner in (x,y,z,w) coords + var y1 = y0 - j1 + G4; + var z1 = z0 - k1 + G4; + var w1 = w0 - l1 + G4; + var x2 = x0 - i2 + 2.0 * G4; // Offsets for third corner in (x,y,z,w) coords + var y2 = y0 - j2 + 2.0 * G4; + var z2 = z0 - k2 + 2.0 * G4; + var w2 = w0 - l2 + 2.0 * G4; + var x3 = x0 - i3 + 3.0 * G4; // Offsets for fourth corner in (x,y,z,w) coords + var y3 = y0 - j3 + 3.0 * G4; + var z3 = z0 - k3 + 3.0 * G4; + var w3 = w0 - l3 + 3.0 * G4; + var x4 = x0 - 1.0 + 4.0 * G4; // Offsets for last corner in (x,y,z,w) coords + var y4 = y0 - 1.0 + 4.0 * G4; + var z4 = z0 - 1.0 + 4.0 * G4; + var w4 = w0 - 1.0 + 4.0 * G4; + // Work out the hashed gradient indices of the five simplex corners + var ii = i & 255; + var jj = j & 255; + var kk = k & 255; + var ll = l & 255; + // Calculate the contribution from the five corners + var t0 = 0.6 - x0 * x0 - y0 * y0 - z0 * z0 - w0 * w0; + if (t0 < 0) n0 = 0.0; + else { + var gi0 = (perm[ii + perm[jj + perm[kk + perm[ll]]]] % 32) * 4; + t0 *= t0; + n0 = t0 * t0 * (grad4[gi0] * x0 + grad4[gi0 + 1] * y0 + grad4[gi0 + 2] * z0 + grad4[gi0 + 3] * w0); + } + var t1 = 0.6 - x1 * x1 - y1 * y1 - z1 * z1 - w1 * w1; + if (t1 < 0) n1 = 0.0; + else { + var gi1 = (perm[ii + i1 + perm[jj + j1 + perm[kk + k1 + perm[ll + l1]]]] % 32) * 4; + t1 *= t1; + n1 = t1 * t1 * (grad4[gi1] * x1 + grad4[gi1 + 1] * y1 + grad4[gi1 + 2] * z1 + grad4[gi1 + 3] * w1); + } + var t2 = 0.6 - x2 * x2 - y2 * y2 - z2 * z2 - w2 * w2; + if (t2 < 0) n2 = 0.0; + else { + var gi2 = (perm[ii + i2 + perm[jj + j2 + perm[kk + k2 + perm[ll + l2]]]] % 32) * 4; + t2 *= t2; + n2 = t2 * t2 * (grad4[gi2] * x2 + grad4[gi2 + 1] * y2 + grad4[gi2 + 2] * z2 + grad4[gi2 + 3] * w2); + } + var t3 = 0.6 - x3 * x3 - y3 * y3 - z3 * z3 - w3 * w3; + if (t3 < 0) n3 = 0.0; + else { + var gi3 = (perm[ii + i3 + perm[jj + j3 + perm[kk + k3 + perm[ll + l3]]]] % 32) * 4; + t3 *= t3; + n3 = t3 * t3 * (grad4[gi3] * x3 + grad4[gi3 + 1] * y3 + grad4[gi3 + 2] * z3 + grad4[gi3 + 3] * w3); + } + var t4 = 0.6 - x4 * x4 - y4 * y4 - z4 * z4 - w4 * w4; + if (t4 < 0) n4 = 0.0; + else { + var gi4 = (perm[ii + 1 + perm[jj + 1 + perm[kk + 1 + perm[ll + 1]]]] % 32) * 4; + t4 *= t4; + n4 = t4 * t4 * (grad4[gi4] * x4 + grad4[gi4 + 1] * y4 + grad4[gi4 + 2] * z4 + grad4[gi4 + 3] * w4); + } + // Sum up and scale the result to cover the range [-1,1] + return 27.0 * (n0 + n1 + n2 + n3 + n4); + } + }; + + function buildPermutationTable(random) { + var i; + var p = new Uint8Array(256); + for (i = 0; i < 256; i++) { + p[i] = i; + } + for (i = 0; i < 255; i++) { + var r = i + ~~(random() * (256 - i)); + var aux = p[i]; + p[i] = p[r]; + p[r] = aux; + } + return p; + } + SimplexNoise._buildPermutationTable = buildPermutationTable; + + function alea() { + // Johannes Baagøe , 2010 + var s0 = 0; + var s1 = 0; + var s2 = 0; + var c = 1; + + var mash = masher(); + s0 = mash(' '); + s1 = mash(' '); + s2 = mash(' '); + + for (var i = 0; i < arguments.length; i++) { + s0 -= mash(arguments[i]); + if (s0 < 0) { + s0 += 1; + } + s1 -= mash(arguments[i]); + if (s1 < 0) { + s1 += 1; + } + s2 -= mash(arguments[i]); + if (s2 < 0) { + s2 += 1; + } + } + mash = null; + return function() { + var t = 2091639 * s0 + c * 2.3283064365386963e-10; // 2^-32 + s0 = s1; + s1 = s2; + return s2 = t - (c = t | 0); + }; + } + function masher() { + var n = 0xefc8249d; + return function(data) { + data = data.toString(); + for (var i = 0; i < data.length; i++) { + n += data.charCodeAt(i); + var h = 0.02519603282416938 * n; + n = h >>> 0; + h -= n; + h *= n; + n = h >>> 0; + h -= n; + n += h * 0x100000000; // 2^32 + } + return (n >>> 0) * 2.3283064365386963e-10; // 2^-32 + }; + } + + // amd + if (typeof define !== 'undefined' && define.amd) define(function() {return SimplexNoise;}); + // common js + if (typeof exports !== 'undefined') exports.SimplexNoise = SimplexNoise; + // browser + else if (typeof window !== 'undefined') window.SimplexNoise = SimplexNoise; + // nodejs + if (typeof module !== 'undefined') { + module.exports = SimplexNoise; + } + +})();