Yeah, when you set the rotate method, that rotation sticks around, forgot to
mention. That's why my first example sped up linearly, I forgot to take that
into account.
I don't think putting a call to animate() inside a method is going to work
properly. It would be better if you had a method that changed the speed value
that is called inside the animate block. Here's an example of how it might work:
$speed = 8
Shoes.app :resizable => false do
transform(:center)
def taiji
image 280, 280, :top => 100, :left => 150 do
# drawing order is important!!!
stroke black
nofill
oval 0, 0, :radius =>140
#angle1 -> angle2 is clockwise, lead to fill surplus semi-circle
fill black
shape do
move_to 70, 50
arc_to 140,70,140,140,TWO_PI-PI/2,PI/2
arc_to 140,210,140,140,PI/2,TWO_PI-PI/2
arc_to 140,140,280,280,PI/2,TWO_PI-PI/2
end
stroke white
fill white
oval 70,140,:radius=>70 # erase the surplus black semi-circle
oval 120, 50, :radius =>20
fill black
oval 120, 190, :radius =>20
end
end
animate(20) do
clear
stroke black
fill white
oval 150, 100, :radius =>140
$spin += $speed
$ang.replace "#{$spin}"
rotate $speed
taiji
end
window :width => 150, :height => 70 do
para "Rotate Angle:"
$ang = para "0"; $spin = 0
button "Reverse" do
$speed *= -1
end
end
end
Subject: Re: I want to draw a taiji animation by shoes
From: [email protected]
To: [email protected]
Date: Fri, 7 Aug 2009 22:03:08 +0800
Thanks a lot!
It seems that each step in animation rotate angle is on the basis of previous
angle,not from original position.And if use clear method in animation,speed of
shoes will not be slow.Otherwise,speed will be slower and slower.
I append 2 buttons try to control rotate direction(clockwise or
anti-clockwise).But it does not work.Can animate method take effect in method?
On Fri, Aug 7, 2009 at 1:32 AM, Ehsanul Hoque <[email protected]> wrote:
Actually, it seems my code makes the taiji spin faster as time goes, not good.
This works the right way though:
Speed = 8
Shoes.app :width => 600, :height => 600, :resizable => false do
transform(:center)
para "Rotate Angle:"
ang = para "0"; spin = 0
def taiji
image 280, 280, :top => 100, :left => 150 do
# drawing order is important!!!
stroke black
nofill
oval 0, 0, :radius =>140
#angle1 -> angle2 is clockwise, lead to fill surplus semi-circle
fill black
shape do
move_to 70, 50
arc_to 140,70,140,140,TWO_PI-PI/2,PI/2
arc_to 140,210,140,140,PI/2,TWO_PI-PI/2
arc_to 140,140,280,280,PI/2,TWO_PI-PI/2
end
stroke white
fill white
oval 70,140,:radius=>70 # erase the surplus black semi-circle
oval 120, 50, :radius =>20
fill black
oval 120, 190, :radius =>20
end
end
animate(20) do |i|
clear
stroke black
fill white
oval 150, 100, :radius =>140
spin += Speed
ang.replace "#{spin}"
rotate Speed #30 * cnt
taiji
end
end
Subject: RE: I want to draw a taiji animation by shoes
From: [email protected]
Date: Thu, 6 Aug 2009 17:23:06 +0000
To: [email protected]
Hey, I just hacked together a solution. The problem was that it was taking too
long to draw, and the angle of spin was quite large. So it looked like it was
going anti-clockwise, when in fact it went clockwise, but far. Shoes itself is
also slow now. Anyways, this code works:
Speed = 0.1
Shoes.app :width => 600, :height => 600, :resizable => false do
transform(:center)
para "Rotate Angle:"
ang = para "0"
def taiji
image 280, 280, :top => 100, :left => 150 do
# drawing order is important!!!
stroke black
nofill
oval 0, 0, :radius =>140
#angle1 -> angle2 is clockwise, lead to fill surplus semi-circle
fill black
shape do
move_to 70, 50
arc_to 140,70,140,140,TWO_PI-PI/2,PI/2
arc_to 140,210,140,140,PI/2,TWO_PI-PI/2
arc_to 140,140,280,280,PI/2,TWO_PI-PI/2
end
stroke white
fill white
oval 70,140,:radius=>70 # erase the surplus black semi-circle
oval 120, 50, :radius =>20
fill black
oval 120, 190, :radius =>20
end
end
animate(20) do |i|
clear
#clear backgroud
stroke black
fill white
oval 150, 100, :radius =>140
spin = i*Speed
ang.replace "#{spin}"
rotate spin #30 * cnt
taiji
end
end
CC: [email protected]
Subject: I want to draw a taiji animation by shoes
From: [email protected]
To: [email protected]
Date: Thu, 6 Aug 2009 22:15:31 +0800
hi,
I'm from China.I want to produce a rotate taiji animation by shoes.But I found
2 problems.
1st,there is no fill() method(filled an enclose area with specified color) in
shoes.So I have
to first draw black area,then draw a white semi-circle to erase part of black
area to produce
Taiji map.Maybe someone has better method.
2nd,to make rotate animation,I draw a taiji map then rotate a certain angle in
each step.The
angle increased relate to time.Without animate,the taiji map was displalyed in
correct
rotated angle.But when I add animate method,the taiji does not rotate as I
expected.Sometimes
it rotate clockwise,sometimes it rotate anti-clockwise.I don't know why.
ruby code in attachment.
Jason Zhou
Get free photo software from Windows Live Click here.
Windows Liveā¢: Keep your life in sync. Check it out.
_________________________________________________________________
Get back to school stuff for them and cashback for you.
http://www.bing.com/cashback?form=MSHYCB&publ=WLHMTAG&crea=TEXT_MSHYCB_BackToSchool_Cashback_BTSCashback_1x1