SS.3.01 Auto-Random Colour Picker with Expressions

My journey into Javascript with After Effects starts relatively simply with this Monday morning activity. This is actually a do-over of something I created in my free time on placement. The first time I made this, I didn’t set out to create something using expressions but I did end up using my existing knowledge of if/else statements to build a randomised colour picker.

The scene was an existing one from 1:14 in Buck’s video, Onward Internet.

Onward Internet from Buck on Vimeo.

The first time round, I set out to reproduce it just to see if I could do it with my skillset. This was a good few months ago, and I didn’t save the original file so I used this morning to create it again from scratch.

I remembered my general approach to this scene but not the code itself. The scene is simply made from triangular masked solids with a rotation of (index-1)*18 so that when the layer is duplicated, the layer is rotated automatically, this is just a time saving trick so that I can easily create and delete the layers, like this:

buck_designprocess01

Next there was a struggle to get the if/else statement right. A syntax that may make sense to me might not translate well to after effects, I had to tray a few different methods before I found one that worked. As a result though, I have learned a little more about how After Effects thinks with random numbers.

Buck_DesignProcess02.gif

Eventually I managed to establish a code that worked, producing random colours from my palette of 6.

screen Shot (1-36-57-28).png

The only downfall of this is that the code did use pure random numbers meaning that some consecutive shapes had the same colour. I had to go into quite a few individual layers and change their colours, which defeats the point of using expressions to achieve that effect. To make this work as a script I’d have to code in some sort of clause that recognises the colours either side and ensures that those ones are different. The issue of course will also occur less if more colours are used.
Highlighted in purple are the layers that I had to change manually. Both on the base composition and on the 2nd layer composition.

screen-shot-2016-10-31-at-11-40-26

screen-shot-2016-10-31-at-11-40-18

Just for fun, here is a comparison to show my final shot next to the one from Buck.

buckrender02

onwardinternetclip


Edit: November 14th 2016

It might be possible to develop a script from this, to create random colour backgrounds IF i can get my hands on the code behind the repeater function found in AE shape layers.

Advertisements

Author: Pip Williamson

Pip // Animator & Motion Designer

2 thoughts on “SS.3.01 Auto-Random Colour Picker with Expressions”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s