We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 30c3d29 commit 0fa51b4Copy full SHA for 0fa51b4
1 file changed
external_library/gem/toxiclibs/geometry/voronoi2.rb
@@ -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
23
+ save_frame('voronoi-002.png')
24
+ no_loop
25
26
27
+def settings
28
+ size 450, 360
29
30
31
+def mouse_pressed
32
+ loop
33
0 commit comments