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

              
                
              
            
!

CSS

              
                body {
  margin: 0;
  padding: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: black;
}
              
            
!

JS

              
                //genuary13
//learned about shaders from here:https://www.youtube.com/watch?v=r5YkU5Xu4_E (vert file from this video)
//and book of shaders: https://thebookofshaders.com/examples/

//reused some of my golden tank code for the canvas 
let cnv2;
let myShader;

function setup() {
  createCanvas(600, 600, WEBGL);
  cnv2 = createGraphics(width*2, height*2);
  myShader = createShader(vert, frag);
  cnv2.background(0);
  cnv2.stroke(255);
  cnv2.strokeWeight(0.05);
 shader(myShader);
}


let a = 9
function draw() {
  let t = frameCount/500;
  myShader.setUniform("u_time",t)
  myShader.setUniform("u_resolution",[width,height])
  cnv2.translate(width,height)
  cnv2.background(0,0,a)
  
  for(let i=0;i<1000;i+=2){
    cnv2.fill(50,240-i/4,250-i/4)
    cnv2.push()
    cnv2.rotate(137.5*i+t+tan(i+t*0.00001))//golden angle
    cnv2.ellipse(0,i/2+i*sin(t)/2+i*sin(i*t/5+i)/30,4+10*abs(sin(t)),2+10*abs(sin(t-i)))
    cnv2.pop()
  } 
  drawScreen();
  cnv2.translate(-width,-height)
}




function drawScreen() {
  myShader.setUniform('texture', cnv2);
  rect(-width, -height, width, height);
}


var frag = `
#ifdef GL_ES
precision mediump float;
#endif
varying vec2 vTexCoord;
uniform float u_time;
uniform sampler2D texture;

void main() {
  vec2 uv = vTexCoord;
  uv.y = 1.0 - uv.y;//flip y  
  vec2 offset = vec2(0.01*sin(u_time),0.01*cos(u_time));
  
  vec3 col;
  col.r = texture2D(texture, uv+offset*sin(u_time)*sin(u_time) ).r;
  col.g = texture2D(texture, uv-offset*sin(u_time)*sin(u_time)).g;
  col.b = texture2D(texture, uv).b;
  gl_FragColor = vec4(col.r,col.g,col.b, 1);
  
  
}
`

var vert = `
attribute vec3 aPosition;
attribute vec2 aTexCoord;

varying vec2 vTexCoord;

void main() {
  // copy the texcoords
  vTexCoord = aTexCoord;

  vec4 positionVec4 = vec4(aPosition, 1.0);
  positionVec4.xy = positionVec4.xy * 2.0 - 1.0;//remap center

  gl_Position = positionVec4;
}
`

              
            
!
999px

Console