Here is a simple sketch, that flashes new random voronoi cells, with random fill.
load_libraries 'mesh' # http://www.leebyron.com/else/mesh/
import 'megamu.mesh.Voronoi'
require 'set'
attr_reader :voronoi, :points
def setup()
size(300, 300)
color_mode HSB, 1.0
end
def draw
points = Set.new
10.times do
10.times do
points.add([rand*300, rand*300])
end
end
voronoi = Voronoi.new((points.to_a).to_java(Java::float[]))
regions = voronoi.get_regions
regions.each do |region|
region_coordinates = region.get_coords
fill(rand, rand, rand)
region.draw(self)
end
end
No comments:
Post a Comment