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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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 id=vertexShader type=x-shader/x-vertex>
attribute vec3 pos;

void main() {
	gl_Position=vec4(pos, 1.0);

canvas {
  position: absolute;
  overflow: hidden;
  display: block;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;

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

~function scene(time) {

	// clear screen
	g.clearColor(1/5, 1/5, 1/5, 1)

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

	// draw
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................