one day i'll rewrite this (stolen from a wolfram cdf demo)