Voronoi diagram: Difference between revisions

No edit summary
Line 1,268:
 
# generate diagram by coloring each pixel with color of nearest site
for x in 0 ..< img_width - 1:
for y in 0 ..< img_height - 1:
var dMin = dot(img_width, img_height)
var sMin: int
for s in 0 ..< nSites - 1:
if (let d = dot(sx[s] - x, sy[s] - y); d) < dMin:
(sMin, dMin) = (s, d)
Line 1,280:
# mark each site with a black box
let black = img.setColor(0x000000)
for s in 0 ..< nSites - 1:
img.drawRectangle(
startCorner=[sx[s] - 2, sy[s] - 2],
Anonymous user