Voronoi diagram: Difference between revisions
Content added Content deleted
(add Ruby) |
|||
Line 586: | Line 586: | ||
def distance_to(px, py) |
def distance_to(px, py) |
||
Math:: |
Math::hypot(px - x, py - y) |
||
end |
end |
||
end |
end |
||
Line 597: | Line 597: | ||
ColourPixel.new( |
ColourPixel.new( |
||
3+rand(width-6), 3+rand(height-6), # provide a margin to draw a circle |
3+rand(width-6), 3+rand(height-6), # provide a margin to draw a circle |
||
RGBColour.new(rand( |
RGBColour.new(rand(256), rand(256), rand(256)) |
||
) |
) |
||
end |
end |