Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
27
Task/Animation/Ruby/animation-1.rb
Normal file
27
Task/Animation/Ruby/animation-1.rb
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
require 'tk'
|
||||
$str = TkVariable.new("Hello World! ")
|
||||
$dir = :right
|
||||
|
||||
def animate
|
||||
$str.value = shift_char($str.value, $dir)
|
||||
$root.after(125) {animate}
|
||||
end
|
||||
|
||||
def shift_char(str, dir)
|
||||
case dir
|
||||
when :right then str[-1,1] + str[0..-2]
|
||||
when :left then str[1..-1] + str[0,1]
|
||||
end
|
||||
end
|
||||
|
||||
$root = TkRoot.new("title" => "Basic Animation")
|
||||
|
||||
TkLabel.new($root) do
|
||||
textvariable $str
|
||||
font "Courier 14"
|
||||
pack {side 'top'}
|
||||
bind("ButtonPress-1") {$dir = {:right=>:left,:left=>:right}[$dir]}
|
||||
end
|
||||
|
||||
animate
|
||||
Tk.mainloop
|
||||
11
Task/Animation/Ruby/animation-2.rb
Normal file
11
Task/Animation/Ruby/animation-2.rb
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
Shoes.app do
|
||||
@direction = 1
|
||||
@label = para "Hello World! ", :family => 'monospace'
|
||||
|
||||
click {|button, left, top| @direction *= -1 if button == 1}
|
||||
|
||||
animate(8) do |f|
|
||||
t = @label.text
|
||||
@label.text = @direction > 0 ? t[-1] + t[0..-2] : t[1..-1] + t[0]
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue