Got invert largely compatible with cursor pixel. Found a bug and fixed it (it was saving to canvas history too many times), discovered minor bug in selection function.