changed code to create a PixelPainter function