During World War I, and to a certain extent, World War II, many ships were painted in garish “dazzle” paint jobs as a form of camouflage.
As the first commenter notes, the goal wasn’t so much to hide the ship, but rather make a successful engagement more difficult. Remember, prior to the turn of the 20th Century, optical fire control was so primitive as to be effectively useless. But by the advent of World War I, the science of “rangekeeping” had advanced by leaps and bounds. Any techniques that made the use of optical rangefinders more difficult were employed.
In World War II, dazzle patterns were again used, but as radar became ubiquitous, optical rangefinders were relegated to back up status, and the difficulty of maintaining a dazzle paintjob was no longer worthwhile.