Converted to use doubles throughout for pixel positions