Allow negative numbers

Changed the code to calculate a range rather just use max when
calculating the sparkling. This means negative numbers are now
supported.

Documentation was tweaked to add another example, this time of cosine
wave generation.