refact the painting related code, mv to new package.