Change scale and offset to use a single function.