Changing shape color over time online

Hi all,

I’m developing an online study where I need the outline color of a shape to change slowly over time from white to red.

What I have now is a polygon component with a a Border color of “$TimerColor”. Above it I have a code component with “TimerColor = [1,1,1]” at the start of each routine and TimerColor = [x - .01 for x in TimerColor] in each frame.

This works to gradually change the color from white to black over a few seconds. However, this isn’t quite what I need.

Here is what I haven’t figured out yet:

  1. How to ensure this change happens over a set number of seconds (e.g., change occurs over 2.5 seconds exactly).
  2. How to make the color shift from white to red (instead of white to grey).

Note that I will need this to work for online experiments so I can’t use python libraries like numpy.

Any help is greatly appreciated!


if t < 2.5:
     TimerColor = [1, 1-2*t/2.5, 1-2*t/2.5]

That works well! Thank you!