Skip to content

Instantly share code, notes, and snippets.

@chikoski
Created May 21, 2015 02:55
Show Gist options
  • Select an option

  • Save chikoski/ca33e219a4ddc98ef81c to your computer and use it in GitHub Desktop.

Select an option

Save chikoski/ca33e219a4ddc98ef81c to your computer and use it in GitHub Desktop.
function draw(){
ctx.fillStyle = "rgb(32, 32, 32)";
ctx.fillRect(0, 0, canvas.width, canvas.height);
var data = [20, 40, 50, 60, 30, 10, 20, 40, 70, 5, -1, -20, -5, -20, -7, -5, 5];
ctx.fillStyle = "rgb(255, 255, 255)";
var i = 0;
var offset = 5;
var width = (canvas.width - offset * (data.length + 1))/ data.length;
while(i < data.length){
var x = offset * (i + 1) + width * i;
ctx.fillRect(x, canvas.height / 2 - data[i] * 4,

width, data[i] * 4);
i = i + 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment