refactor ctx to canvas