Dynamically process calendar event style

Continuing the discussion from How can I dynamically process calendar event names?:

I'd like to be able to write a simple script that can take as input calendar events (calendar, event title, time start/end) and output a processed style (set background color, shorten event name systematically, etc.) much like how the shell script widgets work.