Created
March 20, 2018 06:55
-
-
Save s-estay/22b59e1f66f98865d6e05ba6d633f684 to your computer and use it in GitHub Desktop.
Contain script within div tag using p5 parent element.
This file contains 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
//RGB rainbow colors | |
var rainbowR = [248, 255, 255, 254, 208, 105, 18, 68, 59]; | |
var rainbowG = [12, 51, 102, 174, 195, 208, 189, 68, 12]; | |
var rainbowB = [18, 17, 68, 45, 16, 37, 185, 221, 189]; | |
var i; | |
var canvas; | |
var t = rainbowR.length; | |
function setup() { | |
canvas = createCanvas(640, 100); | |
canvas.parent('script-holder'); | |
i = 0; | |
} | |
function draw(){ | |
//background | |
background(255); | |
//borders | |
fill(255); | |
stroke(0); | |
rect(0, 0, 639, 99); | |
//ellipse click | |
stroke(255); | |
fill(rainbowR[i], rainbowG[i], rainbowB[i]); | |
ellipse(mouseX, mouseY, 50, 50); | |
//ellipse static | |
stroke(255); | |
fill(0, 100); | |
ellipse(320, 50, 50, 50); | |
} | |
function mousePressed(){ | |
if(i < t - 1){ | |
i += 1; | |
} | |
else{ | |
i = 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment