Here is the requested code. I am putting here two
examples. In the first one the buttons themselves
animate, and in the second one they do
not.
Example 1.
{curl 4.0 applet} {curl-file-attributes
character-encoding = "windows-latin-1"} {applet
{compiler-directives careful? = true} }
{let c1:Canvas = {Canvas
width = 10in, height = 5in, border-width = 1pt, background =
""} } {value c1} {let message1:EllipseGraphic =
{EllipseGraphic fill-color = {url
"control-panel-logo.gif"}, height
= 1in, width = 1in } } {let message2:EllipseGraphic
= {EllipseGraphic
fill-color = {url
"control-panel-logo.gif"}, height
= 1in, width = 1in } } {let
random:RolledRandom = {RolledRandom 0, 100}} {let f:Frame
=
{Frame
halign =
"center", width =
2in, color =
"red", font-size =
22pt } }
{let timer:#Timer} {let box:HBox =
{HBox
{Frame halign = "left", message1},
f, {Frame halign = "right",
message2},
{CommandButton
label="Start",
{on Action
do
{if-non-null timer
then
set timer.repeat =
-1
}
}
},
{CommandButton
label="Stop",
{on Action
do
{if-non-null timer
then
set timer.repeat =
0
}
} }
} }
{do let start-x:Distance =
2in, start-y:Distance = 1in {c1.add x = start-x, y =
start-y, box} let start-time:DateTime =
{DateTime} let drop-time:Time = 3s
set timer = {box.animate
frequency
= 60fps,
repeat = 0,
{on
TimerEvent
do
let elapsed-time:Time =
{start-time.elapsed}
let t:Time = {abs (elapsed-time mod drop-time*2) -
drop-time}
let y:Distance = start-y + 0.5 * 2(cm/s^2)*(t * t)
{c1.move-to-xy box, start-x,
y}
{f.add {random.next-roll}, replace? =
true}
} }
} ||--
{c1.add ||-- x =
2in, ||-- y =
1in, ||-- {text font-weight =
"bold", Words} ||-- } }
================================
Example 2.
{curl 4.0 applet} {curl-file-attributes
character-encoding = "windows-latin-1"} {applet
{compiler-directives careful? = true} }
{let c1:Canvas = {Canvas
width = 6in,
height = 5in,
border-width = 1pt,
background =
"" } }
{value c1} {let
message1:EllipseGraphic =
{EllipseGraphic fill-color = {url
"control-panel-logo.gif"}, height
= 1in, width = 1in } } {let message2:EllipseGraphic
= {EllipseGraphic
fill-color = {url
"control-panel-logo.gif"}, height
= 1in, width = 1in } } {let
random:RolledRandom = {RolledRandom 0, 100}} {let f:Frame
=
{Frame
halign =
"center", width =
2in, color =
"red", font-size =
22pt } }
{let box:HBox =
{HBox {Frame halign = "left",
message1},
f, {Frame halign = "right",
message2}
} }
{do let start-x:Distance =
.1in, start-y:Distance = 1in let
start-time:DateTime = {DateTime} let drop-time:Time =
3s let timer:Timer
= {box.animate
frequency
= 10fps,
repeat = 0,
{on
TimerEvent
do
let elapsed-time:Time =
{start-time.elapsed}
let t:Time = {abs (elapsed-time mod drop-time*2) -
drop-time}
let y:Distance = start-y + 0.5 * 2(cm/s^2)*(t * t)
{c1.move-to-xy box, start-x,
y}
{f.add {random.next-roll}, replace? =
true}
} }
{c1.add
x = start-x,
y = start-y,
box
} {c1.add x
= 5in, y =
start-y,
{spaced-hbox
{CommandButton
label="Start",
{on Action
do
set timer.repeat =
-1
}
},
{CommandButton
label="Stop",
{on Action
do
set timer.repeat =
0
}
} }
} }
-- Kamal
----- Original Message -----
Sent: Tuesday, December 27, 2005 9:32
PM
Subject: Re: Bouncing balls in Curl
Hi,
I have tried to add 2 buttons,
first button to start the bouncing balls and the random number
generation
2nd button to stop the bouncing balls and the random number
generation.
But due to the arrangement of the variables/parameters, i cant seem to
get the button to work. (i.e the parameter t appears after the button
definition.)
Could someone help me to quickly complete this portion please? My demo to
the CEO if i want to show Curl will be 1.5 days away.
Thanks, PT
Kamal Bhatt <[EMAIL PROTECTED]>
wrote:
There are various ways to do what you
want. The example below uses an HBox.
I would suggest reading more about different
containers and see what suits you best
for your application. The other choices could
be a say a Canvas or a Grid.
{curl 4.0 applet} {curl-file-attributes
character-encoding = "windows-latin-1"} {applet
{compiler-directives careful? = true} }
{let c1:Canvas = {Canvas
width = 6in, height = 5in, border-width = 1pt, background =
""} } {value c1}
{let message1:EllipseGraphic =
{EllipseGraphic fill-color =
{url
"control-panel-logo.gif"},
height = 1in, width = 1in } } {let
message2:EllipseGraphic =
{EllipseGraphic fill-color =
{url
"control-panel-logo.gif"},
height = 1in, width = 1in } }
{let random:RolledRandom = {RolledRandom 0,
100}} {let f:Frame =
{Frame
halign =
"center", width =
2in, color =
"red", font-size =
22pt } }
{let box:HBox =
{HBox {Frame halign = "left",
message1},
f, {Frame halign = "right",
message2}
} }
{do let start-x:Distance = 2in,
start-y:Distance = 1in {c1.add x = start-x, y =
start-y, box} let start-time:DateTime =
{DateTime} let drop-time:Time =
3s {box.animate frequency =
60fps, {on TimerEvent
do let
elapsed-time:Time =
{start-time.elapsed}
let t:Time = {abs (elapsed-time mod drop-time*2) -
drop-time}
let y:Distance = start-y + 0.5 * 2(cm/s^2)*(t * t)
{c1.move-to-xy box, start-x,
y}
{f.add {random.next-roll}, replace? =
true} }
} ||--
{c1.add ||-- x =
2in, ||-- y =
1in, ||-- {text font-weight =
"bold", Words} ||-- }
}
----- Original Message -----
Sent: Sunday, December 25, 2005 11:31
AM
Subject: Re: Bouncing balls in
Curl
Thanks Duke and Kamal for the response.
I had added another bouncing ball to what was posted here
earlier.
Can you tell me how i can make the 2 balls separated by a horizontal
distance of 2in and the random number appears between the 2 balls?
Yahoo! Photos Ring in the New Year with Photo
Calendars. Add photos, events, holidays, whatever.
{curl 4.0 applet} {curl-file-attributes character-encoding =
"windows-latin-1"} {applet {compiler-directives
careful? = true} } {let c1:Canvas =
{Canvas width = 6in, height = 5in, border-width = 1pt, background =
""} } {value c1} {let message1:EllipseGraphic =
{EllipseGraphic fill-color =
{url
"control-panel-logo.gif"},
height = 1in, width = 1in } } {let
message2:EllipseGraphic =
{EllipseGraphic fill-color =
{url
"control-panel-logo.gif"},
height = 1in, width = 1in } } {let
overlay:OverlayBox =
{OverlayBox {Frame halign =
"left", message1}, {Frame
halign = "right", message2},
{Frame valign =
"bottom",
height =
1in,
{huge color = "red",Lucky
Number!}
} } } {do let
start-x:Distance = 2in, start-y:Distance = 1in
{c1.add x = start-x, y = start-y, overlay} let
start-time:DateTime = {DateTime} let drop-time:Time
= 3s {overlay.animate frequency =
60fps, {on TimerEvent
do
let elapsed-time:Time =
{start-time.elapsed}
let t:Time = {abs (elapsed-time mod drop-time*2) -
drop-time}
let y:Distance = start-y + 0.5 * 2(cm/s^2)*(t * t)
{c1.move-to-xy overlay, start-x,
y} }
}
{c1.add x =
2in, y =
1in, {text font-weight =
"bold", Words} } }
******************************************* To unsubscribe
from this list, send a mail
to: mailto:[EMAIL PROTECTED] To contact a human
list administrator, send a mail
to: mailto:[EMAIL PROTECTED] To recieve a list of
other options for this list, send a mail
to: mailto:[EMAIL PROTECTED]
Yahoo! Shopping Find Great Deals on Holiday Gifts at Yahoo!
Shopping
{curl 4.0 applet} {curl-file-attributes character-encoding =
"windows-latin-1"} {applet {compiler-directives
careful? = true} }
{let c1:Canvas = {Canvas
width = 10in, height = 5in, border-width = 1pt, background =
""} } {value c1} {let message1:EllipseGraphic =
{EllipseGraphic fill-color =
{url "control-panel-logo.gif"},
height = 1in, width = 1in } } {let
message2:EllipseGraphic =
{EllipseGraphic fill-color =
{url "control-panel-logo.gif"},
height = 1in, width = 1in } } {let
random:RolledRandom = {RolledRandom 0, 100}} {let f:Frame
=
{Frame
halign =
"center", width =
2in, color =
"red", font-size =
22pt } } {let box:HBox =
{HBox
{Frame halign = "left",
message1},
f, {Frame halign = "right",
message2},
{CommandButton
label="Start",
{on Action
do
}
},
{CommandButton
label="Stop",
{on Action
do
} }
} }
{do let start-x:Distance = 2in,
start-y:Distance = 1in {c1.add x = start-x, y = start-y,
box} let start-time:DateTime =
{DateTime} let drop-time:Time = 3s
{let t:Timer = {box.animate
frequency =
60fps,
repeat =
0, {on
TimerEvent
do
let elapsed-time:Time =
{start-time.elapsed}
let t:Time = {abs (elapsed-time mod drop-time*2) -
drop-time}
let y:Distance = start-y + 0.5 * 2(cm/s^2)*(t * t)
{c1.move-to-xy box, start-x,
y}
{f.add {random.next-roll}, replace? =
true}
} }
} ||--
{c1.add ||-- x =
2in, ||-- y =
1in, ||-- {text font-weight =
"bold", Words} ||--
} }
******************************************* To unsubscribe from this
list, send a mail to: mailto:[EMAIL PROTECTED] To
contact a human list administrator, send a mail
to: mailto:[EMAIL PROTECTED] To recieve a list of
other options for this list, send a mail
to: mailto:[EMAIL PROTECTED]
|