Anonymous user
Voronoi diagram: Difference between revisions
→{{header|Nim}}
No edit summary |
|||
Line 1,268:
# generate diagram by coloring each pixel with color of nearest site
for x in 0 ..< img_width
for y in 0 ..< img_height
var dMin = dot(img_width, img_height)
var sMin: int
for s in 0 ..< nSites
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
img.drawRectangle(
startCorner=[sx[s] - 2, sy[s] - 2],
|