Categories

M Train – Code

A drawing board to draw tonal scale.

Video: 

 

Image:

 

Processing Code:

int x;
int y = 20;
int w = 100;
int h = 100;
int a = 0;

color circColor;

void setup(){

size(500,500);
background(0);

fill(255);
textSize(14);
text(“Press keys to see what they looks like!”, 10, 30);
text(“D as ‘do’, R as ‘re’, etc.”, 10, 60);
}

void draw(){
if (x>500){
x=0;
y = y+100;
a = a +100;
if(x<500){
y = y -20;
}
}

fill(circColor);
ellipse(x,500-y,w,h);

x = x+1;

}

 

void whichKeyIsPressed(char keyCharBig, char keyCharSmall, int toneColorR, int toneColorG, int toneColorB, int yAdd){
if(key == keyCharBig || key == keyCharSmall){
circColor = color(toneColorR, toneColorG,toneColorB);
x = x+10;
y = a+yAdd;
}
}

void keyPressed(){
whichKeyIsPressed(‘d’,’D’,208,82,255,20);
whichKeyIsPressed(‘r’,’R’,232,94,78,30);
whichKeyIsPressed(‘m’,’M’,255,181,59,40);
whichKeyIsPressed(‘f’,’F’,232,228,72,50);
whichKeyIsPressed(‘s’,’S’,86,255,108,60);
whichKeyIsPressed(‘l’,’L’,94,255,212,70);
whichKeyIsPressed(‘x’,’X’,75,118,232,80);

 

No Comments

Leave a Comment: