title: Randomly generate 3 distinct colors
body: <p>I've looked at <a href="https://stackoverflow.com/q/15282580/7128934">this one</a> but does not help with the random part. Is there a better way to randomly generate 3 different colors so that the square, the circle, and the text stand out visually from one another in the code below. The colors have to be randomly generated and also distinct enough from one another. The current code works maybe only half the time</p>
  
  <pre><code>plot(0, type = "n", xlim = c(0,10), ylim = c(0,10),
      ann = FALSE, axes = FALSE, asp = 1)
  
  cols = colorRampPalette(sample(2:9,2), alpha = TRUE)(8)
  
  polygon(x = c(1,9,9,1), y = c(1,1,9,9), border = NA, col = cols[1])
  
  symbols(x = 5, y = 5, circles = 4, inches = FALSE,
      add = TRUE, bg = cols[4], fg = NA)
  
  text(x = 5, y = 5, labels = "Hi", col = cols[7], font = 2, cex = 3)
  </code></pre>
  
  <h1>EXAMPLES</h1>
  
  <p><strong>GOOD</strong></p>
  
  <p><a href="https://i.stack.imgur.com/OfzR4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OfzR4.png" alt="enter image description here"></a></p>
  
  <p>POLYGON: "#FF00FFFF", CIRCLE: "#916DFFFF", TEXT: "#24DAFFFF"</p>
  
  <p><strong>BAD</strong></p>
  
  <p><a href="https://i.stack.imgur.com/6gRj1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6gRj1.png" alt="enter image description here"></a></p>
  
  <p>POLYGON: "#00FFFFFF", CIRCLE: "#51E3E3FF", TEXT: "#A2C7C7FF"</p>