Skip to content

Instantly share code, notes, and snippets.

@kdoodoo
Created November 14, 2015 00:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kdoodoo/6e16324cf86b772cdf54 to your computer and use it in GitHub Desktop.
Save kdoodoo/6e16324cf86b772cdf54 to your computer and use it in GitHub Desktop.
var a = [];
var av;
var c = 0;
var d;
var e;
var f = 0;
function setup() {
}
function draw() {
createCanvas(windowWidth,windowHeight);
//VALUE
b = mouseX-windowWidth/2;
append(a, b);
//ARRAY
if(f<windowWidth){
for(f = 0 ; f < a.length ; f++){
d = a[f];
c = c + d;
e = c / a.length;
}
//COUNTER CHANGE
}
else{
f = 0;
}
stroke(100,255,100);
//line(i+1,windowHeight/2,i+1,(d+b)/2);
stroke(0);
line(f,windowHeight/2,f,windowHeight/2+d);
noFill();
strokeWeight(1);
stroke(0,0,random(0,255));
ellipse(windowWidth/2,windowHeight/2,e/10,e/10);
//console.log(e);
// console.log(a);
stroke(0,0,255);
text(e,windowWidth/2,windowHeight/2+20);
text(d,windowWidth/2,windowHeight/2);
text(c,windowWidth/2,windowHeight/2-20);
text(f,windowWidth/2,windowHeight/2-40);
strokeWeight(1);
console.log(f);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment