cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

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.

            
              <canvas id=a></canvas>
<script id=fragmentShader type=x-shader/x-fragment>
precision mediump float;
#define ITERS 22
uniform float time;
uniform vec2 resolution;


vec2 R(vec2 p,float a) {
	return vec2( p.x*cos(a) + p.y*sin(a), 
			    -p.x*sin(a) + p.y*cos(a));
}

float julia(vec2 c,vec2 c1, float max){
	float xx = c.x * c.x;
	float yy = c.y * c.y;
	float xy = c.x * c.y;
	float s = xx + yy;
	for (int i = ITERS;i>0;i--){
		c=vec2(xy + c.y - c.x, xx + yy * xy - c.y) + c1;
		xx = c.x * c.x;
		yy = c.y * c.y;
		xy = c.x * c.y;
		s = xx + yy;
		if(s>=max || i == 1)return float(ITERS - i)/float(ITERS);
	}
	return 0.0;
}


void main() {
	
	vec2 c0 = (gl_FragCoord.xy / resolution) - vec2(0.5,0.5);	
	vec2 c  = R(c0, time * 0.002);
	float j = julia(c + cos(time*.2) / 1.7,c + sin(time*.4) / 1.7, 16.0);
	float r = j * sin(c.x+time * 1.5);
	float g = j * sin(c.y + time * 1.2+1.0);
	float b = j;
	gl_FragColor = vec4(r, g, b, 1.0);
}
</script>
<script id=vertexShader type=x-shader/x-vertex>
attribute vec3 pos;

void main() {
	gl_Position=vec4(pos, 1.0);
}
</script>
            
          
!
            
              body{
  background-color:#000;overflow:hidden;margin:0
}

canvas {
  position: absolute;
  overflow: hidden;
  display: block;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
}
            
          
!
            
              w=a.width=innerWidth
h=a.height=innerHeight
g=a.getContext('webgl')||a.getContext('experimental-webgl')
g.enable(g.DEPTH_TEST)
g.depthFunc(g.LEQUAL)

$prog(g, [vertexShader, fragmentShader])
posBuf = $buf([1,1,0,-1,1,0,1,-1,0,-1,-1,0])
pos = $attr("pos")


~function scene(time) {
	time=time*1e-3

	// clear screen
	g.clearColor(1/5, 1/5, 1/5, 1)
	g.clear(g.COLOR_BUFFER_BIT | g.DEPTH_BUFFER_BIT)

	// bind attributes to buffers
	$bind(pos, posBuf, 3)
	
	// set uniforms
	$uni("time", time)
	$uniV("resolution", [w,h])

	// draw
	g.drawArrays(g.TRIANGLE_STRIP,0,4)
	requestAnimationFrame(scene)
}(0)
            
          
!
999px
Loading ..................

Console