Points-line
How do I make an points-line?
What is a points-line? How do you make a points-line? This script and codes were developed by IEkiller on 18 January 2023, Wednesday.
Points-line - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>points-line</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <canvas id="can" width=1000 height=800></canvas> <script src="js/index.js"></script>
</body>
</html>
Points-line - Script Codes CSS Codes
* { margin: 0; padding: 0;
}
canvas { background: #ccc; display: block;
}
Points-line - Script Codes JS Codes
var can = document.querySelector('#can');
can.width = window.innerWidth;
can.height = window.innerHeight;
var ctx = can.getContext('2d');
ctx.fillStyle = 'rgba(0,100,255,.8)';
ctx.strokeStyle = 'rgba(255, 100, 0, .8)';
ctx.lineWidth = 1;
var points = [ // {x:10, y:10, r: 3, sx: -1, sy: 2}
];
const lineRange = can.width / 6;
function init() { points = bronPoints(200, 3); window.tempPotins = [].concat(points); window.raf = requestAnimationFrame(loop);
}
function bronPoints(num, range) { var arr = []; for (var i = 0; i < num; i++) { arr.push({ x: Math.round(Math.random() * (can.width - 100) + 50), y: Math.round(Math.random() * (can.height - 100) + 50), r: !range ? Math.round(Math.random() * 5 + 5) : range, sx: Math.round(Math.random() * 7 - 3), sy: Math.round(Math.random() * 7 - 3), }) } return arr;
}
function loop() { ctx.clearRect(0, 0, can.width, can.height); drawLine(); drawPoint(); updatePoint(); window.raf = requestAnimationFrame(loop);
}
function drawPoint() { tempPotins.forEach(function(item, i) { ctx.beginPath(); ctx.arc(item.x, item.y, item.r, 0, 2 * Math.PI); ctx.closePath(); ctx.fill(); });
}
function updatePoint() { tempPotins.forEach(function(item, i) { item.x += item.sx; if (item.x >= can.width - item.r || item.x <= 0 + item.r) { item.sx = -item.sx; } item.y += item.sy; if (item.y >= can.height - item.r || item.y <= 0 + item.r) { item.sy = -item.sy; } });
}
function drawLine() { var arr = [].concat(tempPotins); while (arr.length > 0) { for (var i = 1, l = arr.length; i < l; i++) { if (isInRange(arr[0], arr[i])) { ctx.save(); ctx.beginPath(); ctx.moveTo(arr[0].x, arr[0].y); ctx.lineTo(arr[i].x, arr[i].y); ctx.closePath(); ctx.stroke(); ctx.restore(); } } arr.shift(); }
}
function isInRange(po1, po2) { var dis = Math.sqrt(Math.pow(po2.x - po1.x, 2) + Math.pow(po2.y - po1.y, 2)); return dis < lineRange;
}
init();
Developer | IEkiller |
Username | win7killer |
Uploaded | January 18, 2023 |
Rating | 3 |
Size | 2,396 Kb |
Views | 8,096 |
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 |
Css3-eyes | 1,807 Kb |
Canvas_paint | 3,104 Kb |
A Pen by IEkiller | 6,561 Kb |
Rain Of Text | 2,463 Kb |
Dir tree | 3,169 Kb |
Css3-rotate demo | 2,994 Kb |
Css border amazing-2 | 1,529 Kb |
Color selecter | 3,973 Kb |
Canvas snow | 2,572 Kb |
Css border amazing-1 | 1,841 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 |
Basic 3D Fullscreen Transition | Apetrov | 3,270 Kb |
Beveled corners using CSS border attribute | DawsonMediaD | 2,136 Kb |
Ipad Mini Showcase | Hornebom | 10,479 Kb |
Magnus 3 | ARocketfish | 7,944 Kb |
AngularJS Datalist Directive | M-e-conroy | 2,366 Kb |
Pagepilling.js | Blossk | 6,554 Kb |
Search Box in Content Moves to Fixed Header | Chriscoyier | 2,768 Kb |
JQuery exercise | Brian-baum | 3,780 Kb |
Popover Example | Seanboom | 2,429 Kb |
Css color for svg | Ademilter | 2,392 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!