fix the bugs caused by canvas coordinate system