Created
September 3, 2017 23:14
-
-
Save RH2/1602fd13cb17ce047658cd05e63d8b71 to your computer and use it in GitHub Desktop.
veronoiCanvas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Richard Attempts To Make Veronoi Diagrams</title> | |
</head> | |
<body> | |
</body> | |
<script type="text/javascript"> | |
var canvas = document.createElement("canvas") | |
var ctx = canvas.getContext('2d') | |
canvas.width=500 | |
canvas.height=500 | |
document.body.appendChild(canvas) | |
ctx.fillColor="black" | |
ctx.fillRect(0,0,canvas.width,canvas.height) | |
var points = [] | |
for (var i = 0; i < 100; i++) { | |
points.push(cInboundPoint()) | |
} | |
rPoints() | |
function rPoints(){ | |
ctx.fillColor="cyan" | |
for (var i = 0; i < points.length; i++) { | |
ctx.beginPath() | |
ctx.fillStyle="white" | |
ctx.arc(points[i][0],points[i][1],3,0,2*Math.PI,false) | |
ctx.fill() | |
} | |
} | |
function rRadiusONEtoMANY(i){ | |
for (var i = 0; i < points.length; i++) { | |
points[i] | |
} | |
} | |
function cInboundPoint(){ | |
var p = [Math.random()*canvas.width,Math.random()*canvas.height] | |
return p; | |
} | |
function cd(){ | |
var e = document.createElement("div") | |
return e; | |
} | |
function dist(a,b){ | |
var d = [a[0]-b[0],a[1]-b[1]] | |
var distance = | |
return distance; | |
} | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment