Pen Settings

HTML

CSS

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

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

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.

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

              
                
              
            
!

JS

              
                var nParticles = 1000; //number of particles in wave
let pArrayX = [];//xcoordinates
let pArrayY = [];//ycoordinates
let cLim = 40;
var alpha = 4;
var stepD = 3;
function setup() {
  createCanvas(600, 600);//canvas size
  background(255);//white background creates fade effect
  angleMode(DEGREES);//degree mode
  makePArray();//initializes particles
  noStroke();//no outline
}

function draw() {
  translate(width/2,width/2,width/2);//origin at center
  background(0,0,0,2);//black and transparent
  stepPArray(); //animates particles through parametric equation
}
function mousePressed() {//creates new wave with random equation
    background(255)//white creates fade
    makePArray()//initialize new particle arrays
   frameCount = 1;
}
function makePArray(){
  cLim = int(random(5,80))
  pArrayX = [];//clear array
  pArrayY = [];//clear array
  step = frameCount/stepD;//step/speed of wave
  pArrayX[0] = mouseX
  pArrayY[0] = mouseY
  for (let i = 1;i<nParticles;i++){//randomize points around the parametric x,y for nParticles
    pArrayX[i] = pArrayX[0]+random(-35,20)*sin(i/9)*cos(i/9)
    pArrayY[i] = pArrayY[0]+random(-50,25)*sin(i*9)*cos(i/11)
  }
}

function stepPArray(){
  step = frameCount/stepD;//step size for animation
  newX = mouseX-width/2
  newY = mouseY-width/2
  deltaX = (pArrayX[0] - newX);//change in x from last point
  deltaY = (pArrayY[0] - newY);//change in y from last point
  pArrayX[0] = newX;//new x -center point
  pArrayY[0] = newY;//new y -center point
  fill(0,0,0,10)
  circle(pArrayX[0],pArrayY[0],3)//plot point
  for (i=1;i<nParticles;i++){//create dispersion of points
    mod1 = pArrayX[i]-pArrayX[0] //find x dist from center point
    mod2 = pArrayY[i]-pArrayY[0]//find y dist from center point
    fill(0+8*(abs(mod1+mod2)),0+8*(abs(mod1+mod2)),0+8*(abs(mod1+mod2)))//base color on distance from center
    if (mod1 < cLim && mod1>-cLim){ //keep particles in constrained
      mod1 = 0
    }
    if (mod2 < cLim && mod2>-cLim){
      mod2 = 0
    }
    //base new position on last position - delta plus randomness
    pArrayX[i] = (pArrayX[i]-deltaX)+random(-1,1)*cos(i/11)*sin(i)-random(-4,3)*sin(i/20)-tan(frameCount)*mod1
    pArrayY[i] = ( pArrayY[i]-deltaY)+ random(-1,1)*cos(i/11)*cos(i*9)-mod2*tan(frameCount)
    push()
    rotate((frameCount/10)%360)
    circle(pArrayX[i],pArrayY[i],1)//plot particle
    pop()
  }
}
              
            
!
999px

Console