Skip to content

Instantly share code, notes, and snippets.

@MartinMSPedersen
Created February 19, 2021 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MartinMSPedersen/4a561531657de549971918767359ddd4 to your computer and use it in GitHub Desktop.
Save MartinMSPedersen/4a561531657de549971918767359ddd4 to your computer and use it in GitHub Desktop.
Make two colour - one light and one dark
f1 <- sample(0:255,3)
while (sum(f1*c(0.2126,0.7152,0.0722)) < 0.85*255) { # brightness
f1 <- sample(0:255,3)
}
f2 <- sample(0:255,3)
while (sum(f2*c(0.2126,0.7152,0.0722)) > 0.15*255) { # brightness
f2 <- sample(0:255,3)
}
if (runif(1) > 0.5) {
farve1 <- rgb(f1[[1]], f1[[2]], f1[[3]], maxColorValue = 255)
farve2 <- rgb(f2[[1]], f2[[2]], f2[[3]], maxColorValue = 255)
} else {
farve2 <- rgb(f1[[1]], f1[[2]], f1[[3]], maxColorValue = 255)
farve1 <- rgb(f2[[1]], f2[[2]], f2[[3]], maxColorValue = 255)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment