File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
external_library/gem/toxiclibs/geometry Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments