Salir
  • Comunidad global
    • Idioma:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티

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

Explorador ,
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.

TEMAS
Scripts
1.1K
Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines

correct answers 1 respuesta correcta

Defensor , 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

...
Traducir
Defensor ,
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);

  }

}

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Explorador ,
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.

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Defensor ,
Oct 06, 2016 Oct 06, 2016

Oh yes, sorry for confusion.

Not sure how I left that in there.

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines
Explorador ,
Oct 06, 2016 Oct 06, 2016
MÁS RECIENTES

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.

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines