Created
September 6, 2015 20:33
-
-
Save bmoren/cee361e4d1f37643914b to your computer and use it in GitHub Desktop.
p5 Color Examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Vary the red based on the hour | |
var h; | |
function setup() { | |
createCanvas(600, 600); | |
} | |
function draw() { | |
h = hour(); | |
print(h); | |
//take 24 hour time and convert it to between 0 & 255 for the color slot | |
hColor = map(h,0,24,0,255); | |
fill(hColor,0,0); | |
rect(200,200,100,100); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//HSB colorshift | |
//Blue Hue: 239 | |
//Yellow Hue: 65 | |
//Red Hue: 0 | |
var h; | |
function setup() { | |
createCanvas(600, 600); | |
colorMode(HSB); | |
} | |
function draw() { | |
h = hour(); | |
print(h); | |
//take 24 hour time and convert it to between 0 & 255 for the color slot | |
hColor = map(h,0,24,0,239); | |
//uncomment below - keep it a varying set of blue all the time | |
//hColor = map(h,0,24,200,250); | |
fill(hColor,100,100); | |
rect(200,200,100,100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment