forked from ashbb/shoes_tutorial_html
/
gallery12.rb
43 lines (34 loc) · 924 Bytes
/
gallery12.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# gallery12.rb
require 'gallery12-flickr'
Shoes.app :width => 300, :height => 300, :title => 'Finding Photos on Flickr v0.1' do
extend FindingFlickr
para "Find: "
@input = para('panda', :weight => 'bold')
@star = image :left => 275, :top => 3, :width => 20, :height => 20 do
star 10, 10, 12, 10, 7, :fill => deepskyblue, :stroke => orange
end
def show_flickr
finding_flickr @input.text do |photos|
@photo = image photos[0], :left => 30, :top => 40
@e = every 10 do |i|
@photo.remove
@photo = image photos[(i + 1) % photos.length], :left => 30, :top => 40
end
end
end
def clear_flickr
@e.remove
@photo.remove
end
keypress do |k|
case k
when String
@input.text += k
when :backspace
@input.text = @input.text[0..-2]
else
end
end
show_flickr
@star.click{clear_flickr; show_flickr}
end