mirror of
https://github.com/seigler/generative
synced 2025-07-26 22:56:10 +00:00
publish: Make room for future sketches
generated from commit 1fc82531ea0a31bdcb87e6c20a37e629497c4876
This commit is contained in:
commit
f17d33dda0
7 changed files with 145 additions and 0 deletions
1
app-75c7425a.js
Normal file
1
app-75c7425a.js
Normal file
|
@ -0,0 +1 @@
|
|||
!function(){"use strict";var e="undefined"==typeof global?self:global;if("function"!=typeof e.require){var r={},t={},o={},n={}.hasOwnProperty,i=/^\.\.?(\/|$)/,a=function(e,r){for(var t,o=[],n=(i.test(r)?e+"/"+r:r).split("/"),a=0,s=n.length;a<s;a++)t=n[a],".."===t?o.pop():"."!==t&&""!==t&&o.push(t);return o.join("/")},s=function(e){return e.split("/").slice(0,-1).join("/")},c=function(r){return function(t){var o=a(s(r),t);return e.require(o,r)}},d=function(e,r){var o=p&&p.createHot(e),n={id:e,exports:{},hot:o};return t[e]=n,r(n.exports,c(e),n),n.exports},l=function(e){return o[e]?l(o[e]):e},u=function(e,r){return l(a(s(e),r))},f=function(e,o){null==o&&(o="/");var i=l(e);if(n.call(t,i))return t[i].exports;if(n.call(r,i))return d(i,r[i]);throw new Error("Cannot find module '"+e+"' from '"+o+"'")};f.alias=function(e,r){o[r]=e};var h=/\.[^.\/]+$/,m=/\/index(\.[^\/]+)?$/,v=function(e){if(h.test(e)){var r=e.replace(h,"");n.call(o,r)&&o[r].replace(h,"")!==r+"/index"||(o[r]=e)}if(m.test(e)){var t=e.replace(m,"");n.call(o,t)||(o[t]=e)}};f.register=f.define=function(e,o){if(e&&"object"==typeof e)for(var i in e)n.call(e,i)&&f.register(i,e[i]);else r[e]=o,delete t[e],v(e)},f.list=function(){var e=[];for(var t in r)n.call(r,t)&&e.push(t);return e};var p=e._hmr&&new e._hmr(u,f,r,t);f._cache=t,f.hmr=p&&p.wrap,f.brunch=!0,e.require=f}}(),function(){"undefined"==typeof window?this:window;require.register("initialize.js",function(e,r,t){"use strict";document.addEventListener("DOMContentLoaded",function(){r("sketches/1")})}),require.register("sketches/1.js",function(e,r,t){"use strict";new p5(function(e){function r(){if(t)e.randomSeed(t);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 f=2,h=o*n/a,m=Math.sqrt(h),v=Math.max(1,Math.round(n/m))+1,p=Math.max(1,Math.round(o/m))+1,w=e.random(0,1e3),M=0;M<v*p;M++){var b=M%p,g=Math.floor(M/p);s.noStroke(),s.background("#000");var x=e.noise(w+g/v*f,w+b/p*f),S=i*x,_=e.color(100*e.random(),100,90*x+10,70*x+10);s.fill(_),s.circle(i/2,i/2,S),c.shader(l),l.setUniform("tex0",s),l.setUniform("texelSize",[8/i,8/i]),l.setUniform("direction",[1,0]),c.rect(0,0,i,i),d.shader(u),u.setUniform("tex0",c),u.setUniform("texelSize",[8/i,8/i]),u.setUniform("direction",[0,1]),d.rect(0,0,i,i),c.shader(l),l.setUniform("tex0",d),l.setUniform("texelSize",[1/i,1/i]),l.setUniform("direction",[1,0]),c.rect(0,0,i,i),d.shader(u),u.setUniform("tex0",c),u.setUniform("texelSize",[1/i,1/i]),u.setUniform("direction",[0,1]),d.rect(0,0,i,i),s.image(d,0,0,i,i),s.fill("#000");var k=e.random(2*Math.PI);s.circle(S*Math.cos(k),S*Math.sin(k),e.random(.3,.5)*S);do{var U=e.random(2*Math.PI),q=e.random(2*Math.PI);s.stroke(0),s.strokeWeight(1+S*Math.pow(e.random(.7368),3)),s.line(i*(Math.sin(U)+.5),i*(Math.cos(U)+.5),i*(Math.sin(q)+.5),i*(Math.cos(q)+.5))}while(e.random()<.5+.45*x);var y=e.random(0,2*Math.PI),E=e.random(m),z=o/(p-1)*b+E*Math.cos(y),P=n/(v-1)*g+E*Math.sin(y);e.image(s,z-i/2,P-i/2)}}var t=void 0,o=void 0,n=void 0,i=void 0,a=void 0,s=void 0,c=void 0,d=void 0,l=void 0,u=void 0;e.preload=function(){l=e.loadShader("shaders/blur-two-pass/base.vert","shaders/blur-two-pass/blur.frag"),u=e.loadShader("shaders/blur-two-pass/base.vert","shaders/blur-two-pass/blur.frag")},e.setup=function(){a=100,window.onhashchange=function(){t=window.location.hash.substr(1),r()},t=window.location.hash.substr(1),e.noStroke(),e.colorMode(e.HSB,100),o=document.documentElement.scrollWidth,n=document.documentElement.scrollHeight,i=1.75*(o+n)/Math.sqrt(a),e.createCanvas(o,n),s=e.createGraphics(i,i),c=e.createGraphics(i,i,e.WEBGL),d=e.createGraphics(i,i,e.WEBGL),s.noStroke(),c.noStroke(),d.noStroke(),r()},e.draw=function(){},e.keyPressed=function(){" "==e.key&&(t=null,r())}})}),require.register("___globals___",function(e,r,t){})}(),require("___globals___"),require("initialize");
|
1
app-eccc53bd.css
Normal file
1
app-eccc53bd.css
Normal file
|
@ -0,0 +1 @@
|
|||
body,html{height:100%}body{background-color:#000;margin:0;padding:0;display:flex;align-items:center;justify-content:center}
|
14
index.html
Normal file
14
index.html
Normal file
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Generative Art - seigler.github.io</title>
|
||||
<link rel="stylesheet" href="app-eccc53bd.css">
|
||||
</head>
|
||||
<body>
|
||||
<script src="modules/p5.min.js"></script>
|
||||
<script src="modules/p5.sound.min.js"></script>
|
||||
<script src="app-75c7425a.js"></script>
|
||||
</body>
|
||||
</html>
|
3
modules/p5.min.js
vendored
Normal file
3
modules/p5.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
28
modules/p5.sound.min.js
vendored
Normal file
28
modules/p5.sound.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
18
shaders/blur-two-pass/base.vert
Normal file
18
shaders/blur-two-pass/base.vert
Normal file
|
@ -0,0 +1,18 @@
|
|||
// our vertex data
|
||||
attribute vec3 aPosition;
|
||||
attribute vec2 aTexCoord;
|
||||
|
||||
// lets get texcoords just for fun!
|
||||
varying vec2 vTexCoord;
|
||||
|
||||
void main() {
|
||||
// copy the texcoords
|
||||
vTexCoord = aTexCoord;
|
||||
|
||||
// copy the position data into a vec4, using 1.0 as the w component
|
||||
vec4 positionVec4 = vec4(aPosition, 1.0);
|
||||
positionVec4.xy = positionVec4.xy * 2.0 - 1.0;
|
||||
|
||||
// send the vertex information on to the fragment shader
|
||||
gl_Position = positionVec4;
|
||||
}
|
80
shaders/blur-two-pass/blur.frag
Normal file
80
shaders/blur-two-pass/blur.frag
Normal file
|
@ -0,0 +1,80 @@
|
|||
precision mediump float;
|
||||
|
||||
// texcoords from the vertex shader
|
||||
varying vec2 vTexCoord;
|
||||
|
||||
// our texture coming from p5
|
||||
uniform sampler2D tex0;
|
||||
|
||||
// the size of a texel or 1.0 / width , 1.0 / height
|
||||
uniform vec2 texelSize;
|
||||
|
||||
// which way to blur, vec2(1.0, 0.0) is horizontal, vec2(0.0, 1.0) is vertical
|
||||
uniform vec2 direction;
|
||||
|
||||
// gaussian blur filter modified from Filip S. at intel
|
||||
// https://software.intel.com/en-us/blogs/2014/07/15/an-investigation-of-fast-real-time-gpu-based-image-blur-algorithms
|
||||
// this function takes three parameters, the texture we want to blur, the uvs, and the texelSize
|
||||
vec3 gaussianBlur( sampler2D t, vec2 texUV, vec2 stepSize ){
|
||||
// a variable for our output
|
||||
vec3 colOut = vec3( 0.0 );
|
||||
|
||||
// stepCount is 9 because we have 9 items in our array , const means that 9 will never change and is required loops in glsl
|
||||
const int stepCount = 9;
|
||||
|
||||
// these weights were pulled from the link above
|
||||
float gWeights[stepCount];
|
||||
gWeights[0] = 0.10855;
|
||||
gWeights[1] = 0.13135;
|
||||
gWeights[2] = 0.10406;
|
||||
gWeights[3] = 0.07216;
|
||||
gWeights[4] = 0.04380;
|
||||
gWeights[5] = 0.02328;
|
||||
gWeights[6] = 0.01083;
|
||||
gWeights[7] = 0.00441;
|
||||
gWeights[8] = 0.00157;
|
||||
|
||||
// these offsets were also pulled from the link above
|
||||
float gOffsets[stepCount];
|
||||
gOffsets[0] = 0.66293;
|
||||
gOffsets[1] = 2.47904;
|
||||
gOffsets[2] = 4.46232;
|
||||
gOffsets[3] = 6.44568;
|
||||
gOffsets[4] = 8.42917;
|
||||
gOffsets[5] = 10.41281;
|
||||
gOffsets[6] = 12.39664;
|
||||
gOffsets[7] = 14.38070;
|
||||
gOffsets[8] = 16.36501;
|
||||
|
||||
// lets loop nine times
|
||||
for( int i = 0; i < stepCount; i++ ){
|
||||
|
||||
// multiply the texel size by the by the offset value
|
||||
vec2 texCoordOffset = gOffsets[i] * stepSize;
|
||||
|
||||
// sample to the left and to the right of the texture and add them together
|
||||
vec3 col = texture2D( t, texUV + texCoordOffset ).xyz + texture2D( t, texUV - texCoordOffset ).xyz;
|
||||
|
||||
// multiply col by the gaussian weight value from the array
|
||||
col *= gWeights[i];
|
||||
|
||||
// add it all up
|
||||
colOut += col;
|
||||
}
|
||||
|
||||
// our final value is returned as col out
|
||||
return colOut;
|
||||
}
|
||||
|
||||
|
||||
void main() {
|
||||
|
||||
vec2 uv = vTexCoord;
|
||||
// the texture is loaded upside down and backwards by default so lets flip it
|
||||
uv = 1.0 - uv;
|
||||
|
||||
// use our blur function
|
||||
vec3 blur = gaussianBlur(tex0, uv, texelSize * direction);
|
||||
|
||||
gl_FragColor = vec4(blur, 1.0);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue