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

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

              
                <html>
  <head>
   <!-- add link to p5js	-->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.min.js"></script>
  </head>
  <body>
  </body>
</html>

              
            
!

CSS

              
                /* - reset css - */ 
html,body,div,form,fieldset,legend,label{margin:0;padding:0;}
table{border-collapse:collapse;border-spacing:0;}
th,td{text-align:left;vertical-align:top;}
h1,h2,h3,h4,h5,h6,th,td,caption{font-weight:normal;}
img{border:0;}
canvas{display:block;}


              
            
!

JS

              
                //plan for creative code: 
//



//================================================//
// ========= | PRELOAD + INITIAL VARS | ========= // 
//================================================//

// =============== | VARIABLES | ================ //
var t = 0;


// ================ | OBJECTS | ================= //



// ================ | COLORS | ================= //

//-------------- | color palette

var pMagenta = '#D037F5';
var pDarkBlue = '#0A1045';
var pBrightBlue = '#003ACC';
var pLightPurple = '#8098FF';
var pGreen = '#0AF007';
var pWhite = '#fff';

//-------------- | Art colors

var bgFill = pMagenta;
var ambiFill = pLightPurple;
var domeFill = pBrightBlue;

var pointR = 10;
var pointG = 240;
var pointB = 7;

var point2R = 255;
var point2G = 255;
var point2B = 255;

// ================= | PRELOAD | ================== //

//-------------- | preload building blocks

function preload() {
  dome = loadModel('https://cdn.glitch.me/4976d32d-fd94-4dd4-8b88-2150e673b6a1%2Fdome.obj', true);
	
	hollowCone = loadModel('https://cdn.glitch.me/4976d32d-fd94-4dd4-8b88-2150e673b6a1%2Fcone.obj', true);
	
	drop = loadModel('https://cdn.glitch.me/4976d32d-fd94-4dd4-8b88-2150e673b6a1%2Fdrop.obj', true);
	
	smallTorus = loadModel('https://cdn.glitch.me/4976d32d-fd94-4dd4-8b88-2150e673b6a1%2FsmallTorus.obj', true);
	
	midTorus = loadModel('https://cdn.glitch.me/4976d32d-fd94-4dd4-8b88-2150e673b6a1%2FmidTorus.obj', true);
	
	bigTorus = loadModel('https://cdn.glitch.me/4976d32d-fd94-4dd4-8b88-2150e673b6a1%2FbigTorus.obj', true);
	
		hollowBox = loadModel('https://cdn.glitch.me/4976d32d-fd94-4dd4-8b88-2150e673b6a1%2Fhollowbox.obj', true);
}

//================================================//
// ========== | SETUP + GENERATE ONCE | ========= // 
//================================================//

function setup() {

createCanvas(500, 500, WEBGL);
angleMode(DEGREES);
	
	dropY = -300;
	dropScl = 0.1;
	torusScl = 1;
	torusRad = 25;
  torusTube = 10;
}

//================================================//
// ============= | GENERATE CONTINOUS | ========= // 
//================================================//

function draw() {

	// orbitControl(4);
	
// ------------- | initial style
	background(bgFill);
		
// ------------- | Light
	ambientLight(ambiFill);
	
	pointLight(pointR, pointG, pointB, 1000, 1000, 1000);
	pointLight(point2R, point2G, point2B, -1000, 1000, 1000);
	
// -------| grid & guides | comment on & off  
// -------| ! keep after bg !
	
	// drawAxis();
	// drawGrid();


// ================ | DRAWING | ================= //
var len = 15;
t += 1;
var ang = t;
// frameRate = 60;
	
push();
translate(-width/2 -20,-height/2 -80);
for(var i = 1 ; i < len; i ++){

	var diff = ang * i ;
	var y = map(sin(diff), -1, 1, 200, height-50);
	var x = map(i , 0, len-1, 20 , width-20);
  push();
	translate(x,y,0);
	scale(0.5);
	fill(domeFill);
	domeObj();
	pop();
}
pop();
	
// ============= | END OF DRAWING | ============= //

}




//================================================//
// ================ | BASE SHAPES | ============= // 
//================================================//
// setting the base shapes to the ideal parameters after loading & before using them

function domeObj(){
		push();
	  noStroke();
		rotateX(-90);
		rotateZ(-91); // to align it perfectly
		translate(-50, 0,0);
		model(dome);
		pop();
}



function dropObj(){
	push();
	noStroke();
	rotateZ(180);
	translate(0,-100,0);
	model(drop);
	pop();
}

function coneObj(){
	push();
	noStroke();
	translate(-7.5,0,-61);//to align
	rotateY(7);//to fix the crooked position
	rotateY(180); // to flip 
	model(hollowCone);
	pop();
}


function sTorusObj(){
	push();
	noStroke();
	rotateX(90);
	model(smallTorus);
	pop();
}

function mTorusObj(){
	push();
	noStroke();
	rotateX(90);
	model(midTorus);
	pop();
}

function boxObj(){
	push();
	noStroke();
	rotateX(180);
	translate(0,-100,0)
	model(hollowBox);
	pop();
}




//================================================//
// =============== | GUIDES & GRID | ============ // 
//================================================//


function drawAxis() {
	push();
	strokeWeight(3);
	stroke(255, 0, 0);
	line(0, 0, 0, 100, 0, 0);
	stroke(0, 0, 0);
	line(0, 0, 0, 0, 100, 0);
	stroke(0, 0, 255);
	line(0, 0, 0, 0, 0, 100);
	pop();
}

function drawGrid() {
	let sz = 1000;
	let num = 10;
	push();
	translate(-sz / 2, -sz / 2, 0);
	stroke(200);
	for (var i = 0; i < num + 1; i++) {
		line((i * sz) / num, 0, 0, (i * sz) / num, sz, 0);
		line(0, (i * sz) / num, 0, sz, (i * sz) / num, 0);
	}
	pop();
}

              
            
!
999px

Console