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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                //- Click anywhere on the screen to stop/play the flowers' animation, and save your favorite flowers. :)    
//- On mobile touch screen to stop/play the animation.
              
            
!

CSS

              
                body {
	background-color: hotpink;
	margin: 0;
	padding: 0;
	overflow: hidden;
}
              
            
!

JS

              
                /* 
 * MORPHING FLOWERS
 * Anim made with p5 - Enjoy!
 *
 * #031 - #100DaysOfCode
 * By ilithya | 2020
 * https://www.ilithya.rocks/
 * https://twitter.com/ilithya_net
 */

const bgColor = 'hotpink'; 
const flowerColor = '#fffffd'; // white

function setup() {
	setAttributes('antialias', true);
	createCanvas(windowWidth, windowHeight, WEBGL);
	
	background(bgColor);
	frameRate(4);
	strokeWeight(1);
	fill(flowerColor);
}

let time = 0;
const drawFlowers = () => {	
	time++;
	
	background(bgColor);	

	const fWidth = round((windowWidth + windowHeight) / 14);
	const fHeight = fWidth / 2;
	const fLineX2 = 25;
	const fLineY1 = fWidth * 30;
	
	const fWidthNeg = fWidth * -1;
	const fHeightNeg = fHeight * -1;
	const fLineX2Neg = fLineX2 * -1;
	const fLineY1Neg = fWidthNeg * 30;
	
	const qTime = time / 4;

	for (let i = 0; i < 160; i++) {
		rotateY(qTime);
		circle(fWidth, fWidth, fWidth);
		circle(fWidthNeg, fWidthNeg, fWidthNeg);
		line(fWidth, fLineY1, fLineX2, fWidth);
		line(fWidthNeg, fLineY1Neg, fLineX2Neg, fWidthNeg);

		push();
		rotateY(time);
		stroke(flowerColor);
		line(fWidth, fLineY1, fLineX2Neg, fWidth);
		line(fWidthNeg, fLineY1Neg, fLineX2, fWidthNeg);
		pop();
		
		// Top part
		push();
		rotate(qTime);
		circle(fHeight, fHeight, fHeight);
		circle(fHeightNeg, fHeightNeg, fHeightNeg);
		pop();
	}
};

function draw() {
	drawFlowers();
}

// Let's stop/play the flowers' animation with a canvas click or mobile canvas touch.
let isDrawing = true;
const toggleDraw = () => {	
	if (isDrawing) {
		noLoop();
		isDrawing = false;
	} else {
		loop();
		isDrawing = true;
	}
};
function mousePressed() {
	toggleDraw();
}
function touchStarted() {
	toggleDraw();
}
              
            
!
999px

Console