Created
November 3, 2018 15:08
-
-
Save vlna/001a4b53b95931de91d83ba490e2713a to your computer and use it in GitHub Desktop.
simple mouse controlled RGB mixer in Processing
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
int[] c = {30,120,180}; //default color | |
void setup() { | |
String[] args = {"ResultApplet"}; | |
ResultApplet ra = new ResultApplet(); | |
PApplet.runSketch(args, ra); | |
size(300, 256); | |
surface.setTitle("MixerApplet"); | |
} | |
void draw() { | |
for (int i=0;i<3;i++) { | |
stroke(i==0?255:0,i==1?255:0,i==2?255:0); | |
fill(255,255,255); | |
rect(i*100,0,99,256); | |
fill(i==0?255:0,i==1?255:0,i==2?255:0); | |
rect(i*100,255-c[i],99,c[i]); | |
} | |
} | |
void mouseWheel(MouseEvent event) { | |
int i = mouseX/100; | |
c[i]=c[i]-8*event.getCount(); | |
if (c[i]>255) {c[i]=255;} | |
if (c[i]<0) {c[i]=0;} | |
} | |
void mouseClicked() { | |
int i = mouseX/100; | |
c[i]=255-mouseY; | |
} | |
public class ResultApplet extends PApplet { | |
public void draw() { | |
surface.setSize(300,256); | |
background(c[0],c[1],c[2]); | |
fill(c[0]+c[1]+c[2]>=384?0:255); | |
textAlign(CENTER,CENTER); | |
textSize(40); | |
text(c[0]+","+c[1]+","+c[2],150,128); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment