P5.js data visualization
How do I make an p5.js data visualization?
P5.js data visualization. What is a p5.js data visualization? How do you make a p5.js data visualization? This script and codes were developed by Engin Arslan on 16 December 2022, Friday.
P5.js data visualization - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>p5.js data visualization</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <html> <head> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.7/p5.min.js"></script> </head> <body> </body>
</html> <script src="js/index.js"></script>
</body>
</html>
P5.js data visualization - Script Codes CSS Codes
body { padding: 0; margin: 0; display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center; -webkit-box-align: center; -ms-flex-align: center; align-items: center; background: black;
}
canvas { position: fixed; top: 50%; left: 50%; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%);
}
P5.js data visualization - Script Codes JS Codes
var data = [];
var maxData;
function setup() { createCanvas(800, 800); angleMode(DEGREES); rectMode(BOTTOM); for (var i = 0; i < 100; i = i + 1) { var randomNumber = random(20, 80); data.push(randomNumber); } maxData = max(data);
}
function draw() { background(43, 53, 63); fill(139, 171, 203); stroke(89, 86, 74); var angleSeparation = 360 / data.length; var padding = 10; if (frameCount <= 400) { maxValue = constrain(frameCount * 2, 0, 400); } else { maxValue = 400; } var offset = 200; var dataMultiplier = (height/2-offset-padding) / maxData; for (var i = 0; i < data.length; i = i + 1) { push(); var currentData = data[i]; var finalHeight = currentData * dataMultiplier; var animatedHeight = map(maxValue, 0, 400, 0, finalHeight); translate(width / 2, height / 2); rotate(angleSeparation * i); rect(0, offset, angleSeparation*2, animatedHeight); text(Math.floor(currentData), offset-20, 0); pop(); }
}
Developer | Engin Arslan |
Username | enginarslan |
Uploaded | December 16, 2022 |
Rating | 3 |
Size | 2,233 Kb |
Views | 32,384 |
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 |
Learning-threejs-03 | 2,276 Kb |
Book-cover-step-14 | 2,091 Kb |
Coding for Visual Learners - Cover | 2,675 Kb |
P5.js basic template | 1,807 Kb |
P5.js generative art | 2,180 Kb |
Book-cover-step-01 | 1,824 Kb |
Learning-threejs-02 | 2,211 Kb |
Book-cover-step-06 | 1,943 Kb |
Learning-threejs-06 | 2,628 Kb |
Learning-threejs-00 | 1,752 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 |
CSS-Flexbox-Demo | Sstiglets | 1,709 Kb |
Basic template | Tomcat | 1,675 Kb |
Contact | GanNichiHa | 2,514 Kb |
Awesome textarea | Ayoungh | 1,977 Kb |
Simple jQuery Slider | Jurbank | 2,874 Kb |
DevCamp 2014 - Denver Public Library | See8ch | 5,033 Kb |
CSS Dynamic Width Square Div | Elleestcrimi | 2,861 Kb |
Preloader | Rikki_Sixx | 2,815 Kb |
Animate elements with fixed gradient | Badabam | 4,406 Kb |
CSS3 Snow Animation | NickyCDK | 1,695 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!