Gil Sperling

video, stage and music

Animating in code

September 17, 2019 by gilsperling

The most fun I’ve had so far at ITP was playing the bouncing ball sketch with my son (2.5). I would ask him what size he wanted the ball to be and what color, and then I would change it in setup. He loved it. Naturally, next I want these parameters to be controlled directly through voice recognition.

For my animated sketch, I began making all the dimension variables dependents of the head size of the figure, so that the entire portrait could be changed by changing one or two variables. There are still a few hard coded variables, like the number of hairs.

The first animation idea was to have the eyes tracking the mouse – that was implemented using the map function. The next layer was the timed animation of the hair moving, which has a mouse-dependent element as well. I would want each hair to move independently, but I think that requires getting into classes.

After those two elements were set I came up with the idea of the tongue reaching out to swallow the mouse cursor. I discovered I had to use booleans to define different states (tongue drawing, tongue retracting). I was almost there, but then I found a bug – if the mouse was moving while the tongue was drawing, it would continue drawing forever. It seems that the map function can’t work properly if the value used to define the range is a variable. I overrode it by differentiating between the mouse coordinates and the “target” coordinates, and froze the object during the tongue animation. There must be a way, however, to have a line draw towards a moving point, just as we are able to move an object toward it. But that will have to do for this week…

Posted in Fall '19 - Introduction to Computational Media |

Comments are closed.