ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Color change driven by JSON-file

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Sebastian Martinez
Color change driven by JSON-file
on May 12, 2020 at 10:14:50 pm

Dear Expression wizzards,

I'm trying to achive this





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


Return to posts index

Sebastian Martinez
Re: Color change driven by JSON-file
on May 13, 2020 at 3:33:17 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


Return to posts index

Tomas Bumbulevičius
Re: Color change driven by JSON-file
on May 16, 2020 at 2:30:33 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


Return to posts index


Sebastian Martinez
Re: Color change driven by JSON-file
on May 26, 2020 at 1:37:04 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


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]