changed $r/ = 255; to $r = $r / 255;