html
html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--
A Voronoi diagram is a partitioning of a plane into regions based on distances to a specific set of points. Each region corresponds to a point, called a seed, and consists of all the points closer to that seed than to any other. This will be a series of codes for experiment and will be created in future gradually & hopefully. It is version 2.0 and enjoy this!
Created by: `ᴴᵗᵗየ
Created in: 29th Jan, 2025 at Sololearn
Voronoi Code no: 05
-->
<title>Voronoi v2.0</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/7.8.5/d3.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/d3-delaunay@6"></script>
<style>
* { margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: black; }
canvas { display: block; }
</style>
</head>
<body>
<script>
let points = [];
const numPoints = 100;
const width = window.innerWidth;
const height = window.innerHeight;
let ctx = document.createElement("canvas").getContext("2d");
Enter to Rename, Shift+Enter to Preview
css
css
1
Enter to Rename, Shift+Enter to Preview
js
js
1
alert("A Voronoi diagram is a partitioning of a plane into regions based on distances to a specific set of points.\n\nDrag your finger or mouse and even touch as well to see the some mesmerizing effects. Enjoy!");
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run