Animating transformations. Adobe InDesign CS5
Anuncio
Anuncio
C HAPTER 11: Creating Dynamic Documents Working with Animation 169
Rem Given a document "myDocument" and a page "myPage" containg a polygon
Rem "myPolygonA" and a motion path myMotionPathPointsA...
Rem Remove the default timing list in the timing settings for the spread.
Rem Set animation preferences for the polygon.
myPolygonA.AnimationSettings.Duration = 2 myPolygonA.AnimationSettings.MotionPathPoints = myMotionPathPointsA myPage.Parent.TimingSettings.TimingLists.Item(1).Delete
Set myTimingSettings = myPolygonA.TimingSettings
Set myTimingList = myTimingSettings.TimingLists.Add(idDynamicTriggerEvents.idOnClick)
Set myTimingGroup = myTimingList.TimingGroups.Add(myPolygonA, 0)
Animating transformations
Page items can change size, rotation or skewing angles, opacity, and visibility as their animation plays. The
AnimationSettings
of the page item contain properties (such as
RotationArray
or
HiddenAfter
) that define the transformations that are applied during animation. The following script fragment shows how to make a page item rotate as it follows a motion path (for the complete script, refer to AnimateRotation).
Rem Given a document "myDocument" and a page "myPage" and the color "myColorA"...
Rem Add a page items to animate.
Set myPolygonA = myPage.Polygons.Add
myPolygonA.FillColor = myColorA myPolygonA.StrokeColor = myDocument.Swatches.Item("None") myPolygonA.Paths.Item(1).EntirePath = Array(Array(72, 72), Array(72, 144),
Array(144, 108))
Rem Create a motion path.
myMotionPathPoints = Array(Array(Array(Array(108, 108), Array(108, 108), Array(108,
108)), Array(Array(516, 108), Array(516, 108), Array(516, 108))), True)
Rem Set animation preferences for the polygon.
myPolygonA.AnimationSettings.Duration = 2 myPolygonA.AnimationSettings.MotionPathPoints = myMotionPathPoints
Rem Assuming 24 Frames Per Second (FPS)
Rem 23 = 1 second, 47 = 2 seconds, 71 = 3 seconds, 95 = 4 seconds, 119 = 5 seconds,
Rem 143 = 6 seconds
Rem Since the duration of our animation is 2 seconds, the following line will
Rem make the polygon rotate 360 degrees from the start to the end
Rem of the animation.
myPolygonA.AnimationSettings.RotationArray = Array(Array(0, 0), Array(47, 360))
Set myTimingSettings = myPage.Parent.TimingSettings
Rem Remove the default timing list.
myTimingSettings.TimingLists.Item(1).Delete
Rem Add a new timing list that triggers when the page is clicked.
Set myTimingList = myTimingSettings.TimingLists.Add(idDynamicTriggerEvents.idOnPageClick)
Rem Add the polygons to a single timing group.
Set myTimingGroup = myTimingList.TimingGroups.Add(myPolygonA, 0)
Scripting offers more control over animation than can be achieved with InDesign’s user interface. A scripted animation can, for example, apply transformations at each key frame of a given motion path. For
more on this topic, see “Key frames” later in this chapter.
Motion presets
In the preceding examples, we’ve constructed motion paths and specified animation settings as if we were creating animations from the basic level in InDesign’s user interface. But InDesign can also use motion presets to define the animation of page items in a layout. A motion preset can apply a number of animation properties at once, as seen in the following script fragment (for the complete script, refer to
Descargar
Anuncio