Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Color change driven by JSON-file

  • Color change driven by JSON-file

  • Sebastian Martinez

    May 12, 2020 at 10:14 pm

    Dear Expression wizzards,

    I’m trying to achive this
    https://www.youtube.com/watch?v=JPiyOGyjWvI
    but not with the hight of the shape layer but with its fill.

    There is a JSON-file imported into my project. In there sections for individual counties (for example “[0]”) with several days (“day0” to “day45”) and corresponding values (lets say 50 to 2000).

    In my comp is also a Null-Object wich has two Color Control effects to provide two different colors. One is for a low value, the other fo a high value.

    Over time I’d like to fade between these colors according to the values in my data.

    I alredy tried but I’m stuck with this (and I haven’t magage to complete it):

    c = footage("tripcountsPerCountyPerDate.json").sourceData; // data-source imported in project

    v1 = c[0].day0; // first value of "0"
    v2 = c[0].day45; // last value of "0"

    ???

    startcolor = thisComp.layer("Null 42").effect("Color 1")("Color");
    endcolor = thisComp.layer("Null 42").effect("Color 2")("Color");

    ease(time, 1, 29, startcolor, endcolor);

    linear(v,0,100,startcolor,endcolor);

    So is it linear or ease at the end? And how do I get the values to drive the color?

    Thank you so much and best wishes
    Sebastian

    Sebastian Martinez
    CGI-Designer
    Cologne, Germany
    AE, AI, PS, 3ds max, C4d

    Some contents or functionalities here are not available due to your cookie preferences!

    This happens because the functionality/content marked as “Google Youtube” uses cookies that you choosed to keep disabled. In order to view this content or use this functionality, please enable cookies: click here to open your cookie preferences.

  • Sebastian Martinez

    May 13, 2020 at 3:33 pm

    Hi folks,

    I gave it another try myself and with the help of a friend of mine who is a Javascript-Pro, though he hasn’t ever touch AE before:

    counties = footage("test.json").sourceData;
    minmax = counties[counties.length-1];
    countyName = name.split("-")[1].split(" ")[0];
    var result;
    for(var i = 0; i < counties.length-1; i++) {
    if(counties[i].ID === countyName){
    result = counties[i].days;
    }
    }
    //v = result[timeToFrames(0)];
    v = result[Math.round(thisComp.layer("Null 42").effect("Slider Control")("Slider"))];
    startcolor = thisComp.layer("Null 42").effect("Color 1")("Color");
    endcolor = thisComp.layer("Null 42").effect("Color 2")("Color");
    linear (v,minmax.min,minmax.max,startcolor,endcolor);

    Data-source is a JSON-file imported into AE. The layer name ist a reference to pick its specific values out from the JSON. The part in the middle I don’t understand. But the results are driven by an animated slider (from 0 to 45 wich are the separat values animated over time). And the two colors for having a transition between them come from Color Controle effects named Color 1 and Color 2.

    The JSON-file partly look like this:

    The code works well. But might be written better I guess…

    Sebastian Martinez
    CGI-Designer
    Cologne, Germany
    AE, AI, PS, 3ds max, C4d

  • Tomas Bumbulevičius

    May 16, 2020 at 2:30 pm

    Hey Sebastian, any chance to actually know more about the colors?

    Lets say its blue for low, and red for high values. Does interpolation above works without introducing any non-related color values? Since color is 4 dimensional array – I wonder what results such interpolation brings in real life scenarios ! Cheers!

    Find out more:
    Motion Graphics Design & After Effects Tutorials
    On YT
    On VH

  • Sebastian Martinez

    May 26, 2020 at 1:37 pm

    Hi Tomas,

    thanks for asking! Regarding the colors – it just simply works. Even with 3 colors, two for max and min value and the third for medium value. The more colors you use the more distinguished is the result.

    For that I finally changed the workflow a bit by just using black and white for min and max values, prerender the result and on that image-sequence I used the Colorama-Effect to ramp values with multible colors. That way it is easier to edit the desired colors.

    Sebastian Martinez
    CGI-Designer
    Cologne, Germany
    AE, AI, PS, 3ds max, C4d

Viewing 1 - 4 of 4 posts

Log in to reply.

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