тва дали ще стане
//
// Random3dText_w_depth_xyz.jsx
//
//Byron Nash 01/05
//The text reading/creating was borrowed from createTextLayersFromFile.jsx
// by Dan Ebberts
//
// This script reads a user specified text file and
// creates a text layer for each line of text in a
// new comp called "Text Comp", or it uses the active comp.
// - adds expression to control a random placement in 3d space
// - adds expression to control a depth fade as the layer recedes from the camera
// - creates a new camera and a null with sliders to control the effect
//
// added x,y,z sliders 10/2007 lloyd alvarez
//
{
// create undo group
app.beginUndoGroup("Create Text Layers From File");
// Prompt user to select text file
var myFile = fileGetDialog("Select a text file to open.");
if (myFile != null){
// open file
var fileOK = myFile.open("r","TEXT","????");
if (fileOK){
// create project if necessary
var proj = app.project;
if(!proj) proj = app.newProject();
//set currently selected comp to variable
var myComp = app.project.activeItem;
//check to see if selected item is a comp, if not, make a new comp
if(proj.activeItem instanceof CompItem) {
var myComp = proj.activeItem;
}else{
// create new comp named 'my text comp'
var compW = 720; // comp width
var compH = 486; // comp height
var compL = 15; // comp length (seconds)
var compRate = 29.97; // comp frame rate
var compBG = [0/255,0/255,0/255] // comp background color
var myItemCollection = app.project.items;
var myComp = myItemCollection.addComp('Text Comp',compW,compH,1,compL,compRate);
myComp.bgColor = compBG;
}
//setup controller null and add expression sliders
var controlLayer = myComp.layers.addNull();
controlLayer.startTime = 0;
controlLayer.enabled = false;
controlLayer.source.name = "Controller";
var theControl = controlLayer.Effects.addProperty("ADBE Slider Control");
theControl.name = "X_Spread";
theControl.property(1).setValue(0);
var theControl = controlLayer.Effects.addProperty("ADBE Slider Control");
theControl.name = "Y_Spread";
theControl.property(1).setValue(0);
var theControl = controlLayer.Effects.addProperty("ADBE Slider Control");
theControl.name = "Z_Spread";
theControl.property(1).setValue(0);
var opacityMin = controlLayer.Effects.addProperty("ADBE Slider Control");
opacityMin.name = "Start Fade";
opacityMin.property(1).setValue(0);
var opacityMax = controlLayer.Effects.addProperty("ADBE Slider Control");
opacityMax.name = "End Fade";
opacityMax.property(1).setValue(1000);
var cam = myComp.layers.addCamera("Camera 1",[360,243]);//make a new camera
// read text lines and create text layer for each
// until end-of-file is reached
var text;
while (!myFile.eof){
text = myFile.readln();
if (text != "") {
var curLayer = myComp.layers.addText(text);
curLayer.threeDLayer = true;
//define expressions on position and opacity
var posExp = 'seedRandom(index,true);\r'+
'x_slider = thisComp.layer("Controller").effect("X_Spread")("Slider");\r'+
'y_slider = thisComp.layer("Controller").effect("Y_Spread")("Slider");\r'+
'z_slider = thisComp.layer("Controller").effect("Z_Spread")("Slider");\r'+
'midWidth = thisComp.width/2; midHeight = thisComp.height/2;\r'+
'x = random(x_slider,x_slider*-1);\r'+
'y = random(y_slider,y_slider*-1);\r'+s
'z = random(z_slider,z_slider*-1);\r'+
'[x+midWidth,y+midHeight,z];\r';
var opacExp = 'depth = length(position,thisComp.layer("Camera 1").position);\r'+
'min = thisComp.layer("Controller").effect("Start Fade")("Slider");\r'+
'max = thisComp.layer("Controller").effect("End Fade")("Slider");\r'+
'linear(depth,min,max,100,0)';
//add expressions on position and opacity
curLayer.property("position").expression = posExp;
curLayer.property("opacity").expression = opacExp;
}
}
controlLayer.moveToBeginning();//moves the null to the top of the stack
cam.moveToBeginning();//moves the cam to the top of the stack
// close the file before exiting
myFile.close();
}else{
alert("File open failed!");
}
}else{
alert("No text file selected.");
}
app.endUndoGroup();
}