-
-
Save toothrot/80111 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shoes.app(:width => 200, :height => 70 * 4 + 40) do | |
background black | |
colors = [red, blue, green, yellow] | |
people = ["steve","ed","nick","tom"] | |
@next_color = colors.cycle | |
@next_color.next | |
@previous_color = colors.cycle | |
(colors.length - 1).times { @previous_color.next } | |
def names_n_colors(people, colors) | |
clear do | |
background black | |
names_n_colors = colors.zip(people).map do |color, person| | |
flow(:height => 70, :width => 200) do | |
border color, :strokewidth => 2 | |
my_label = subtitle person, :stroke => white | |
fill @previous_color.next | |
rotate(90) | |
a = arrow(104, 5, 30) | |
a.click { names_n_colors(swap_previous(people, person), colors) } | |
fill @next_color.next | |
rotate(180) | |
a = arrow(90, 45, 30) | |
a.click { names_n_colors(swap_next(people, person), colors) } | |
end | |
end | |
button "ok!" | |
end | |
end | |
def swap_previous(array, item) | |
idx = array.index(item) | |
array[(idx-1) % array.length],array[idx] = array[idx],array[(idx-1) % array.length] | |
array | |
end | |
def swap_next(array, item) | |
idx = array.index(item) | |
array[(idx+1) % array.length],array[idx] = array[idx],array[(idx+1) % array.length] | |
array | |
end | |
names_n_colors(people, colors) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment