Skip to content

Instantly share code, notes, and snippets.

@maxdevel
Created November 21, 2008 21:44
Show Gist options
  • Save maxdevel/27649 to your computer and use it in GitHub Desktop.
Save maxdevel/27649 to your computer and use it in GitHub Desktop.
Shoes.app(:title => "MGang Clock v0.01", :width => 320, :height => 320, :resizable => true) do
background "#234".."#c03", :angle => 45
deg_increment = Math::PI / 4
@imgs = []
@style_over = { :width => 100, :height => 100 }
@style_out = { :width => 20, :height => 20}
def calculate_avatar_point(angle)
r = 115
center_x = 140
center_y = center_x
x = r * Math.cos(angle) + center_x
y = r * Math.sin(angle) + center_y
[x.to_i, y.to_i]
end
Dir[File.dirname(__FILE__) + '/img/*.jpg'].each do |img|
@imgs << (image img)
end
stack :align => 'center' do
@imgs.size.times do |i|
x, y = calculate_avatar_point( deg_increment *i)
img = @imgs[i].style(:top => x, :left => y, :width => 40, :height => 40)
rect x, y, 20, 20
img.hover do
img.style @style_over
@trace.text = "over... style: ", img.style.inspect
end
img.click do
@trace.text = "click. ", img.style.inspect
end
img.leave do
img.style @style_out
end
end
end
@trace = edit_line
@trace.style(:width => 300)
end
Shoes.app(:title => "MGang Clock v0.01", :width => 320, :height => 320, :resizable => true) do
background "#234".."#c03", :angle => 45
@radius=120
@imgs = []
@i = 0
@style_over = { :width => 100, :height => 100 }
@style_out = { :width => 20, :height => 20}
Dir[File.dirname(__FILE__) + '/img/*.jpg'].each do |img|
rad = 2 * 3.14159 / 8 * @i
@x=(Math.cos(rad)*@radius+140).to_i
@y=(Math.sin(rad)*@radius+140).to_i
@imgs << image(:top => @x, :left => @y, :width => 20, :height => 20) do
fill img
img.hover do
img.style @style_over
@trace.text = "over... style: ", img.style.inspect
end
img.click do
@trace.text = "click. ", img.style.inspect
end
img.leave do
img.style @style_out
@mask.remove
end
rect 0, 0, 20, 20
end
@mask = mask { rect x, y,20,20,10 }
@i += 1
end
@trace = edit_line
@trace.style(:width => 300)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment