home *** CD-ROM | disk | FTP | other *** search
- //////////////////////////////////////////////////
- //
- // ADOBE SYSTEMS INCORPORATED
- // Copyright 2002 Adobe Systems Incorporated
- // All Rights Reserved
- //
- // NOTICE: Adobe permits you to use, modify, and
- // distribute this file in accordance with the terms
- // of the Adobe license agreement accompanying it.
- // If you have received this file from a source
- // other than Adobe, then your use, modification,
- // or distribution of it requires the prior
- // written permission of Adobe.
- //
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // Gradient and Twirl.js
- //
- // DESCRIPTION
- //
- // This script gives the gradient and twirl effect
- // to objects selected and animates them over frames.
- //
- // HOW TO USE
- //
- // Create any object(s) and select them in the Composition.
- // Select Automation > Run Automation Script
- // > Gradient and Twirl.js
- //
- // Click on Preview Mode to view the objects
- // gradient and twirl effect.
- //
- //////////////////////////////////////////////////
-
-
- // Main Code [Execution of script begins from here]
-
- // Check if any composition is open
- if(application.compositions.length > 0){
- comp = application.currentComposition;
- if(comp.selection.length >= 1){ // Checks if at least one object is selected
- var targets = comp.selection; // Store all selected objects in the array targets
-
- application.currentComposition.saveSelection(); // saves the current selection
- // Call function Gradient
- // Make changes in the parameters to try with different results.
- Gradient(targets, 48, 250, 250, 100, 50, 200);
-
- // Call function distort
- // Make changes in the parameters to try with different results.
- Distort(targets, 48, 200, 3);
-
- application.currentComposition.restoreSelection(); // restores the saved selection
- }
- else{ // If no objects are selected brings the Console window up
- Console.show();
- // Writes to the Console
- Console.write("Please select the objects to give gradient and twirl effect run script again.\n");
- }
- }
- else{// if no composition open
- // opens a new composition
- comp = application.newComposition();
- Console.show();
- Console.write("New Composition opened\nPlease create and select the objects give gradient and twirl effect and run script again.\n");
- }
-
-
- // Add your own functions here
-
- //////////////////////////////////////////////////
- //
- // Gradient:
- //
- // Set the targets objects with a given Gradient.
- // The starting color RGB values have to be specified for start of gradient.
- // The ending color RGB values have to be specified for end of gradient.
- // Both have to be significantly different to see the best result of the effect.
- //
- // targets: The objects to give the gradient and twirl effect
- // startRed: start red color for the gradient
- // starGreen: start green color for the gradient
- // starBlue: star blue color for the gradient
- // endRed: end red color for the gradient
- // endGreen: end green color for the gradient
- // endBlue: end blue color for the gradient
- //
- //////////////////////////////////////////////////
-
-
- function Gradient(targets, startRed, startGreen, startBlue, endRed, endGreen, endBlue)
- {
- // loop through all of the selected objects
- // Set their gradient type and the start and end color for the gradient
- for(var i=0 ; i < targets.length ; i++){
- targets[i].layers[0].colorGradient.type = LMGradientType.burst;
- targets[i].layers[0].colorGradient.startColor.red = startRed;
- targets[i].layers[0].colorGradient.startColor.green = startGreen;
- targets[i].layers[0].colorGradient.startColor.blue = startBlue;
- targets[i].layers[0].colorGradient.endColor.red = endRed;
- targets[i].layers[0].colorGradient.endColor.green = endGreen;
- targets[i].layers[0].colorGradient.endColor.blue = endBlue;
- }
- }
-
-
- //////////////////////////////////////////////////
- //
- // Distort:
- // Give the distort effect - twirl to the targets object(s)
- //
- // targets: The objects to give twirl distortion effect
- // frames: The total number of frames across which the turns are set.
- // finalTurns: The number of turns in the twirl effect
- // keyFrameRate: The attribute will be recorded every this frame
- // i.e. if keyFrameRate is 3 attribute is set at every 3rd frame and so on.
- //
- // Note: The twirl turns cannot be seen without a gradient because
- // then both will be of the same color. Hence here we have a gradient
- // before twirl turn.
- //
- //////////////////////////////////////////////////
-
-
- function Distort(targets, frames, finalTurns, keyFrameRate)
- {
- // Loop through all of the selected objects
- for(var i=0 ; i < targets.length ; i++){
-
- // variable to store the original distortion type of the object.
- var oriDistort = targets[i].layers[0].stopwatch.distortion.type;
-
- // variable to store the original number of turns the object has.
- var oriTwirlTurns = targets[i].layers[0].stopwatch.distortion.twirlTurns;
-
- // Set the current original frame as the current frame
- var frame0 = targets[0].startFrame;
-
- // Finding the amount of turns to be set per key frame
- var singleTurn = Math.round(finalTurns * keyFrameRate/frames);
-
- // Turn stopwatches for distortion and then twirlturns on
- // You can specify positive or negative number of turns
- // for clockwise or anti-clockwise turns respectively
- targets[i].layers[0].stopwatch.distortion.type = true;
- targets[i].layers[0].stopwatch.distortion.twirlTurns = true;
-
- // Recording the attributes after the stopwatches are turned on, hence
- // assigning the oriainal values stored back to the object
- targets[i].layers[0].distortion.type = oriDistort;
- targets[i].layers[0].distortion.twirlTurns = oriTwirlTurns;
-
- // Setting the first frame of each object as the original frame
- targets[i].currentFrame = frame0;
-
- // Set the distortion type
- targets[i].layers[0].distortion.type = LMDistortType.twirl;
-
- // Loop to go through all the frames across which to set the final number
- // turns
-
- for(var j=0 ; j < frames ; j += keyFrameRate){
- // Set the key frame
- targets[i].currentFrame = frame0 + j;
-
- // Increase the number of turns at each key frame
- targets[i].layers[0].distortion.twirlTurns += singleTurn;
- }
- }
- }
-
-
-
-
-
-