Ellipses

Developer
Size
2,312 Kb
Views
10,120

How do I make an ellipses?

An idea for an animation that I had when playing with the tools for my spiraler project here https://codepen.io/tsuhre/project/full/ZgbOYx/. What is a ellipses? How do you make a ellipses? This script and codes were developed by Ben Matthews on 20 December 2022, Tuesday.

Ellipses Previews

Ellipses - Script Codes HTML Codes

<!DOCTYPE html>
<html class="https://github.com/processing/p5.js/releases/download/0.5.6/p5.min.js">
<head> <meta charset="UTF-8"> <title>Ellipses</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div id="controls">
</div> <script src='https://github.com/processing/p5.js/releases/download/0.5.6/p5.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Ellipses - Script Codes CSS Codes

* { margin:0; padding:0; }
html, body { width:100%; height:100%; overflow: hidden;}
canvas { display:block; }
#controls { margin: 20px; position: absolute; top: 0; left: 0; color: white;
}

Ellipses - Script Codes JS Codes

window.addEventListener('resize', resize, false);
var	speed = 2,	angleMod = .1,	numrotations = 16,	walker1,	walker2;
function Walker(x, y){	this.x = x;	this.y = y;	this.xVel = random()*speed;	this.yVel = random()*speed;	this.update = function(){	this.x += this.xVel;	this.y += this.yVel;	if (this.x < 0 || this.x > width - 1) this.xVel *= -1;	if (this.y < 0 || this.y > height - 1) this.yVel *= -1;	else this.angle += angleMod;	}
}
function setup(){ createCanvas(); colorMode(HSB, 360, 100, 100, 100); ellipseMode(CORNERS);	rectMode(CORNERS);	stroke(0, 0, 100);	//noStroke();	noFill();	//fill(120, 100, 100, 10);	strokeWeight(3); resize();	walker1 = new Walker(random()*width, random()*height);	walker2 = new Walker(random()*width, random()*height);
}
function inBounds(x, y){	return (x > -1 && y > -1 && x < width && y < height);
}
function draw(){	background(0, 10);	if (!walker1) return;	var a = 1/numrotations;	a *= PI*2;	translate(width/2, height/2);	push();	for (var i = 0; i < numrotations; i++){	ellipse(walker1.x - width/2, walker1.y - height/2, walker2.x - width/2, walker2.y - height/2);	rotate(a);	}	pop();	scale(1, -1);	for (var i = 0; i < numrotations; i++){	ellipse(walker1.x - width/2, walker1.y - height/2, walker2.x - width/2, walker2.y - height/2);	rotate(-a);	}	walker1.update();	walker2.update();
}
function resize(){ resizeCanvas(window.innerWidth, window.innerHeight);	background(0);
}
Ellipses - Script Codes
Ellipses - Script Codes
Home Page Home
Developer Ben Matthews
Username tsuhre
Uploaded December 20, 2022
Rating 4
Size 2,312 Kb
Views 10,120
Do you need developer help for Ellipses?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Ben Matthews (tsuhre) Script Codes
Create amazing Facebook ads with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!