Ellipses
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 - 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);
}
Developer | Ben Matthews |
Username | tsuhre |
Uploaded | December 20, 2022 |
Rating | 4 |
Size | 2,312 Kb |
Views | 10,120 |
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!
Name | Size |
Voronoi Pursuit Curves | 4,234 Kb |
Circular Ogee Tiling | 3,106 Kb |
Sand Traveler | 2,467 Kb |
Random Chess Game | 3,330 Kb |
Flame Animation Test 2 | 2,937 Kb |
Fractal Fun | 3,965 Kb |
Axial | 4,511 Kb |
Tree Generator | 3,211 Kb |
Ribbons | 2,140 Kb |
Constellations | 2,961 Kb |
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!
Name | Username | Size |
Em Test | Rodesco | 1,784 Kb |
Background Images | Jooonebug | 2,100 Kb |
Pure CSS Spinners | Jlong | 2,043 Kb |
Planet Awesome | Bartuc | 3,554 Kb |
Svg sky | Omodev | 7,070 Kb |
My three.js practice | Esambino | 3,203 Kb |
Slide like Mailbox | Hmps | 3,758 Kb |
DFF Website | Hawcubite | 10,123 Kb |
Drag in vanilla js using dotval math instead of translate | Paulq | 2,662 Kb |
Swiftype Lower Third | Zumwalt | 4,796 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!