JS smoothing functions for scalar value using interpolation curves (Composition by usefuldesign.au)

Author: usefuldesign.au
License: (unknown)
Date: 2011.04.27
Compatibility: 10.5, 10.6
Categories:
Required plugins:
(none)

This JS code implements custom JS functions I wrote too mimic Quartz Composer's standard Smooth Patch inside JS patch execution.

The demo comp shows the results are identical to all the curves associated with the interpolation and smooth patches.

The motivation for writing was the annoying procrastination that the JS Smooth Array code that the Apple QC Visualiser Template employs. It's noticeable that the acceleration is proportional to it's distance from the current input value, resulting in sprites that seem repelled by their target co-ordinates when using that kind of expression. It's also not observant of a set period and is dependant on the input delta for it's slope, since it only carries the last frame value in state — nothing else.

I've also included files for Apples Grapher app which I used to determine the curve expressions (equations). Thanks to Yves Barois who help me to use Grapher's trickier functions (hello piecewise equations) despite Apples woefully scant documentation for that app.

Please credit code when used or used with alterations in your JS code and in your QC comp. Drop me an email too if you like!

usefuldesign [dot] au [at] gmail [dot] com

PreviewAttachmentSize
Javascript smoothing functions.qtz83.32 KB

usefuldesign.au's picture
Re: JS smoothing functions for scalar value using ...

Grapher App files and 2 screen-grabs (grapher files for all the curves in zip file):


Quadratic In (aqua), Quadratic Out (blue) and the composite expressions (pink and brown) that make Quadratic In-Out (light green)




Sine In, Sine Out and Sine In-Out




usefuldesign.au's picture
Re: JS smoothing functions for scalar value using ...

More documentation: