Skip to content

Instantly share code, notes, and snippets.

@lizzybrooks
Forked from nataliefreed/randomColorFromArray.js
Last active February 26, 2018 20:43
Show Gist options
  • Save lizzybrooks/8cccb105a745af23f9494311057f3034 to your computer and use it in GitHub Desktop.
Save lizzybrooks/8cccb105a745af23f9494311057f3034 to your computer and use it in GitHub Desktop.
Pick a random color from an array in P5
function setup() {
createCanvas(700, 400);
var listOfColors = [color('#aabf12'), color('#33ab12'), color('#165512'), color('#fe3fa2'), color('#a345cd')];
strokeWeight(100);
for(var i=0;i<listOfColors.length;i++) {
stroke(listOfColors[i]);
// stroke(listOfColors[int(random(0, listOfColors.length))]); //to randomize, comment this line in
line(0, 0, 0, height);
translate(100, 0);
}
}
function draw() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment