Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="container"></div>
<script id="vertexShader" type="x-shader/x-vertex">

  void main() {
    gl_Position = vec4( position, 1.0 );
  }

</script>

<script id="fragmentShader" type="x-shader/x-fragment">

  uniform vec2 iResolution;
  uniform float iGlobalTime;

// Complex Form with Black and White Spirals
// Created by XORXOR, 2016
// Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)
// https://www.shadertoy.com/view/MtcXD7
// 
// Thanks to iq for voronoi
// https://www.shadertoy.com/view/ldl3W8
// Spiral idea from Fingerprint generator by diviaki
// https://www.shadertoy.com/view/4t3SWN

#define ANIMATE

vec2 hash( vec2 p )
{
	return fract( sin( vec2( p.x * p.y, p.x + p.y ) ) * vec2( 234342.1459123, 373445.3490423 ) );
}

// iq's voronoi
// https://www.shadertoy.com/view/ldl3W8
vec4 voronoi( in vec2 x )
{
    vec2 n = floor( x );
    vec2 f = fract( x );

    //----------------------------------
    // first pass: regular voronoi
    //----------------------------------
	vec2 mg, mr, mo;

    float md = 8.0;
    for( int j=-1; j<=1; j++ )
    for( int i=-1; i<=1; i++ )
    {
        vec2 g = vec2(float(i),float(j));
		vec2 o = hash( n + g );
		#ifdef ANIMATE
        o = 0.5 + 0.3*sin( iGlobalTime + 6.2831*o );
        #endif	
        vec2 r = g + o - f;
        float d = dot(r,r);

        if( d<md )
        {
            md = d;
            mr = r;
            mg = g;
            mo = o;
        }
    }

    //----------------------------------
    // second pass: distance to borders
    //----------------------------------
    md = 8.0;
    for( int j=-2; j<=2; j++ )
    for( int i=-2; i<=2; i++ )
    {
        vec2 g = mg + vec2(float(i),float(j));
		vec2 o = hash( n + g );
		#ifdef ANIMATE
        o = 0.5 + 0.3*sin( iGlobalTime + 6.2831*o );
        #endif	
        vec2 r = g + o - f;

        if( dot(mr-r,mr-r)>0.00001 )
        md = min( md, dot( 0.5*(mr+r), normalize(r-mr) ) );
    }

    return vec4( md, mr, mo.x + mo.y );
}

void main()
{
		vec2 b = 6.0 * gl_FragCoord.xy / iResolution.x;
    vec4 v = voronoi( b );
    vec2 q = v.yz;
    
    float a = iGlobalTime + atan( sign( v.w - 1.0 ) * q.y, q.x );
    float l = length( q * 5.0 / ( sqrt( v.x ) ) ) + 0.319 * a;
    float m = mod( l, 2.0 );
    float o = ( 1.0 - smoothstep( 1.7, 2.0, m ) ) * smoothstep( 1.0, 1.3, m );
    o = mix( 0.0, o, smoothstep( 0.04, 0.07, v.x ) );

	gl_FragColor = vec4( vec3( o ), 1.0 );
}

</script>
              
            
!

CSS

              
                *{
  padding: 0;
  margin: 0;
}
              
            
!

JS

              
                // Complex Form with Black and White Bands
// After Sol Lewitt.
//
// Created by XORXOR, 2016
// Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)
// https://www.shadertoy.com/view/MldSD4

var container;
var camera, scene, renderer;
var uniforms;
var startTime;

init();
animate();

function init() {

  container = document.getElementById( 'container' );

  startTime = Date.now();
  camera = new THREE.Camera();
  camera.position.z = 1;

  scene = new THREE.Scene();

  var geometry = new THREE.PlaneBufferGeometry( 4, 3 );
  
                     
  uniforms = {
      iGlobalTime: { type: "f", value: 1.0 },
      iResolution: { type: "v2", value: new THREE.Vector2() }
    };

  var material = new THREE.ShaderMaterial( {

    uniforms: uniforms,
    vertexShader: document.getElementById( 'vertexShader' ).textContent,
    fragmentShader: document.getElementById( 'fragmentShader' ).textContent

  } );

  var mesh = new THREE.Mesh( geometry, material );
  scene.add( mesh );

  renderer = new THREE.WebGLRenderer();
  container.appendChild( renderer.domElement );

  onWindowResize();

  window.addEventListener( 'resize', onWindowResize, false );
}

function onWindowResize( event ) {

  uniforms.iResolution.value.x = window.innerWidth;
  uniforms.iResolution.value.y = window.innerHeight;

  renderer.setSize( window.innerWidth, window.innerHeight );

}

function animate() {

  requestAnimationFrame( animate );
  render();

}

function render() {

  var currentTime = Date.now();
  uniforms.iGlobalTime.value = (currentTime - startTime) * 0.001;
  renderer.render( scene, camera );

}
              
            
!
999px

Console