Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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