<% matches = @tournament_stage.matches_ordered # depth of SVG tree depth = Math.log2(matches.count).floor+1; # height of SVG height = 200 * 2**Math.log2(matches.count).floor + 100; lastrx = 0 lastry = 0 lastrh = 0 lastrw = 0 %> <% %> <% (1..matches.count).each do |i| %> <% when 0 %> <% if matches[i-1].teams.count < @tournament_stage.tournament.min_teams_per_match %> stroke="red" fill-opacity="0.6" <% else %> stroke="green" <% end %> <% when 1 %> stroke="orange" <% when 2 %> stroke="yellow" <% when 3 %> stroke="grey" <% end %> /> " /> <% if matches[i-1].teams.first %> Team <%= matches[i-1].teams.first.id %> <% end %> VS " /> <% if matches[i-1].teams[1] %> Team <%= matches[i-1].teams[1].id %> <% end %> <% if i > 1 %> <% end %> <% if Math.log2(i+1) == Math.log2(i+1).ceil %> <% lastrx = rx lastry = ry lastrh = rh lastrw = rw %> <% end %> <% end %>