You set HSB-mode to pg with pg.colorMode(HSB);
So the external graphics is in HSB-mode, but processing display is not. Then in drawrect you read HSB values and color is in RGB-mode.
To get rid of changes you need to set processing display to HSB mode with command colorMode(HSB);
. A good place for it is just at the end of setup().