In this example, several fish are animated along different paths across the screen. The animations are set to loop continuously, so that the fish will endlessly complete the same cycle. The school of yellow fish was made by copying and pasting a single fish that was previously animated.
Each fish is a transparent bitmap with a white irregular polygon behind it as a mask.
in,ms
ThreeDeeRect
bottomLine
topLine
in,ms
ThreeDeeRect
bottomLine
topLine
placeholder
WjpositionChildViewer
<KinitAnimation
enterpage
endAnimation
leavepage
,%H.%
newbnds
positionChildViewer
serves
%the placeholder
train animation
-- on
opens
. On
sends
animate message
notifyAfter
"tank"
initAnimation
positionChildViewer
-- close
notifyBefore
endAnimation
isOpen
-- sizes
specified
r childViewer, bnds
newbnds= pageUnitsToClient(
strChecked
The aquatic scene below is actually taking place on another page in this book. A child viewer is displaying that page.
The rectangle behind the viewer has script to control its behavior.e rectangle behind it has script to control its behavior.
leavepage
enterpage
orangeFish
MplayAnimation
blueFish
yellowFish3
yellowFish2
animSysbookLoaded
yellowFish1
initAnimation
orangeFish
blueFish
yellowFish3
ZstopAnimation
yellowFish2
animSysbookLoaded
yellowFish1
endAnimation
initAnimation
animSysbookLoaded()
playAnimation 1
'"yellowFish1"
'"yellowFish2"
'"yellowFish3"
'"blueFish"
'"orangeFish"
endAnimation
stopAnimation
yellowFish3
anim_animationSettings
(( (
w{'w(w{
blueFish
anim_animationSettings
yellowFish1
anim_animationSettings
(( (
w{'w(w{
yellowFish2
anim_animationSettings
(( (
w{'w(w{
orangeFish
anim_animationSettings
TT9T4
4994Y94
T5EEU
TTUP}
19Y9EEU
CDTUP
DUEEH
11995LU
EDTTP
11990
EKG monitor
label
myChapterID
visited
The path animation system book allows you to animate an object at either a constant or variable speed over the length of its path.
When a constant speed is chosen, the object moves over the length of its path at a steady rate. However, when a variable rate is chosen, the object moves quickly between distant points on its path and slowly between points that are near to one another.
illustrates an animation that is best done with a variable rate. The monitor's beam should move across the screen at a steady rate but up and down at varying rates.
anim_animationSettings
Start
MplayAnimation
variable
buttonUp
enterPage
playAnimation 1
"Beam"
notifyBefore
735,4545
startPosition
Start
ZstopAnimation
buttonUp
leavePage
stopAnimation
"Beam"
notifyBefore
Variable
MplayAnimation
buttonUp
playAnimation 1
"beam"
Variable Rate
Constant
MplayAnimation
buttonUp
playAnimation 2
"beam"
Constant Rate
in,ms
ThreeDeeRect
bottomLine
topLine
This example illustrates an animation that is best done with a variable rate. The monitor's beam should move across the screen at a steady rate but up and down at a faster rate..
enterPage
leavePage
false
Path animation sysbook
label
myChapterID
false
visited
Multimedia ToolBook comes with a sysbook that makes animations along paths easy to create and maintain. You can animate along straight or curved paths.
in,ms
ThreeDeeRect
bottomLine
topLine
in,ms
ThreeDeeRect
bottomLine
topLine
Here are two examples of the types of paths you can use.to animation.
(( (
w{'w(w{
Moving frame animation
label
myChapterID
visited
The animation sysbook makes combining movement and frame animation easy. All you need to do is create a group of objects, specify a path, and then turn frame animation on.
in,ms
ThreeDeeRect
bottomLine
topLine
globe
MplayAnimation
animSysBookLoaded
enterpage
ZstopAnimation
animSysbookLoaded
leavePage
notifyBefore
animSysBookLoaded()
playAnimation 1
notifyAfter
animSysbookLoaded()
stopAnimation
curframe
anim_animationSettings
in,ms
ThreeDeeRect
bottomLine
topLine
Here we have our familiar animated earth with movement added.ded.
enterpage
leavePage
false
,%H.%
Displays/hides Template Outline palette.
helpTemplate
&Contents
Change To&pic Name..
The path animation sysbook is not loaded. Animations in the "Path Animation" sections will not run. Be sure that either mtb30.sbk or mtb30ani.sbk are included in your startupSysbooks.
Using this &Template
false
Displays help on using this template.
Options for modifying content of this template.
Changes name of current chapter.
New &Chapter...
outline
animSysbookLoaded
Cvisited
changeName
rebuildStructure
tableOfContents
toolbar
tableofcontents
firstTime
firstTime
Adds new chapter to this book.
Change C&hapter Name..
Changes name of topic chapter.
New &Topic...
author
Adds new topic to this chapter.
contents
topicsBackground
Template &Outline
enterApplication
Change Chapter Name...
chaptersBackground
author
outline
Change Topic Name...
contents
TopicsBackground
entermenu
helpTemplate
Contents
leaveapplication
outline
toolbar
author
outline
toolbar
reader
outline
mstate
rebuildStructure
contents
outline
w, #?
chaptersBackground
This template is limited to
chapters.
/%chapterCount
chapterLimit
topicsBackground
newBackground
chapterLimit
chapter headings
chaptersBackground
topics
topicsBackground
w, #>
.&, 7
w, #>
PBmyPages
voutline
curChapterId
myChapterID
pagelabel
chapterCount
outline
tabSpacer
curPageId
tableofcontents
tableOfContents
chaptersBackground
ainitPage
0%chapterCount
label
topicsBackground
rebuildStructure
.&, "
extractName
extractID
,%H.%
itemOffset
O@middleGray
9@darkBlue
tabSpacer
tableOfContents
tableofcontents
updatechecks
tableOfContents
.&, "
Cannot find book TMPLHELP.TBK
mydir
tmplhelp.tbk
helpTemplate
initPage
w, #?
Enter new chapter name.
cancel
This template is limited to
chaptersBackground
label
rebuildStructure
tableOfContents
toolbar
chapterName
chapters.
/%chapterCount
chapterLimit
Untitled
topicsBackground
newChapter
cancel
Enter new topic name.
chaptersBackground
lastPage
label
rebuildStructure
tableOfContents
toolbar
chapterName
Untitled
topicsBackground
newTopic
cancel
Enter new name.
label
rebuildStructure
label
changeName
firstTime
saveAs
about
aboutAnimate
mtb30.sbk
false
mtb30anm.sbk
animSysbookLoaded
SYSTEM OLD
PROGMAN INI
TASKMAN EXE
TECHNOTEINI
TERMINALEXE
train
b;origloc
train
animate
b;origloc
train
initAnimation
animate
t =
"train"
rightMost =
p =
moveAmount = 45
origloc
initAnimation
t =
visited
false
strChecked
train
origloc
-1485,90
strChecked
train
scriptRecorderPopup1
strChecked
pageUnits
visited
false
strChecked
strChecked
Page Units:
Each pixel on the screen is several page units wide by several units tall. The amount varies depending on your screen resolution. The sysPageUnitsPerPixel system property will tell you how many page units there are for each horizontal and vertical pixel represented on the screen. For example, in standard VGA, there are 15 page units per horizontal pixel and 15 per vertical pixel.
pageUnits
strChecked
scriptRecorderPopup1
visited
false
strChecked
scriptRecorderPopup1
strChecked
To use the script recorder:
1. Make sure the objects you want to move are not selected.
2. Choose Start Recording from the Edit menu.
3. Drag the objects along the path you want them to follow, clicking frequently to record the movement.
4. Choose Stop Recording from the Edit menu.
5. In the script of the button that starts the animation, choose Paste Recording from the script editor's Edit menu..
strChecked
scriptRecorderPopup2
visited
false
strChecked
strChecked
Guidelines for using the script recorder:
The main advantage of the script recorder is that you can create animation without writing scripts. However, there are also disadvantages:
Difficult to modify To change a recorded animation, you must either edit the script ToolBook created or record the animation again.
Difficult to create smooth movement It may be hard to create uniform spacing and direction between each step of the animation.
If you need to create smooth, easily modifiable animation, you may want to examine the topics in the Useful Scripts section of this book.......
scriptRecorderPopup2
strChecked
aboutAnimation
about
keychar
isOpen
focuswindow =
keyEnter
close
"about"
strChecked
in,false
ThreeDeeRect
strChecked
strChecked
bottomLine
strChecked
topLine
strChecked
strChecked
,%H.%
0,100,0
0,0,0
0,100,0
buttonclick
0,100,0
switch
tvOn
value
buttonclick
switch
(32)+32
(32)+32
--
(32)+32
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
out,true
ThreeDeeRect
strChecked
strChecked
bottomLine
strChecked
topLine
strChecked
false
about
screen
buttonclick
buttonclick
isOpen
"tv 1"
tvOn
T"screen"
close
"about"
strChecked
strChecked
strChecked
0"@"J
strChecked
strChecked
T#d#J
strChecked
strChecked
strChecked
strChecked
strChecked
,&<&J
strChecked
strChecked
L'\'J
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
B+R+J
strChecked
strChecked
childloc
l,|,J
strChecked
frame
strChecked
b-r-J
strChecked
lastTime
strChecked
strChecked
Animation Book
Created in
ToolBook 3.0
Asymetrix Corporation
strChecked
R0b0J
strChecked
strChecked
F1V1J
strChecked
strChecked
screen
>2J2mp
X2h2J
lastTime
strChecked
strChecked
strChecked
strChecked
clock
childloc
strChecked
strChecked
screen
lastTime
strChecked
strChecked
strChecked
angle
strChecked
strChecked
strChecked
enterbackground
about
keychar
keyEnter
close
"about"
strChecked
strChecked
Written by
Joseph Brickkkin
ToolBook 3.0
Asymetrix Corporation
maxBounce
myInfo
-30,3,1
strChecked
-30,2,1
WINHELP
outlineOrganizer
chapterCount
topicCount
selectChars
false
visited
strChecked
strChecked
outline
topline
group
topLine
X sizeIt
bottomLine
sizeIt
sizeIt
bottomLine
topline
m"topLine"
objs
rec =
sz =
pupp = syspageUnitsPerPixel
sz >
sz >
xpix =
syspageunitsperpixel
ypix =
b =
ll =
lr =
ur =
ul =
ul,lr
--
ll,lr,ur
--
ll,ul,
in,ms
ThreeDeeRect
bottomLine
topLine
outline
strChecked
selectedTextline
Moving objects 5
Position property 7
Script recorder 6
Move command 11
Move to command 4
Move by command 3
Moving on idle 12
Frame animation 2
How it works 13
Hiding and showing 14
Animating buttons 15
Useful scripts 16
Animating with color 17
Simulating gravity 18
Timing animation 19
Moving along a line 20
Using path animation 36
Path animation sysbook 40
Fish tank 37
EKG monitor 39
Moving frame animation 41
Untitled 45
Untitled 46
marker
vertLoc
vertLoc b
value
ypix =
syspageunitsperpixel
s =
halfH =
C- 3*
strChecked
buttonGroup
yunewTopic
false
outline
newChapter
Chapter
ainitpage
Untitled
header
title
buttonclick
buttonclick
stl = selectedTextLines
"outline"
vRef
parentwindow
initpage
currentPage
%modal
isopen
pRef
close
title = "Untitled"
B"Chapter"
newChapter
newTopic stl
strChecked
&New...
editTopic
strChecked
&Delete
updateButtons
check
buttonclick
buttonclick
s_cancel
buttonclick
buttonclick
4s_cancel
Edit &Title:
header
topline
group
topLine
X sizeIt
bottomLine
sizeIt
sizeIt
bottomLine
topline
m"topLine"
objs
rec =
sz =
pupp = syspageUnitsPerPixel
sz >
sz >
xpix =
syspageunitsperpixel
ypix =
b =
ll =
lr =
ur =
ul =
ul,lr
--
ll,lr,ur
--
ll,ul,
in,ms
ThreeDeeRect
bottomLine
topLine
header
pageId
lineNum
Fish tankjectsnimation
character
paragraph
arrow6
arrow1
arrow2
arrow3
arrow4
arrow5
wrwww
w"'ww
r'"ww
"wr'w
'ww"w
wwwr'
wwww"
wwwwr
wxwww
wwwwx
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwww
wwwwwwwwwwww
wwwwwwwwwwwww
wwwwwwwwwwwww
wwwwpw
pwwwxxwwwwx
wwwwpwwwwww
wwwww
xxwww
wwwwpp
xxwwxx
wwwwwxx
xxwwwwwxx
wwwww
wxxxxxxwwwxx
wwwwx
xxwwwwxxxxxww
wxxxxxwwwxxxx
wwwww
xwwwwxxxxxww
wwwww
wwxxwxwwwwxx
wwwwx
xwwww
wwwwx
wwwwxxwwwxx
wwwww
wwwwwwp
wwwwwp
wwwwwwx
wwwwp
wwwwwwwwx
wwwwww
wwwwwwwwwx
wwwwww
wwwwwwww
wwwwwwwwwwwww
wwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwww
wwwwwwwwwwww
wwwwwwwwwwwww
wwwwwwwwwwwww
wwwwxxwwwwwwxxwwwwx
wwwwwwwwwww
wwwww
xxxwww
wwwwxxw
wwwwxxx
wwwwx
xwwwwx
wwxpx
xxwwwww
wwxxxp
xxxwww
wwwxxw
xxwwww
wwwww
wwwwww
wwwww
wwwww
wwwwwww
wwwwwp
wwwwwwwp
wwwww
wwwwwwx
wwwwwp
wwwwp
wwwwwwwwx
wwwwww
wwwwwwwwwx
wwwwww
wwwwwwww
wwwwwwwwwwwww
wwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
"""""""""""""
**********
**********
**********
**********
""""""""""""""
**********"
***********"
************
***********
""""""""""""""
********"
*********"
**********
*********
"""""""""""""
******"
*******"
********
*******
"""""""""""""
*****
****"
*****
*****"
*****
******
*****
*****
"""""""""""""
*********
*********
*********
*********
xxxxp
wwwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwx
wwwwwwwwwwwww
wwwwwwwxxxx
wwwwwwwwwww
wwwwwwwwwwx
wwwwwwwwwww
wwwwwwwwww
wwwwwwwwwwW
wwwwwwwwwp
wwwwwwwwww
twwwwwwwww
wwwwwwwww
)wwwwwwwwx
wwwwwwwww
wwwwwwwwpx
wwwwwwwwwf
wwwwwwww
pwwwwwwwww
@wwwwwwww
wwwwwwww
wwwwwwww
wwwwwwww
Vwwwwwwww
wwwwwwww
wwwwwwww
pwwwp
wwwwwwww
Gwwwwwwww
wwwwwwwwEUwwwwwwww
wwwpww
wwwwwwww
wwwwwwww
wwwwwwww
xwwwwwwww
wwwwwwww
wwwwwwww
wxxxx
wwwwwwwwF
wwwwwwwwp
wwwwwwww
&wwwwwwwwp
wxxpwwwwwwwww
&wwwwwwwwx
wwwwwwwww
&wwwwwwwww
wwwwwwwww
wwwwwwwwwp
wwwwwwwwww
wwwwwwwwww
wwwwwwwwww
Fwwwwwwwwwwx
wwwwwwwwwww
Xwwwwwwwwwww
wwwwwwwwwww
wwwwwwwwwwww
wwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwx
toolbar
ComboBox
xcombobox
focuswindow =
false
visited
strChecked
chapterCount
topicCount
previous
buttonclick
buttonclick
-- sends the
message
currentPage
strChecked
buttonclick
buttonclick
-- sends the
tmessage
currentPage
strChecked
heading
raisedField
tbk_wid_name
faceColor
highlightColor
shadowColor
tbk_wid_props
color,hls
color,hls
color,hls
tbk_wid_values
faceText
strChecked
highlight
strChecked
Using path animation
shadow
strChecked
Using path animation
J Z J
strChecked
Using path animation
buttonclick
buttonclick
currentPage
focuswindow =
strChecked
tableOfContents
tableOfContents
buttonclick
buttonclick
-- handled
Hthe
message navigates
-- table
contents
tableOfContents
currentPage
strChecked
Contents
SectionLabel
strChecked
Section:
outline
@4bookOverview
buttonup
bookOverview
strChecked
topics
topics
buttonclick
buttonclick
-- causes navigation
chapter heading
currentPage
focuswindow =
strChecked
Chapter Topics
helpTemplate
buttonclick
buttonclick
helpTemplate
strChecked
toolbar
Moving on idle
label
myChapterID
visited
Whenever ToolBook is not running scripts, it receives the idle message. If you want an animation to run constantly while nothing else is happening, trigger each step of the animation upon the idle message.
The advantage to animation driven by the idle message is that you can interrupt the animation at any time to interact with other parts of the application. The key is to handle only one "step" of the animation per execution of the idle handler.handler.
in,true
ThreeDeeRect
strChecked
ballbounds
strChecked
bottomLine
strChecked
topLine
strChecked
in,true
ThreeDeeRect
strChecked
strChecked
bottomLine
strChecked
topLine
strChecked
strChecked
The bouncing ball moves by a small amount upon each execution of the idle handler. Note that you can press any of the buttons on the tool bar or go to another application at any time.during this animation.
elapsedTime
curDir
vector
maxBounce
150,15,-1
myInfo
strChecked
false
How it works
label
myChapterID
visited
To create frame animation, you display a series of images quickly in sequence, each one slightly different than the one preceding it. The differences between the frames cause the object's apparent movement.
The animation at the top is a series of sixteen paint objects, shown individually below.
strChecked
out,true
ThreeDeeRect
strChecked
strChecked
bottomLine
strChecked
topLine
strChecked
strChecked
strChecked
out,true
ThreeDeeRect
strChecked
< L J
strChecked
bottomLine
strChecked
topLine
strChecked
strChecked
strChecked
strChecked
strChecked
curFrame
myCurFrame
myCurFrame
newFrame
hides
shows frames (paintobjects)
the globe animation.
-- The paintObjects are named "1"
notifybefore
numFrames = 16 --
curFrame = myCurFrame
-- currently showing
newFrame =
-- store
myCurFrame
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
*!:!J
strChecked
strChecked
strChecked
#0#J
strChecked
in,true
ThreeDeeRect
strChecked
f$v$J
strChecked
bottomLine
strChecked
P#b%n%
topLine
strChecked
widget slows down everything,
notifybefore
lastTime
strChecked
Slow-Mo
in,true
ThreeDeeRect
strChecked
,(<(J
strChecked
bottomLine
strChecked
'()4)
topLine
\)l)J
strChecked
strChecked
This globe animation is a series of paintObjects, shown one after the other.......the other.
curFrame
myCurFrame
mycurframe
highlight
newFrame
moves the
over
appropriate globe.
"globes are
numbered "1"
notifybefore
numFrames = 16 --
paintObjects
current
showing:
curFrame = mycurframe
newFrame =
myCurFrame
<-L-J
myCurFrame
strChecked
*f.l.
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
.6>6J
strChecked
D7T7J
strChecked
*,848
\8l8J
strChecked
*D9L9
strChecked
*\:d:
strChecked
*t;|;
strChecked
strChecked
strChecked
strChecked
highlight
strChecked
false
Hiding and showing
label
myChapterID
visited
A common method for creating frame animation is to hide and show objects in a group using the hide and show commands.
This animation hides and shows one paint object after another. Each paint object shows the dog in a different position. A user property of the group keeps track of which frame is currently shown.
out,true
ThreeDeeRect
strChecked
strChecked
bottomLine
strChecked
topLine
strChecked
curFrame
myCurFrame
myCurFrame
newFrame
-- This handler controls the animation
-- The
consists
18 paintobjects, named
-- 1
18, respectively. For each execution
(sent constantly
mode)
advanced one frame.
currently shown
stored
%a userProperty
notifybefore
numFrames = 18 --
paintObjects
ping
curFrame = myCurFrame
-- calculate
newFrame =
so we know what
h t (
curdog
lastTime
myCurFrame
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
in,true
ThreeDeeRect
strChecked
strChecked
bottomLine
h x J
strChecked
topLine
strChecked
strChecked
The running dog above is a series of 18 frames, shown one after the other. Small differences in the t at least 30 milliseconds have passed before displaying the next frame. This way, no more that 24 frames per second
false
Animating buttons
label
myChapterID
false
visited
Buttons can display bitmap resources, which are stored in the book. In its normal state, a button displays the bitmap resource specified by its normalGraphic property. When you press the button, the button displays its invertGraphic. You can use these properties to create an animation effect.
The button on the right displays an animation when clicked.K
in,true
ThreeDeeRect
bottomLine
topLine
This button has two frames of animation: one specified by its normalGraphic, the other specified by its invertGraphic, which is displayed when clicked.
5bookref
,%H.%
,%H.%
false
5bookref
found
5bookref
notifyBefore
normalgraphic
k4 + 1
bitmap ("cd"&
bookref
notifyAfter
bref =
rl = resourceList("
found =
rl) = "cd"&i
C:\HOOK\CBT\NEWANIM.TBK
bookref
in,true
ThreeDeeRect
bottomLine
topLine
These buttons set their normalGraphic property to a series of images.lGraphic, the other specified by its invertGraphic.
arrow
5bookref
,%H.%
,%H.%
false
5bookref
found
5bookref
arrow
notifyBefore
normalgraphic
k6 + 1
bitmap ("arrow"&
bookref
notifyAfter
bref =
rl = resourceList("
found =
rl) = "
C:\HOOK\CBT\NEWANIM.TBK
bookref
Useful scripts
label
myChapterID
17,18,19,20
myPages
This section contains reusable handlers you can use to make writing your animation scripts easier.
17,18,19,20
Animating with color
label
myChapterID
false
visited
Not all animation involves moving or hiding objects. You can create an animation just by setting the colors of various objects.
The object representing the TV screen has a script that cycles its rgbFill property through 512 colors of the RGB spectrum.
Each panel of the colorful sculpture on the right cycles through four colors.
out,true
ThreeDeeRect
strChecked
strChecked
bottomLine
strChecked
topLine
strChecked
in,true
ThreeDeeRect
strChecked
strChecked
bottomLine
strChecked
topLine
& 6 J
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
curColor
fucurColor
gucurColor
notifybefore
Zcolorlist[4]
1]=128,128,0
2]=255,0,255
+3]=0,128,128
;=0,255,0
curColor =
k4 + 1
orgbfill
colorList[
curColor
strChecked
curColor
fucurColor
gucurColor
notifybefore
Zcolorlist[4]
1]=128,128,0
2]=255,0,255
+3]=0,128,128
;=0,255,0
curColor =
k4 + 1
orgbfill
colorList[
curColor
strChecked
curColor
fucurColor
gucurColor
-- cycles through four colors
notifybefore
Zcolorlist[4]
1]=128,128,0
2]=255,0,255
+3]=0,128,128
;=0,255,0
curColor =
k4 + 1
orgbfill
colorList[
curColor
strChecked
curColor
fucurColor
gucurColor
notifybefore
Zcolorlist[4]
1]=128,128,0
2]=255,0,255
+3]=0,128,128
;=0,255,0
curColor =
k4 + 1
orgbfill
colorList[
curColor
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
"0"J
strChecked
strChecked
#0#J
strChecked
strChecked
6$F$J
strChecked
strChecked
L%\%J
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
J)Z)J
strChecked
strChecked
>*N*J
strChecked
strChecked
2+B+J
strChecked
strChecked
.&, "
.&, "
oplastTime
timegettime
-- cycle through 512 colors
the rgb spectrum.
notifybefore
inc = 32 -- amount
each
orgbfill
r = (r+
g = (g+
b = (b+
lastTime
timegettime()
N/^/J
strChecked
lastTime
strChecked
o P3&
strChecked
J1Z1J
strChecked
strChecked
strChecked
strChecked
strChecked
04@4J
strChecked
strChecked
b5r5J
strChecked
"626J
strChecked
strChecked
B7R7J
strChecked
strChecked
f8v8J
strChecked
&969J
strChecked
Simulating gravity
label
myChapterID
false
visited
This page has a useful handler for animating falling objects. You provide the handler with the object that you want to "drop," how tall that object is supposed to be, where the ground is, and the starting speed of the object.
Press the Animate button on the right to see a demonstration.{
out,true
ThreeDeeRect
strChecked
strChecked
bottomLine
strChecked
topLine
strChecked
in,true
ThreeDeeRect
strChecked
strChecked
bottomLine
strChecked
topLine
strChecked
ground
strChecked
V f J
strChecked
.animate
buttondown
animate message, handled
strChecked
out,false
ThreeDeeRect
strChecked
strChecked
bottomLine
strChecked
topLine
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
Animate
thought
strChecked
thought5
strChecked
thought4
strChecked
thought3
strChecked
thought2
strChecked
thought1
strChecked
ground
finaly
accelerate
animate
animate
finaly =
U"ground"
accelerate
,2,finalY
,1.5,
5625,684
origloc
strChecked
strChecked
strChecked
strChecked
Timing animation
label
myChapterID
visited
When you want animation to move at a particular speed regardless of the machine it's on, you can write a handler to check the time during the animation process.
The function timeGetTime() in the mmsystem DLL file is useful for this purpose. This function returns the time in milliseconds. The mmsystem DLL comes with Windows 3.1.
out,true
ThreeDeeRect
strChecked
strChecked
bottomLine
strChecked
topLine
strChecked
in,true
ThreeDeeRect
strChecked
strChecked
bottomLine
strChecked
topLine
strChecked
strChecked
The animated globe above is a series of 16 frames. The buttons controlling its speed set a user property of the globe called Delay to various values (0 for "Fast," 60 for "medium," and 120 for "Slow"). The script in the globe checks to see if at least that many milliseconds have passed before displaying the next frame....
speedControl
strChecked
globe
delay
buttonclick
buttonclick
delay
"globe"
strChecked
Fa&st
globe
delay
buttonclick
buttonclick
delay
"globe"
strChecked
&Medium
globe
delay
buttonclick
buttonclick
delay
"globe"
strChecked
Slo&w
strChecked
globe
4478050,10,0
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
enterpage
false
Moving along a line
label
myChapterID
false
visited
Often, you just want to move an object along a straight line. This page contains a handler for doing that. You pass it the object you want to move, the line that you want to move the object along, and how many steps you want to take along the line.
Note that this handler will move an object along angled lines as well. Once you've positioned the guiding lines, you can hide them.
strChecked
PmoveObjectAlongPath
buttonclick
buttonclick
-- sends message handled
moveObjectAlongPath
m"path",15
strChecked
in,true
ThreeDeeRect
strChecked
strChecked
bottomLine
strChecked
topLine
strChecked
strChecked
Click each of the ellipses above to see them move along their respective paths.
PmoveObjectAlongPath
buttonclick
buttonclick
-- sends message handled
moveObjectAlongPath
"yoyo",40
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
out,true
ThreeDeeRect
strChecked
strChecked
bottomLine
strChecked
topLine
strChecked
out,true
ThreeDeeRect
strChecked
strChecked
bottomLine
strChecked
topLine
strChecked
topic
raisedField
tbk_wid_name
faceColor
highlightColor
shadowColor
tbk_wid_props
color,hls
color,hls
color,hls
tbk_wid_values
strChecked
highlight
strChecked
Table of contents
shadow
strChecked
Table of contents
strChecked
Table of contents
strChecked
Click on one of the topics below to view information on that subject.ubject.
toolbar
ThreeDeeRect
out,true
bottomLine
topLine
strChecked
strChecked
strChecked
strChecked
strChecked
toolbar
newpage
previous
first
strChecked
tableOfContents
myChapter
myPages
chapterCount
topicCount
false
visited
24,27
selectChars
strChecked
tableOfContents
strChecked
60,Cats
68,Dogs
pageList
strChecked
chapter1
strChecked
pageID
Moving objectser
check1
strChecked
strChecked
chapter2
strChecked
pageID
Frame animation
check2
strChecked
strChecked
chapter3
Timing Animation 66
Simulating Gravity 67
topics
strChecked
pageID
Useful scriptsn
check3
strChecked
strChecked
chapter4
Chickens 26
Goats 25
topics
pageID
strChecked
Using path animation
check4
strChecked
strChecked
chapter5
strChecked
pageID
Untitled
check5
strChecked
strChecked
chapter6
strChecked
check6
strChecked
strChecked
chapter7
strChecked
check7
strChecked
strChecked
chapter8
strChecked
check8
strChecked
topLine
ThreeDeeRect
in,true
strChecked
strChecked
bottomLine
strChecked
strChecked
strChecked
This book shows you various techniques for animating objects, with and without writing handlers.
tableOfContents
Frame animation
label
myChapterID
chapterCount
topicCount
13,14,15
myPages
A common method to display a complex animation is to create several frames and show them in a series, similar to the way a movie works. This section covers the basics of frame animation using OpenScript.
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
4 D J
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
trailerCountdown
lastTime
myAngle
strChecked
strChecked
strChecked
strChecked
minute
strChecked
counter
strChecked
enterpage
13,14,15
Move by command
label
myChapterID
visited
Use the move by command when you want to move an object relative to its current position. For example, the command "move rectangle id 1 by 45,90" would move this object 45 page units to the right and 90 page units down.
This example uses move by in a loop to move the golf ball into the hole. The amount that the ball moves for each loop is calculated from the positions of the two objects. Note that the ball goes into the hole no matter where it starts from.
out,true
ThreeDeeRect
strChecked
strChecked
bottomLine
strChecked
topLine
strChecked
in,true
ThreeDeeRect
strChecked
strChecked
bottomLine
strChecked
topLine
strChecked
green
j z J
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
out,false
ThreeDeeRect
strChecked
strChecked
bottomLine
strChecked
topLine
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
Animate
false
Move to command
label
myChapterID
visited
Use move to to move an object to a specific place. This is useful when the animated path of one object is relative to the positions of other objects.
The example at the right shows a moon orbiting a planet. The path that the moon follows is not an ellipse; it's a polygon with 50 vertices. The example script simply moves the moon object to each vertex of the polygon, one after the other.
out,true
ThreeDeeRect
strChecked
strChecked
bottomLine
strChecked
topLine
strChecked
in,true
ThreeDeeRect
strChecked
strChecked
bottomLine
strChecked
topLine
strChecked
orbit
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
out,false
ThreeDeeRect
strChecked
strChecked
bottomLine
strChecked
topLine
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
.animate
buttondown
orbit
moonRef
animate
-- sends the animate message
-- moves
along
-- optimization: store
{reference
%we will
-- be refering
moonRef =
sz =
-- we are going
walk
, so let's
-- cache them
vs =
"orbit"
come
a list
pairs
-- one
each vertex. For
iteration
loop,
-- we
grab
y positions
E, subtract half
ball's
positioning relative
that
(vs)
strChecked
Animate
false
myChapterID
7,6,11,4,3,12
myPages
Moving objects
label
Most animation involves moving an object from one place to another. The topics in this section discuss the various techniques for moving objects using OpenScript.
strChecked
placeholder
WjpositionChildViewer
train
<KinitAnimation
enterpage
train
leavepage
,%H.%
newbnds
positionChildViewer
.animate
train
serves
%the placeholder
train animation
-- on
opens
. On
sends
animate message
notifyAfter
initAnimation
positionChildViewer
-- close
notifyBefore
isOpen
-- sizes
specified
r childViewer, bnds
newbnds= pageUnitsToClient(
strChecked
strChecked
strChecked
leavepage
enterpage
7,6,11,4,3,12
Script recorder
label
myChapterID
visited
You can animate objects without writing scripts yourself by using the script recorder. This is useful when you want to animate one or more objects along an arbitrary path.
How to use the script recorder
When to use the script recorder
The animation to the right was created using the script recorder.
scriptRecorderPopup
buttonclick
buttonclick
"scriptRecorderPopup"
strChecked
strChecked
scriptRecorderPopup2
buttonclick
buttonclick
"scriptRecorderPopup2"
strChecked
strChecked
strChecked
strChecked
ThreeDeeRect
out,true
strChecked
strChecked
bottomLine
strChecked
topLine
strChecked
strChecked
ThreeDeeRect
in,true
strChecked
strChecked
bottomLine
strChecked
topLine
strChecked
balloonpath
strChecked
cloudpath
strChecked
cloud
strChecked
strChecked
strChecked
strChecked
ThreeDeeRect
out,false
strChecked
strChecked
bottomLine
strChecked
topLine
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
strChecked
Animate
balloon
strChecked
&Button
false
Position property
label
myChapterID
visited
Each object in ToolBook has a property called position that tells ToolBook where the object sits relative to the top and left edges of the page. Moving an object involves changing this property.
Position is a list of two numbers given in page units. In the illustration to the right, drag the object and notice how its position property changes.
pageUnitsPopup
buttonclick
buttonclick
"pageUnitsPopup"
strChecked
in,true
ThreeDeeRect
strChecked
strChecked
bottomLine
strChecked
topLine
strChecked
descr
strChecked
The position is 1258,973. he illustration above is 1560,1455. ag the object=
strChecked
n ~ J
strChecked
strChecked
client
strChecked
strChecked
strChecked
ToolBook - POSITION.TBKign
strChecked
strChecked
strChecked
strChecked
File Edit View Page Object Draw
strChecked
9733page
yline
client
endpoint
endpoint
value
Znewb
cb =
client
xpix =
sysPageUnitsPerPixel
ypix =
b =
w =
v1 = x - w
v2 =
cb +
v3 = v1+w
v4 = y -
fref =
sz =
fpos = v3 +
*2,v2+(v4-v2)
y2 -
v4 - v2
strChecked
strChecked
centerLine
strChecked
xline
client
endpoint
endpoint
value
Znewb
xpix =
sysPageUnitsPerPixel
ypix =
cb =
client
b =
h =
v1 =
cb +
v2 = y - h
v3 = x -
v4 = v2 + h
fref =
sz =
fpos = v1+(v3-v1)
y2 -
y2,v4 +
v3 - v1
strChecked
strChecked
centerLine
strChecked
strChecked
1258page
strChecked
strChecked
strChecked
false
newChapterOrTopic
cancel
initpage
cancel
keyChar
close
initpage val
keyEnter
chapter
&Chapter
buttonclick
buttonclick
Cancel
buttonclick
buttonclick
Cancel
Cancel
strChecked
strChecked
strChecked
chapterCount
&Topic
topicCount
newChapterOrTopic
outlineOrganizer
aboutAnimation
cancel
initpage
;PALED30 EXE
PARADOX ATS
PCDLIB DLL
PCDXBMP DLL
PHOTO DLL
PRINTWNDSBK
PXENGWINDLL
RELNOTESHLP
RELNOTESWRI
MS Sans Serif
MS Sans Serif
MS Sans Serif
MS Sans Serif
MS Sans Serif
System
MS Sans Serif
MS Sans Serif
firstTime
System
MS Sans Serif
MS Sans Serif
MS Sans Serif
Times New Roman
Courier New
MS Sans Serif
Arial
Courier New
Arial
chapterCount
MS Sans Serif
Courier New
page "scriptRecorderPopup1"
toolbar
page "toolbar"
outline
Template Outline
page "outlineOrganizer"
location
clientSz
3360,7515
page "newChapterOrTopic"
Page "train"
Page "tv 1"
313,172
train
pageUnitsPopup
Page "pageunits"
buttonclick
buttonclick
close
The Animation Book
Page "tank"
4005,11130
scriptRecorderPopup
ScriptRecorderPopup2
page "scriptRecorderPopup2"
about
About Animation Book
page "aboutAnimation"
frame
screen
openwindow
closeWindow
openwindow
currentPage
pageUnitsToClient(
frame
T"screen"
closeWindow
435,450
extra
page "train"
Move command
label
myChapterID
visited
Moving an object involves setting its position property for each step of the animation. Usually this is accomplished in a loop structure, such as step or while.
The commands to use for moving an object are move to and move by.
Toolbook uses page units as the unit of measure to specify position.%
pageUnitsPopup
buttonclick
buttonclick
"pageUnitsPopup"
strChecked
strChecked
Move <object> to <position>
This command moves the specified object to the position supplied, for example:
move polygon "x" to 0,0
Moves it to the upper-left corner of the screen.een..
raisedField
tbk_wid_name
faceColor
highlightColor
shadowColor
tbk_wid_props
color,hls
color,hls
color,hls
tbk_wid_values
strChecked
highlight
strChecked
move toe Commandperty
shadow
strChecked
move toe Commandperty
* : J
strChecked
move toe Commandperty
raisedField
tbk_wid_name
faceColor
highlightColor
shadowColor
tbk_wid_props
color,hls
color,hls
color,hls
tbk_wid_values
strChecked
highlight
strChecked
move bye Commandperty
shadow
strChecked
move bye Commandperty
strChecked
move bye Commandperty
strChecked
Move <object> by <amount>
This command moves the object by the x and y amounts supplied, for example:
move polygon "x" by 45,60
Moves it 45 page units to the right and 60 down. s downits down