Skip to content

Instantly share code, notes, and snippets.

@roundrobin
Created April 6, 2013 07: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 roundrobin/5325290 to your computer and use it in GitHub Desktop.
Save roundrobin/5325290 to your computer and use it in GitHub Desktop.
Canvas exmpla
{"editor_editor":{"coffee":false,"vim":false,"emacs":false,"width":600,"height":300,"hide":false},"description":"Canvas exmpla","endpoint":"","display":"canvas","public":true,"require":[],"fileconfigs":{"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"inlet.svg":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/7cuR5VK.png"}
function getRandomInt (min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
var canvas = tributary.canvas;
var ctx = canvas.getContext("2d");
for(var i=0;i < 1000; i++){
var x = getRandomInt(1,41);
if(i % 10 == 0){
ctx.fillStyle = "rgb("+(255)+",240,0)";
} else {
ctx.fillStyle = "rgb(0,0,0)";
}
ctx.fillRect ( (0.51 * i)+100, 3, 0.1, x);
}
ctx.fillStyle = "rgba(0,0,250,0.5)";
ctx.fillRect (100, 3, 124, 40);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment