Forum Replies Created

Page 42 of 1081
  • Dan Ebberts

    July 26, 2023 at 2:50 am in reply to: Random colours from exact colour control colours

    Maybe like this:

    var color1 = effect("Color Control")("Color");
    var color2 = effect("Color Control 6")("Color");
    var color3 = effect("Color Control 4")("Color")
    var colors = [color1,color2,color3];
    var idx = Math.floor(random(colors.length));
    colors[idx];

    or like this if you want each color to hold longer than 1 frame:

    var color1 = effect("Color Control")("Color");
    var color2 = effect("Color Control 6")("Color");
    var color3 = effect("Color Control 4")("Color")
    var colors = [color1,color2,color3];
    var nFrames = 5;
    var f = timeToFrames(time);
    seed = Math.floor(f/nFrames);
    seedRandom(seed,true);
    var idx = Math.floor(random(colors.length));
    colors[idx];
  • Dan Ebberts

    July 18, 2023 at 5:50 pm in reply to: How to apply two different formations to text

    Once you apply an expression to source text, you’re stuck with a single style for all the text. Easiest is probably to use two layers and position the second line using sourceRectAtTime() to measure the first line.

  • Ah, sorry, forgot that part. Try this:

    m = marker;
    easeTime = .25;
    n = 0;
    if (m.numKeys > 0){
    n = m.nearestKey(time).index;
    if (time < m.key(n).time) n--;
    }
    temp = n;
    c = 0;
    while (temp > 0){
    if (m.key(temp).comment == "") break;
    c++;
    temp--;
    }
    c > 0 ? ease(time,m.key(n).time,m.key(n).time+easeTime,c-1,c) : 0
  • Something more like this maybe:

    m = marker;
    easeTime = .25;
    n = 0;
    if (m.numKeys > 0){
    n = m.nearestKey(time).index;
    if (time < m.key(n).time) n--;
    }
    n > 0 ? ease(time,m.key(n).time,m.key(n).time+easeTime,n-1,n) : 0
  • I’m not exactly sure what you’re after, but this is how I’d calculate how long it’s been since the last marker with no comment:

    m = marker;
    t = 0;
    if (m.numKeys > 0){
    n = m.nearestKey(time).index;
    if (time < m.key(n).time) n--;
    if (n > 0){
    for (i = n; i > 0; i--){
    if (m.key(i).comment == ""){
    t = time - m.key(i).time;
    break;
    }
    }
    }
    }
    t
  • Something like this maybe:

    function ConvertKeyframesToMarkers(){
    var comp = app.project.activeItem;
    if (! comp || ! (comp instanceof CompItem)){
    alert("No comp active.");
    return;
    }
    var props = comp.selectedProperties;
    var prop;
    var layer;
    var marker;
    var markerVal = new MarkerValue("");
    markerVal.label =1; // red
    for (var i = 0; i < props.length; i++){
    prop= props[i];
    layer = prop.propertyGroup(prop.propertyDepth);
    marker = layer.property("Marker");
    if (! (prop.propertyType == PropertyType.PROPERTY)) continue;
    for (var j = 1; j <= prop.numKeys; j++){
    marker.setValueAtTime(prop.keyTime(j), markerVal);
    }
    }
    }
    ConvertKeyframesToMarkers();
  • This should give you the last line:

    txt = text.sourceText;
    lines = txt.split("\r");
    lastLine = lines[lines.length-1];
  • To make it 3D I think you can just change toComp to toWorld in the the curPos and nextPos definitions.

  • Still not quite right. Should be closer:

    n = effect("Slider Control")("Slider").value;
    if (n >= 1000000){
    Math.floor(n/1000000) + n.toFixed(2).substr(-3) + "M";
    }else if (n >= 1000){
    Math.floor(n/1000) + n.toFixed(2).substr(-3) + "k"
    }else{
    n.toFixed(2);
    }

  • Try this:

    numSlider= effect("Slider Control")("Slider").value.toFixed(2);
    numSlider.replace(/\B(?=(\d{3})+(?!\d))/g,",");

    Edit: Sorry – I misread the question–for some reason I thought you wanted to add commas to large numbers.

    Maybe like this?

    n = effect("Slider Control")("Slider").value;
    if (n >= 1000000){
    Math.floor(n/1000000) + n.toFixed(2).substr(-3) + "M";
    }else{
    Math.floor(n/1000) + n.toFixed(2).substr(-3) + "K"
    }

Page 42 of 1081

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy