Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Change fillColor in a Text Layer with the Source Text keyframe?

Explorer ,
Oct 06, 2016 Oct 06, 2016

Dear all. In ExtendScript I'd like to change the color of a text more than once in a comp, without transitions. I know it can be done with an Animator, but I'd like to do it in the Source Text keyframe so that the comp keeps as minimal as possible.

I know how to change the fillcolor of a textlayer using:

var TextColorLayer = comp.layer("MyTextLayer").property("Text").property("Source Text");

var TextDocument = TextColorLayer.value;

TextDocument.fillColor = [1,1,1];

TextColorLayer.setValue(TextDocument);

Obviously this next one does not work, but I have no idea where to put the fillColor here..

var TextColorLayer = comp.layer("MyTextLayer").property("Text").property("Source Text");

var TextColorAddKeys = [currentTime];

var TextColorAddValues = [[1,1,1]];

TextColorLayer.setValuesAtTimes(TextColorAddKeys,TextColorAddValues);

Hope someone can help me out, otherwise I use the Animator-solution which has it's advantages too.

TOPICS
Scripting
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Oct 06, 2016 Oct 06, 2016

I'm not familiar with Animator, but this is the way you set ONE keyframe to a property:

main();

function main() {

  var myComp = app.project.activeItem;

  if (!myComp || !(myComp instanceof CompItem)) {

  alert("Select a Composition first")

  return;

  }

  var mylayer = myComp.selectedLayers[0];

  if (!mylayer || !(mylayer instanceof TextLayer)) {

  return

  }

  var keyTime = myComp.time;

  var colorValue = [1, 1, 1];

  var textProp = mylayer.property("Text").property("Source Text");

  var textDocument = sourc

...
Translate
Advocate ,
Oct 06, 2016 Oct 06, 2016

I'm not familiar with Animator, but this is the way you set ONE keyframe to a property:

main();

function main() {

  var myComp = app.project.activeItem;

  if (!myComp || !(myComp instanceof CompItem)) {

  alert("Select a Composition first")

  return;

  }

  var mylayer = myComp.selectedLayers[0];

  if (!mylayer || !(mylayer instanceof TextLayer)) {

  return

  }

  var keyTime = myComp.time;

  var colorValue = [1, 1, 1];

  var textProp = mylayer.property("Text").property("Source Text");

  var textDocument = sourceText.value;

  textDocument.fillColor = colorValue;

  textProp.setValueAtTime(keyTime, textDocument)

}

The following script will add 5 keyframes with different colors.

main();

function main() {

  var myComp = app.project.activeItem;

  if (!myComp || !(myComp instanceof CompItem)) {

  alert("Select a Composition first")

  return;

  }

  var mylayer = myComp.selectedLayers[0];

  if (!mylayer || !(mylayer instanceof TextLayer)) {

  return

  }

  var keyTimes = [1, 2, 3, 4, 5];

  var colorValues = [[1, 1, 1], [0.5, 0.5, 0.5], [0.56, 0.12, 0.99], [0.12, 0.1, 0.45], [0.69, 0.21, 0.3]];

  var textProp = mylayer.property("Text").property("Source Text");

  for (var i = 0, il = keyTimes.length; i < il; i ++) {

  var curTime = keyTimes;

  var curValue = colorValues;

  var textDocument = sourceText.value;

  textDocument.fillColor = curValue;

  textProp.setValueAtTime(curTime, textDocument);

  }

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 06, 2016 Oct 06, 2016

Dear Tomas, ah yes, that makes a lot of sense, many thanks for pointing this out.

One note, I changed this line

var textDocument = sourceText.value;

into this:

var textDocument = textProp.value;

to make it work.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Oct 06, 2016 Oct 06, 2016

Oh yes, sorry for confusion.

Not sure how I left that in there.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 06, 2016 Oct 06, 2016
LATEST

No problem, you solved my main problem anyway. The other solution with the Animator is pointed out here, just pasting this here for further reference. In some cases it could be more user friendly to set the color in a separate keyframe: How to implement fill-color transition in script ? Call setValueAtTime ? It doesn't work.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines