Skip to content

Commit 0fa51b4

Browse files
committed
colored voronoi
1 parent 30c3d29 commit 0fa51b4

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
require 'toxiclibs'
2+
attr_reader :colors, :gfx, :voronoi
3+
4+
def setup
5+
sketch_title 'Colored Voronoi'
6+
@gfx = Gfx::ToxiclibsSupport.new(self)
7+
complement = Toxi::ComplementaryStrategy.new.create_list_from_color(TColor::BLUE)
8+
@colors = complement.to_a # a ruby Array of TColors
9+
@voronoi = Toxi::Voronoi.new
10+
50.times do
11+
voronoi.add_point(TVec2D.new(rand(width), rand(height)))
12+
end
13+
end
14+
15+
def draw
16+
background 0
17+
stroke_weight 1
18+
stroke 255
19+
voronoi.get_regions.each do |polygon|
20+
fill colors.sample.toARGB
21+
gfx.polygon2D(polygon)
22+
end
23+
save_frame('voronoi-002.png')
24+
no_loop
25+
end
26+
27+
def settings
28+
size 450, 360
29+
end
30+
31+
def mouse_pressed
32+
loop
33+
end

0 commit comments

Comments
 (0)